You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Paolo <ir...@gmail.com> on 2011/04/07 04:15:10 UTC
How to know what RadioGroup was selected?
I implemented this example in my application
https://cwiki.apache.org/WICKET/using-radiogroups.html
But, how I can know what radio button of radiogroup the user selected?
This is a part of the html code:
--------------------------------
<span wicket:id="group">
<input wicket:id="1" type="radio"/>
<input wicket:id="2" type="radio"/>
<input wicket:id="3" type="radio"/>
<input wicket:id="4" type="radio"/>
</span>
This is a part of the java code:
--------------------------------
final Pagamento bean=new Pagamento();
RadioGroup myInt = new RadioGroup("group", new PropertyModel(bean, "myInt"));
myInt.add(new Radio("1", new Model(1)));
myInt.add(new Radio("2", new Model(2)));
myInt.add(new Radio("3", new Model(3)));
myInt.add(new Radio("4", new Model(4)));
form.add(myInt);
...
form.add(new Button("order") {
@Override
public void onSubmit() {
final String pagamentoSTR = bean.toString();
System.out.println ("Tipo pagamento:"+pagamentoSTR);
...
This is the java code for the class Pagamento:
----------------------------------------------
package org.wicket.example;
import java.io.Serializable;
public class Pagamento implements Serializable {
private Integer myInt;
public void setMyInt(Integer myInt) {
this.myInt=myInt;
}
public Integer getMyInt() {
return myInt;
}
}
I have no errors, but in the console i got:
Tipo pagamento:org.wicket.example.Pagamento@5bee9e20
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: How to know what RadioGroup was selected?
Posted by James Carman <ja...@carmanconsulting.com>.
On Wed, Apr 6, 2011 at 10:28 PM, Paolo <ir...@gmail.com> wrote:
> Great!! You was very fast to reply! And I solved my problem with:
>
> System.out.println ("Tipo pagamento:"+bean.getMyInt());
>
> Thank you very much!!!
>
No problem. That's what Wicket is all about, models. Your RadioGroup
"edits" the model you give it, which in your case was a property model
pointing to the "myInt" property on your bean. I would suggest you
check out the Wicket Wiki pages, especially:
https://cwiki.apache.org/WICKET/more-on-models.html
Enjoy and Happy Wicketeering!
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: How to know what RadioGroup was selected?
Posted by Paolo <ir...@gmail.com>.
Alle giovedì 07 aprile 2011, James Carman ha scritto:
> What is the value of "myInt"? That should tell you which one was selected.
>
> On Wed, Apr 6, 2011 at 10:15 PM, Paolo <ir...@gmail.com> wrote:
> > I implemented this example in my application
> >
> > https://cwiki.apache.org/WICKET/using-radiogroups.html
> >
> > But, how I can know what radio button of radiogroup the user selected?
> >
Great!! You was very fast to reply! And I solved my problem with:
System.out.println ("Tipo pagamento:"+bean.getMyInt());
Thank you very much!!!
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: How to know what RadioGroup was selected?
Posted by James Carman <ja...@carmanconsulting.com>.
What is the value of "myInt"? That should tell you which one was selected.
On Wed, Apr 6, 2011 at 10:15 PM, Paolo <ir...@gmail.com> wrote:
> I implemented this example in my application
>
> https://cwiki.apache.org/WICKET/using-radiogroups.html
>
> But, how I can know what radio button of radiogroup the user selected?
>
> This is a part of the html code:
> --------------------------------
> <span wicket:id="group">
> <input wicket:id="1" type="radio"/>
> <input wicket:id="2" type="radio"/>
> <input wicket:id="3" type="radio"/>
> <input wicket:id="4" type="radio"/>
> </span>
>
> This is a part of the java code:
> --------------------------------
>
> final Pagamento bean=new Pagamento();
> RadioGroup myInt = new RadioGroup("group", new PropertyModel(bean, "myInt"));
> myInt.add(new Radio("1", new Model(1)));
> myInt.add(new Radio("2", new Model(2)));
> myInt.add(new Radio("3", new Model(3)));
> myInt.add(new Radio("4", new Model(4)));
> form.add(myInt);
>
> ...
>
> form.add(new Button("order") {
> @Override
> public void onSubmit() {
>
> final String pagamentoSTR = bean.toString();
>
> System.out.println ("Tipo pagamento:"+pagamentoSTR);
> ...
>
> This is the java code for the class Pagamento:
> ----------------------------------------------
> package org.wicket.example;
>
> import java.io.Serializable;
>
> public class Pagamento implements Serializable {
> private Integer myInt;
> public void setMyInt(Integer myInt) {
> this.myInt=myInt;
> }
> public Integer getMyInt() {
> return myInt;
> }
>
> }
>
> I have no errors, but in the console i got:
> Tipo pagamento:org.wicket.example.Pagamento@5bee9e20
>
> ---------------------------------------------------------------------
> 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