Hi Goran,

it looks like there's an easier way to use a RadioGroup. As the javadoc
states, "... The model object of the group is set to the model object of the
selected radio component or null if none selected". So you can just do the
following, for instance:

(a) WebPage class:

    private enum Option { CREATE, UPDATE };

(b) Form class:

        [...]
        private RadioGroup options;
        [...]

(c) Form constructor:

            [...]
            options = new RadioGroup("options", new Model());
            options.add(new Radio("create", new Model(Option.CREATE)));
            options.add(new Radio("update", new Model(Option.UPDATE)));
            add(options);
            [...]

(d) onSubmit() method:

            String option = options.getModelObjectAsString();
            if (option.equals(Option.CREATE)) {
                [...]
            } else { // UPDATE...
                [...]
            }

(e) HTML file:

    [...]
    <input type="radio" wicket:id="create">Create Document</input>
    <input type="radio" wicket:id="update">Update Document</input>
    [...]

Hope this helps,

Cristina



Goran Novak wrote:
> 
> Thanks,
> 
> I got it to work but I dont't understand why does RadioGroup has to have
> its own model. RadioGroup has a constructor "RadioGroup(java.lang.String
> id)", why does it exist if you can't create RadioGroup without its own
> model. It seems somewhat misleading.
> 
> Here is the solution if someone else encounters this problem:
> 
> [...]
> 

-- 
View this message in context: 
http://www.nabble.com/Radio-group%2C-model-tp16678100p19819311.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to