开发者

How to ClickLink through WicketTester when links have the same wicket:id?

开发者 https://www.devze.com 2023-04-04 12:23 出处:网络
On a Wicket page, I produce links with images via the following: @Override protected void populateItem(ListItem<Club> item)

On a Wicket page, I produce links with images via the following:

@Override
protected void populateItem(ListItem<Club> item) 
{
    .开发者_如何学Python..
    Image joinButton = new Image("joinButton", joinResource);
    BookmarkablePageLink<PageClubJoin> joinLink = 
        new BookmarkablePageLink<PageClubJoin>("joinLink", PageClubJoin.class);
    joinLink.setParameter("club", item.getModelObject().getId());
    joinLink.add(joinButton);
    item.add(joinLink);
    ...

The rendered html produces a series of

<a wicket:id="joinLink" ... />

elements.

Now, how do I use WicketTester to ClickLink on, say, the second one? They all have the same wicket:id.


You provide the full path to the component separated by colons:

tester.clickLink("listView:0:joinLink");

The first part is the list view component ID, the second the number of the item you want to select and the third part the link that you want to click. So if you want to click the link in the 99nth item in the list you would use:

tester.clickLink("listView:99:joinLink");
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号