disable hyperlink

312 views
Skip to first unread message

Litty Preeth

unread,
Nov 26, 2008, 9:55:54 AM11/26/08
to Google Web Toolkit
Hi,

Anybody knows how we can disable a HyperLink in GWT?

Regards,
Litty Preeth

mikeds...@gmail.com

unread,
Nov 26, 2008, 11:03:02 AM11/26/08
to Google Web Toolkit
It's a little hacky, but we just substitute a label in it's place.

alex.d

unread,
Nov 27, 2008, 2:30:56 AM11/27/08
to Google Web Toolkit
If you wanna it look disabled - change CSS style. If you wanna your
clickListener not being executed - just remove it(use a single
listener method - not an anonymous inner class).

On 26 Nov., 17:03, "mikedshaf...@gmail.com" <mikedshaf...@gmail.com>
wrote:

Danny Schimke

unread,
Nov 27, 2008, 2:38:32 AM11/27/08
to Google-We...@googlegroups.com
Should'nt setVisible() do this for HyperLinks too?

setVisible needs an element and boolean:

myHyperLink.setVisible(myHyperLink.getElement(), false);

otherwise do what alex.d says:

add and remove a style name which do this.
CSS: visibility: hidden;

2008/11/27 alex.d <alex.du...@googlemail.com>

Litty Preeth

unread,
Nov 27, 2008, 6:38:17 AM11/27/08
to Google-We...@googlegroups.com
But even if you remove the clickListener, it will cause an onHistroryChange event right?

Danny Schimke

unread,
Nov 27, 2008, 10:10:21 AM11/27/08
to Google-We...@googlegroups.com
You are right: it calls the onHistoryChanged- Event. Thats why we created a new button-Widger which extends from Button with only one difference: it has a different link style by default (looks like a link). Then you don't call onHistoryChanged- method. On Button- Click you can add or remove an style name which changes the color of your link-button to gray (look disabled).

CSS for your link-button should look something like this:
.button-link {
  cursor: pointer;
  cursor: hand;
  border: none;
  /* Disable the button-style */
  background-color: transparent;
  padding: 0px;
  color: #4784C3;
  text-decoration: underline;
}

2008/11/27 Litty Preeth <preet...@gmail.com>

alex.d

unread,
Nov 27, 2008, 10:20:34 AM11/27/08
to Google Web Toolkit
Nice button style, Danny. However if you don't want to handle the
onHistoryChanged-Event - well just don't: set the hyperlink's token to
something like "dont_handle_this_token" and don't handle it ;-) But
the button-hyperlink idea is somehow cleaner.

On 27 Nov., 16:10, "Danny Schimke" <schimk...@googlemail.com> wrote:
> You are right: it calls the onHistoryChanged- Event. Thats why we created a
> new button-Widger which extends from Button with only one difference: it has
> a different link style by default (looks like a link). Then you don't call
> onHistoryChanged- method. On Button- Click you can add or remove an style
> name which changes the color of your link-button to gray (look disabled).
>
> CSS for your link-button should look something like this:
> .button-link {
>   cursor: pointer;
>   cursor: hand;
>   border: none;
>   /* Disable the button-style */
>   background-color: transparent;
>   padding: 0px;
>   color: #4784C3;
>   text-decoration: underline;
>
> }
>
> 2008/11/27 Litty Preeth <preeth.h...@gmail.com>
>
> > But even if you remove the clickListener, it will cause an onHistroryChange
> > event right?
>
> > On Thu, Nov 27, 2008 at 1:08 PM, Danny Schimke <schimk...@googlemail.com>wrote:
>
> >> Should'nt setVisible() do this for HyperLinks too?
>
> >> setVisible needs an element and boolean:
>
> >> myHyperLink.setVisible(myHyperLink.getElement(), false);
>
> >> otherwise do what alex.d says:
>
> >> add and remove a style name which do this.
> >> CSS: visibility: hidden;
>
> >> 2008/11/27 alex.d <alex.dukhov...@googlemail.com>

Danny Schimke

unread,
Nov 27, 2008, 10:36:19 AM11/27/08
to Google-We...@googlegroups.com
Yeah, thanks alex ^^

I thought about what you said: I had the same idea to put something like "dont_handled_token". But with something like firebug it's no problem to change the link (even it is absurd) and then JS- errors occurs... I haveno idea to use Hyperlinks without calling onHistoryChanged.

2008/11/27 alex.d <alex.du...@googlemail.com>

Litty Preeth

unread,
Nov 27, 2008, 10:54:47 PM11/27/08
to Google-We...@googlegroups.com
Thank you Danny and Alex for all those valuable tips.....
Reply all
Reply to author
Forward
0 new messages