2012-07-11 81 views
0

在java类中,我需要向wicket中的Label添加列表(例如list.getFirstName()),并且第一个名称是html中的超链接。下面我有Java和HTML html代码的代码如何在wickets中添加链接

<tr > 
      <a wicket:id="gotoClass"> 
        <span wicket:id="firstname"></span> 
     </a> 
</tr> 

的Java类

Iterator<String> brds = list.iterator(); 

RepeatingView repeating = new RepeatingView("repeating"); 
    add(repeating); 

     while (brds.hasNext()) 
     { 
    AbstractItem item = new AbstractItem(repeating.newChildId()); 
        repeating.add(item); 
        String contact = brds.next(); 
       item.add(new Label("firstname", contact)); 


    } 

上面的代码对我的作品和我能够添加标签,也就是说,如果我有10个名字在列表中,我能够在html.But添加10个标签,我尝试添加在HTML锚标记和

form.add(new BookmarkablePageLink<String>("firstname", gotoClass.class));在Java

然后我得到以下异常

最后一个原因:无法在[[Component id = formname]]中找到ID为'firstname'的组件 预期:'formname.firstname'。 具有类似名称的发现:“”

任何人可以帮助我这个

问候 沙拉斯

回答

0

链接元素必须是重复元素的儿子(像你一样先)。例如:

//... 
BookmarkablePageLink<String> link = new BookmarkablePageLink<String>("firstname", gotoClass.class); 
item.add(link); 

link.add(new Label("firstname", contact));