You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by shumbola <sh...@yahoo.com> on 2007/08/13 10:25:10 UTC

Radio problem

Hello all,

Basically I've got a form like this:
<form>
<table>
  <tr>
     <td><input type="radio" name="rtype" value="1"
checked="true">Type1</input><td>
  <tr>
  </tr>
     <td><input type="text" name="input1"></td>
  </tr>
  <tr>
     <td><input type="radio" name="rtype" value="2">Type2</input><td>
  <tr>
  </tr>
     <td><input type="text" name="input2"></td>
  </tr>
  <tr>
     <td> <input type="submit"> </td>
  </tr>
<table>
<form>

If user chooses first radio button, he/she fills the input1, otherwise fills
input2
How I can code this in wicket side? If radio buttons were in the same place,
I'd use RadioChoice and render these two with a model, e.g., List having two
types {"type1", "type2"}. But I've got input field in between those radio
buttons. In general there maybe more form components then just one
textfield.
If I use RadioGroup, then having problem with my Model. Appreciate if
someone show me the right way with a sample code.

Thanks,
shumbola

-- 
View this message in context: http://www.nabble.com/Radio-problem-tf4259849.html#a12122607
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: Radio problem

Posted by Gabor Szokoli <sz...@gmail.com>.
Hi!

On 8/13/07, shumbola <sh...@yahoo.com> wrote:
> If I use RadioGroup, then having problem with my Model. Appreciate if
> someone show me the right way with a sample code.

We use RadioGroup for something similar and it works fine.
The form has a CompoundPropertyModel with attributes including
"radioGroup", "panel0", "panel1", which the subcomponents can find
even when they are nested into each other.
Here's a simplified example:

<span wicket:id="radioGroup">
					<tr>
						<td wicket:id="panel0"> </td>
						<td> <input wicket:id="0" type="radio"> </td>
					</tr>
				
					<tr>
						<td wicket:id="panel1"> </td>
						<td> <input wicket:id="1" type="radio"> </td>
					</tr>
			    </span>	

form constructor:

			RadioGroup radioGroup = new RadioGroup("radioGroup");

			Panel panel0 = new Panel("panel0");
			Radio choice0 = new Radio("0", new Model(new Integer(0)));
			radioGroup.add(panel0);
			radioGroup.add(choice0);

			Panel panel1 = new Panel("panel1");
			Radio choice1 = new Radio("1", new Model(new Integer(1)));
			radioGroup.add(panel1);
			radioGroup.add(choice1);

			form.add(radioGroup);

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