You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by kumar ramanathan <ku...@gmail.com> on 2014/06/10 18:02:38 UTC

Link in repeaters

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


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Link-in-repeaters-tp4666176.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Link in repeaters

Posted by Paul Bors <pa...@bors.ws>.
You need to wrap a the Anchor around a Label and you can do so either in a fragment or your own LablledLinkPanel…

On Jun 10, 2014, at 2:01 PM, Sven Meier <sv...@meiers.net> wrote:

> Hi,
> 
> a link does not output a label. Read here for two possible solutions:
> 
> https://www.mail-archive.com/wicket-user@lists.sourceforge.net/msg28621.html
> 
> Regards
> Sven
> 
> On 06/10/2014 06:02 PM, kumar ramanathan wrote:
>> 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
>> 
>> 
>> --
>> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Link-in-repeaters-tp4666176.html
>> Sent from the Users forum mailing list archive at Nabble.com.
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Link in repeaters

Posted by Sven Meier <sv...@meiers.net>.
Hi,

a link does not output a label. Read here for two possible solutions:

https://www.mail-archive.com/wicket-user@lists.sourceforge.net/msg28621.html

Regards
Sven

On 06/10/2014 06:02 PM, kumar ramanathan wrote:
> 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
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Link-in-repeaters-tp4666176.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Link in repeaters

Posted by Mihir Chhaya <mi...@gmail.com>.
Would simple String concatenation not work here for you?

-Mihir.


On Tue, Jun 10, 2014 at 12:02 PM, kumar ramanathan <kumarramanatha@gmail.com
> wrote:

> 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
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Link-in-repeaters-tp4666176.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>