Question on Link component...

Hi All,

I have created a Link component. My requirement is to write some event listener for the click event. If i click on the link i need to open a different view which may be an another layout component.

For example, i have a login view. In that i have a Link component called “Not Registered”. If i click on the link, i need to open a “New user” view.

How this is possible? Can any one help me on this?

Thanks,
Thamizharasu S

Hi!

I’ll asume that you know how to open different views and are just stumped with getting a listener attached to a Link component.

If you want to assign click listeners to a link, you are probably looking for the Button component with the Button.STYLE_LINK style. It’s used just like a normal button:

Button myButton = new Button("My very nice link");
myButton.setStyle(Button.STYLE_LINK);
myButton.addListener(new ClickListener() { .... });

HTH,
/Jonatan

Hi Jonatan,

Thanks for your answer. I will try your solution and update you.

Thanks,
Thamizharasu S

Hi,

Thanks for the hint. Now i am able to show the link using button with link style.

Thanks,
Thamizharasu S

If I wanted my link to contain an embedded image, how would I do this, assuming I use the Button with the specified style from above? I want the image to appear on the right hand side of the link.

How about something like this?

Button myButton = new Button("My very nice link");
myButton.setStyleName(Button.STYLE_LINK);
myButton.setIcon(new ThemeResource("../runo/icons/32/user.png"));

That’s what I have currently which results in an icon on the left. I want my icon to appear on the right.

Quick’n’dirty:

.v-button-link .v-icon {
    float: right;
}

Hope that helps, I just tried it with 16px icons, but should be doable with larger icons as well.