Quantcast
Channel: Apache Timeline
Viewing all articles
Browse latest Browse all 5648

Link in repeaters

$
0
0
Hi Friends ,
I have successfully generated the view using repeaters using the following
code.

HTML:
<body>

Name Id

</body>

HelloWorld.java
public HelloWorld(){
List<Persons> list = new ArrayList<Persons>();
list.add(new Persons("sam","one"));
list.add(new Persons("ram","two"));
ListDataProvider<Persons> listDataProvider = new
ListDataProvider<Persons>(list);
DataView<Persons> dataView = new DataView<Persons>("rows",
listDataProvider) {
@Override protected void populateItem(Item<Persons> item)

Persons person = item.getModelObject();
RepeatingView repeatingView = new RepeatingView("dataRow");
repeatingView.add(new Label(repeatingView.newChildId(),
person.getName()));
repeatingView.add(new Label(
repeatingView.newChildId(),person.getId()));
item.add(repeatingView);

};
add(dataView);

Ouput I got :

Name Id
sam one(not link)
ram two(not link)

Now I have tried to display the above ouput as below with link

Name Id
sam one(link)
ram two(link)

For this ouput i have altered the code in helloword.java as below

DataView<Persons> dataView = new DataView<Persons>("rows",
listDataProvider){
protected void populateItem(Item<Persons> item){
Persons person = item.getModelObject();
RepeatingView repeatingView = new RepeatingView("dataRow");
repeatingView.add(new Label(repeatingView.newChildId(),
person.getName()));
repeatingView.add(new Link(person.getId()){
public void onClick(){
setResponsePage(Output.class);

});
item.add(repeatingView);

}; add(dataView);}}

Output I got for the above code change is

Name Id
sam
ram

No Id value is displayed.

I need your help on making code changes to display the id as link. Kindly
help me what are the things i need to update.
Thanks,
Kumar

Viewing all articles
Browse latest Browse all 5648

Trending Articles