Hi,


On Mon, Jun 9, 2014 at 7:25 PM, kumar ramanathan <kumarramana...@gmail.com>
wrote:

> Hi Paul,
> Thanks So much i have succesfully displayed the data in table using
> repeating view.The code is shown below.
>
> HelloWorldApplication.java
>
> package com.lnn.app;
>
> import org.apache.wicket.Page;
> import org.apache.wicket.protocol.http.WebApplication;
>
> import com.lnn.page.HelloWorld;
>
> public class HelloWorldApplication extends WebApplication {
>
>         @Override
>         public Class<? extends Page> getHomePage() {
>                 // TODO Auto-generated method stub
>                 return HelloWorld.class;
>         }
>
> }
>
> HelloWorld.java
>
> package com.lnn.page;
>
> import java.util.ArrayList;
> import java.util.List;
>
> import org.apache.wicket.markup.html.WebPage;
> import org.apache.wicket.markup.html.basic.Label;
> import org.apache.wicket.markup.repeater.data.DataView;
> import java.io.Serializable;
> import java.util.ArrayList;
>
> import org.apache.wicket.markup.html.basic.Label;
> import org.apache.wicket.markup.html.link.Link;
> import org.apache.wicket.markup.html.navigation.paging.PagingNavigator;
> import org.apache.wicket.markup.repeater.Item;
> import org.apache.wicket.markup.repeater.RepeatingView;
> import org.apache.wicket.markup.repeater.data.DataView;
> import org.apache.wicket.markup.repeater.data.ListDataProvider;
> import org.apache.wicket.model.IModel;
> import org.apache.wicket.model.Model;
>
> public class HelloWorld extends WebPage {
> 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){
>  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);}}
>
>
> HelloWorld.html
>
>  <?xml version="1.0" encoding="UTF-8"?>
> <html xmlns="http://www.w3.org/1999/xhtml";
>    xmlns:wicket="http://wicket.apache.org";>
> <body>
> <table>
>     <tr><th>Name</th><th>Id</th> </tr>
>     <tr wicket:id="rows">
>     <td wicket:id="dataRow"></td>
>     </tr>
> </table>
> </body>
> </html>
>
> Persons.java
>
>
> package com.lnn.page;
> import java.io.Serializable;
>
> public class Persons implements Serializable{
> String name;
> String id;
>         public Persons(String name,String id){
>                 this.name=name;this.id=id;
>         }
>         public void setId(String id){
>                 this.id=id;
>         }
>         public String getId(){
>                 return this.id;
>         }
>         public void setName(String name){
>                 this.name=name;
>         }
>         public String getName(){
>                 return this.name;
>         }
>
> }
>
> O/P:
> Name Id
> sam     one
> ram     two
>
>
> In the above i have displayed the id a s lable. I want ot show it as
> link using the following change in the code of helloworld.java
> public class HelloWorld extends WebPage {
> 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){
>  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()){
>

Just use Link component instead of Label.

 repeatingView.add(new Link( repeatingView.newChildId()) {
                  public void onClick() {
                          setResponsePage(new Output(person.getId()));
                  }
          }.setBody(Model.of(person.getId())));
  item.add(repeatingView);

You can even optimize it by using BookmarkablePageLink and pass the person
id as a page parameter.

  }
> }; add(dataView);}}
>
> no link/data in the Id column displayed. Please help.How toget the
> link over there.
>
> O/P:
> Name Id
> Sam
> Ram
>
> Thanks,
> Kumar
>
> On 6/9/14, Paul Bors [via Apache Wicket]
> <ml-node+s1842946n4666157...@n4.nabble.com> wrote:
> >
> >
> > Have you tried one of the Repeaters from:
> > http://www.wicket-library.com/wicket-examples/index.html
> >
> > Direct link:
> > http://www.wicket-library.com/wicket-examples/repeater/
> >
> > They are also explained in the Wicket Free Guide at:
> > http://wicket.apache.org/guide/guide/single.html#repeaters
> >
> > Let us know if you have a more specific question.
> >
> >
> > On Fri, Jun 6, 2014 at 9:29 AM, kumar ramanathan <
> kumarramana...@gmail.com>
> > wrote:
> >
> >> Hi Friends,
> >> I am new beginner of wicket and trying to implement the table as below
> >> using
> >> data view.
> >>
> >> name     id
> >> sam      21(link)
> >> ram       16(link)
> >>
> >> once i click the id it show the sam/ram details in next page. I have
> >> tried
> >> many ways to implement it using  simple data view , but not able to do.
> >> Hoping you for help on this.
> >> I have tried cwiki examples, wicket library examples but those are very
> >> long
> >> to understand.Can you please share a simple project similar to my
> >> requirement above. Please help me, am struggling for nearly three months
> >> on
> >> this.
> >>
> >> Thanks,
> >> Kumar
> >>
> >> --
> >> View this message in context:
> >> http://apache-wicket.1842946.n4.nabble.com/Dataview-help-tp4666151.html
> >> Sent from the Users forum mailing list archive at Nabble.com.
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> >> For additional commands, e-mail: users-h...@wicket.apache.org
> >>
> >>
> >
> >
> > -----
> > ~ Thank you,
> >     p...@bors.ws
> > _______________________________________________
> > If you reply to this email, your message will be added to the discussion
> > below:
> >
> http://apache-wicket.1842946.n4.nabble.com/Dataview-help-tp4666151p4666157.html
> >
> > To unsubscribe from Dataview help, visit
> >
> http://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4666151&code=a3VtYXJyYW1hbmF0aGFAZ21haWwuY29tfDQ2NjYxNTF8LTQ2Njc1NzExMg==
>
>
> --
> with regards,
> Kumar R M
> Save the Earth.She will take care of you
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Dataview-help-tp4666151p4666161.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

Reply via email to