You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by jnorris <j....@snet.net> on 2008/06/20 21:25:45 UTC

help with RadioGroup in Table

Hi All,

I have a requirement for a radio button column in a data table.  When a row
is selected data from one of the columns needs to be placed in a text box on
the form.  The problem is how to get the selected row to update the text
box.  I've searched the forums and googled and haven't found a solution that
I can get to work.  The radio buttons themselves work fine until I try to
use an event such as onSelectionChanged which then causes the selection to
be lost which has been discussed in other posts.  I've read in another
similar post that using an ajax behavior is a way to deal with the issue but
I haven't been able to figure out how to do that.  I'm also struggling to
get my head around the correct way to use models for the radio's.  The class
in the model passed in when creating the RadioPanel containing the Radio has
a "selected" property that I've been trying to use for the value of the
radio.

I can get a solution to work using checkboxes but the requirement is
specifically for radio buttons in order to be compatible with the existing
JSP pages in the application.  BTW, if I can pull this off there is a good
chance future application features will be implemented in Wicket with the
idea of eventually migrating the entire application to wicket.

If anyone has got something like this working I'd really appreciate some
direction.  

Code snippets:

The following code is in addComponents() called from constructor:

		final RadioGroup selected = new RadioGroup( "selected" )
//		{
//			@Override
//			protected void onSelectionChanged( Object newSelection )
//			{
//				super.onSelectionChanged( newSelection );	// newSelection is always
null
//			}
//			@Override
//			protected boolean wantOnSelectionChangedNotifications()
//			{
//				return true;
//			}
//		}
		;

		columns.add( new AbstractColumn( new Model( "" )) 
		{
			public void populateItem( final Item cellItem, final String componentId,
final IModel rowModel ) 
			{
				cellItem.add( new RadioPanel( componentId, rowModel ));
			}
		});
		AjaxFallbackDefaultDataTable table = new AjaxFallbackDefaultDataTable(
"table", columns, provider, 15 );

		selected.add( table );
		this.add( selected );

The panel with the Radio:

	private class RadioPanel extends Panel 	
	{
		public RadioPanel( String id, IModel model ) 
		{
			super( id, model );
			add( new Radio( "select", new PropertyModel( model, "selected" )));
		}
	} 

The html for the panel:

	<wicket:panel>
		<input wicket:id="select" type="radio"/>
	</wicket:panel>

The html for the radio group and table:

	<div wicket:id="selected">
		<table wicket:id="table"></table>
	</div>


Thanks in advance,
Jim
-- 
View this message in context: http://www.nabble.com/help-with-RadioGroup-in-Table-tp18036005p18036005.html
Sent from the Wicket - User 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: help with RadioGroup in Table

Posted by jnorris <j....@snet.net>.
Hi Thomas,

Using the row model worked.  I changed the value of the text box with data
from the domain object in the row model, and set that as the target and
bingo!

Thank you for your help.

Jim
-- 
View this message in context: http://www.nabble.com/help-with-RadioGroup-in-Table-tp18036005p18112563.html
Sent from the Wicket - User 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: help with RadioGroup in Table

Posted by Thomas Mäder <to...@gmail.com>.
> new Radio( "select", new PropertyModel( model, "selected" ))

you're setting the model of the Radio to the "selected" property of whatever
is in the row model. What is in the row model? Have you tried just passing
in the row model?

Thomas

On Tue, Jun 24, 2008 at 1:59 PM, jnorris <j....@snet.net> wrote:

>
> This problem is a real show-stopper for me so I really need some help if
> anyone has done something similiar.  I added
> AjaxFormChoiceComponentUpdatingBehavior to the RadioGroup as mentioned in
> another post and it hits onUpdate every time a radio button is selected.
> However, I can't figure out 1) how to get the selected row item's data
> object from the table and 2) what component to add to the AjaxRequestTarget
> (tried the radio group but it throws an exception).
>
> BTW, I gave a prezo to my group a couple of weeks ago and there was some
> real interest in migrating to wicket in place of our bloated legacy system,
> providing I can finish off this proof of concept that I'm working on.
>  There
> is also some pressure here to do a complete re-design in asp.net so I'm
> really hoping to provide an alternative to doing that.  If I can't get the
> radio group in the table working soon I'll have to abandon the wicket
> approach.  So, any hints, help, url's to examples, etc. will be greatly
> appreciated.
>
> Thanks,
> Jim
> --
> View this message in context:
> http://www.nabble.com/help-with-RadioGroup-in-Table-tp18036005p18089479.html
> Sent from the Wicket - User 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: help with RadioGroup in Table

Posted by Igor Vaynberg <ig...@gmail.com>.
create a quickstart and post it somewhere. its hard for anyone to wave
their dead chicken in front of the screen.

-igor

On Tue, Jun 24, 2008 at 4:59 AM, jnorris <j....@snet.net> wrote:
>
> This problem is a real show-stopper for me so I really need some help if
> anyone has done something similiar.  I added
> AjaxFormChoiceComponentUpdatingBehavior to the RadioGroup as mentioned in
> another post and it hits onUpdate every time a radio button is selected.
> However, I can't figure out 1) how to get the selected row item's data
> object from the table and 2) what component to add to the AjaxRequestTarget
> (tried the radio group but it throws an exception).
>
> BTW, I gave a prezo to my group a couple of weeks ago and there was some
> real interest in migrating to wicket in place of our bloated legacy system,
> providing I can finish off this proof of concept that I'm working on.  There
> is also some pressure here to do a complete re-design in asp.net so I'm
> really hoping to provide an alternative to doing that.  If I can't get the
> radio group in the table working soon I'll have to abandon the wicket
> approach.  So, any hints, help, url's to examples, etc. will be greatly
> appreciated.
>
> Thanks,
> Jim
> --
> View this message in context: http://www.nabble.com/help-with-RadioGroup-in-Table-tp18036005p18089479.html
> Sent from the Wicket - User 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: help with RadioGroup in Table

Posted by jnorris <j....@snet.net>.
This problem is a real show-stopper for me so I really need some help if
anyone has done something similiar.  I added
AjaxFormChoiceComponentUpdatingBehavior to the RadioGroup as mentioned in
another post and it hits onUpdate every time a radio button is selected. 
However, I can't figure out 1) how to get the selected row item's data
object from the table and 2) what component to add to the AjaxRequestTarget
(tried the radio group but it throws an exception).

BTW, I gave a prezo to my group a couple of weeks ago and there was some
real interest in migrating to wicket in place of our bloated legacy system,
providing I can finish off this proof of concept that I'm working on.  There
is also some pressure here to do a complete re-design in asp.net so I'm
really hoping to provide an alternative to doing that.  If I can't get the
radio group in the table working soon I'll have to abandon the wicket
approach.  So, any hints, help, url's to examples, etc. will be greatly
appreciated.

Thanks,
Jim
-- 
View this message in context: http://www.nabble.com/help-with-RadioGroup-in-Table-tp18036005p18089479.html
Sent from the Wicket - User 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