Quantcast

radiobuttons in DataView column

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

radiobuttons in DataView column

Dan12321
This post was updated on .
Hello,
I have got DataView and in one column are readiobuttons. I create list with items and one of them have got boolean=true. But in DataView on the page I cannot see checked radiobutton. Can you help me, how to use radiobuttons in DataView?
Thanks.

A have got list:
	books.add(new Book("name-1", genres.get(3), false));
		books.add(new Book("name-2", genres.get(1), false));
		books.add(new Book("name-3", genres.get(3), false));
		books.add(new Book("name-4", genres.get(0), true));
		books.add(new Book("name-5", genres.get(4), false));

and RadioGroup and DataView:
 
   	final RadioGroup radiogroup = new RadioGroup("radiogroup", Model.of(books));
    	
    	DataView<Book> table = new DataView<Book>("books", getBookDataProvider()) {
			
			@Override
			protected void populateItem(Item<Book> item) {
				
				item.add(new Label("name", Model.of(item.getModelObject().getName())));
				radiogroup.add(item.add(new Radio("selected", Model.of(item.getModelObject().isSelected()))));
				item.add(new DropDownChoice("genre", Model.of(item.getModelObject().getGenre()), genres, new ChoiceRenderer<String>(){
					@Override
					public Object getDisplayValue(String object) {
						return object;
					}
					
					@Override
					public String getIdValue(String object, int index) {
						return object;
					}
				}));
			}
		};
		
		radiogroup.add(table);
		add(radiogroup);
    }

and HTML:
<span wicket:id="radiogroup">
		
			<table>
				<tr wicket:id="books">
					<td><span wicket:id="name" /></td>
					<td><select wicket:id="genre" /></td>
					<td><input type="radio" wicket:id="selected" /></td>				
				</tr>
			</table>
		
		</span>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: radiobuttons in DataView column

Sven Meier
Take a look at RadioGroupPage from wicket-examples. It uses a ListView
but the principles are the same.

Hope this helps
Sven

On 06/16/2012 08:41 PM, Dan12321 wrote:

> Hello,
> I have got DataView and in one column are readiobuttons. I create list with
> items and one of them have got boolean=true. But in DataView on the page I
> cannot see checked radiobutton. Can you help me, hot to use radiobuttons in
> DataView?
> Thanks.
>
> A have got list:
>
>
> and RadioGroup and DataView:
>
>
> and HTML:
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/radiobuttons-in-DataView-column-tp4650018.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: radiobuttons in DataView column

Dan12321
Thanks. I look at this, I try my code little chage, but it still doesn't work and I cannot see what is wrong in my code.

When I come to page, one of radiobuttons should be selected. But no one is selected. I suppose, it could take value for radiobutton from model. But it does not take...
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: radiobuttons in DataView column

Sven Meier
Hi,

if you want to have one Radio preselected, you should have the
corresponding model object in the model of the radio group.

Sven

On 06/17/2012 06:48 AM, Dan12321 wrote:

> Thanks. I look at this, I try my code little chage, but it still doesn't work
> and I cannot see what is wrong in my code.
>
> When I come to page, one of radiobuttons should be selected. But no one is
> selected. I suppose, it could take value for radiobutton from model. But it
> does not take...
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/radiobuttons-in-DataView-column-tp4650018p4650020.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: radiobuttons in DataView column

Dan12321
Thanks for help. It works :)
Loading...