How to set the URL on the LinkItem

Hello,
I could not figure out how to set the URL on the LinkItem.
By default it takes the current application URL and substitutes the Application name with the value of the LinkItem. How do i set it to a different value - say www.google.com?
I need the link to be part of the DynamicForm.

Thank you

LinkItem.setTarget

Hello,

afaik setTarget is just to specify if the link has to be displayed in a new window or not (same as the target property of a usual href link

I have the same question than smarter : may we have an example showing how to set the link of a LinkItem ?

Thank you

Respect

I’m not sure I follow. You could add a click handler to a LinkItem and add whatever logic you need in there.

you’re right.
But even with a clickHandler on the LinkItem, clicking on it will also open a new window or mess the current window (depending of the target defined, _self, _parent, etc.)
So we would like to know of we can by pass that behavior to just have our clickHandler handles all the treatment when clicking on the link.

Regards

This should be the behavior you see. Just don’t set setTarget(..) and handle all the logic in your listener.

No it’s not working at all : the clickHandler is not working at all for a LinkItem.
Moreover, even with a clickHandler set for a LinkItem, a click on this link stil opens a new window (due to the fact that the default target value is “_blank”

So I think that this is a bug (I tried the last build to make sure)

Respect

This works for me :

    public void onModuleLoad() {
        DynamicForm form = new DynamicForm();

        LinkItem link = new LinkItem("link");
        link.setLinkTitle("Click Me");
        link.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                SC.say("Hello World");
            }
        });
        link.setShowTitle(false);

        form.setItems(link);
        form.draw();
    }

Sanjiv

Hello Sanjiv,

I don’t understand how it can work for you :

by trying the exact same code sample you gave I don’t have the Hello window that opens but a blank new window with javascript:void() as URL (it is not a SC window but a classic browser one).

Can somebody else try the code sample and let us know ?

PS : I have tried with the latest build (304)

Regards

Which OS are you on? I tried this on OSX Safari and FF 3. Did you try web mode as well?

Sanjiv

Hello Sanjiv,

I have tried on Vista and Windows XP.
On FF3, IE, Chrome (on this one no new windo opens, nothing happens in fact) and hosted mode on both OS without being able to have the correct behavior.

Regards

Thanks, I’ll look into it.

Fixed in SVN.

Thanks,
Sanjiv

thank you sanjiv it’s working correctly now :wink:

Regards

Hi,

I treid with the latest build, still its not working. When I click on the link its opening a page with current application URL. Please help me to fix this problem.

Which build are you using? Did you ever get it working? You can find a working sample in this showcase example.

If you’re still having problems, please post a standalone test.

Sanjiv

Hi,
I have problem with LinkItem. A click on this link opens a new browser’s window.

    public void onModuleLoad() { 
        Window w = new Window();

        DynamicForm form = new DynamicForm();

        LinkItem link = new LinkItem("link");
        link.setLinkTitle("Click Me");
        link.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() {  
           @Override
           public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) {
                SC.say("Hello World");  
				
           }  
        });
        link.setShowTitle(false);

        form.setItems(link);

        final Button sendButton = new Button("Send");
        sendButton.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent event) {
			SC.say("Do send"); 
		}
         });        

        w.addItem(form);
        w.addItem(sendButton);
        w.draw();

    }

The link doesn’t open new browser’s window if I don’t use ClickHandler for button. I think problem in different ClickHandler classes.
PS. Resolved.