the model of each radio returns the object that you want put into the model of the radiogroup so the type of both models is the same

new RadioGroup("foo", new PropertyModel<Person>(this, "person"));
new Radio("bar", new Model(new Person(...)));

so if you want the value to be preselected you have to put the right object inside the model of the radiogroup

-Igor


On 7/17/06, Stefan Lindner <[EMAIL PROTECTED]> wrote:
Hi all,

What ist he correct type for a radio button property model?

I want to use RadioButtons with AJAX. I have found a hint in the mailing
list archive that I have to use RadioGroup and add an ajax event to each
Radio Object in the radio group. This works.
But now: when I want one of the radio buttons to be preselected I need
to bind a model to the radio button.
Let's assume that I have HTML like this

         <form wicket:id="form">
                <span wicket:id="group">
                        <table style="border: 2px dotted #fc0; width:
400px; padding: 5px;">
                         <tr>
                          <td valign="top">Select a person</td>
                          <td>
                                  <table cellspacing="0"
cellpadding="2">
                                        <tr><td wicket:id="persons">
                                                <input type="radio"
wicket:id="radio"/>
                                                <span
wicket:id="name">[this is where name will be]</span></td>
                                        </tr>
                                  </table>
                                  <span valign="top">
                                  </span>
                          </td>
        ...

The java part looks like this


                        final RadioGroup group = new
RadioGroup("group");
                        Form form = new Form("form");

                        add(form);
                        form.add(group);

                        ListView persons = new ListView("persons",
getPersons()) {

                                protected void populateItem(ListItem
item) {
                                        Radio r = new Radio("radio",
item.getModel());

                                        r.add(new
AjaxEventBehavior("onchange") {
                                       protected void
onEvent(AjaxRequestTarget target) {
                                       System.out.println("----------" +
getComponent().getModelObject().toString);
                                    }
                                 });



                                        item.add(r);
                                        item.add(new Label("name", new
PropertyModel(item.getModel(), "name")));

                                }

                        };

                        group.add(persons);


This works well in one way: I can receive the AJAX event when a radio
button is selectd.
But now I want to have one radio buttln preselect when I display the
panel.

When I try to add a PropertyModel to the radio button

        Radio r = new Radio("radio", new PropertyModel(item.getModel(),
"radio")    );

I can see calls to getRadio in my ModelClass when the components are
rendered the first time. But when I klick into a radio butteln a class
cast Exception is thrown. I tried a boolean, a Boolean and a String as
type for the radio button but alway a class cast exception is thrown.
Now once again the question: What ist he correct type for a radio button
property model and what ist he default value to have one radio button
selected.



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to