all components need that after they have been submitted once. how is
component to know that you have updated its model object? have you
called component.modelchanged()? clearinput() will do the same as
that.

-igor

On Thu, Dec 30, 2010 at 6:46 AM, Ernesto Reinaldo Barreiro
<reier...@gmail.com> wrote:
> Igor,
>
> Thanks for your answer. Yes, I thought about that possibility but
> somehow it seems weird to me that you have to call clearinput() to get
> the component update its state based on the model value: in particular
> because other form components do not need that trick to work properly.
>  Would the override
>
>  public boolean isInputNullable() {
>        return false;
>  }
>
> have any other (undesirable) side effects? This "solution" has the
> advantage that I can roll out my own AjaxUpdatebleRadioGroup and thus
> I do not have remember to call clearinput() over and over.
>
> Regards,
>
> Ernesto
>
> On Thu, Dec 30, 2010 at 3:29 PM, Igor Vaynberg <igor.vaynb...@gmail.com> 
> wrote:
>> call clearinput() on the radiogroup so it refreshes based on new model
>> value you set.
>>
>> -igor
>>
>> On Thu, Dec 30, 2010 at 4:57 AM, Ernesto Reinaldo Barreiro
>> <reier...@gmail.com> wrote:
>>> I forgot to mentions this is with wicket 1.4.x.
>>>
>>> Ernesto
>>>
>>> On Thu, Dec 30, 2010 at 1:53 PM, Ernesto Reinaldo Barreiro
>>> <reier...@gmail.com> wrote:
>>>> Hi,
>>>>
>>>> Apologies for the somewhat lengthy e-mail.
>>>>
>>>> Consider the following situation
>>>>
>>>> 1-I have a form with a RadioGroup, several Radio buttons, an AJAX
>>>> submit button and some AJAX links that fetch "information" that can be
>>>> used to repaint the form and the RadioGroup.
>>>>
>>>> In simplified code more or less this.
>>>>
>>>> public class RadioPage extends WebPage  {
>>>>
>>>>        private static final long serialVersionUID = 1L;
>>>>
>>>>        private WebMarkupContainer context;
>>>>
>>>>        private Gender gender;
>>>>
>>>>        private FeedbackPanel feedbackPanel;
>>>>
>>>>        public RadioPage() {
>>>>              Form<Void> form = new Form<Void>("form");
>>>>              add(form);
>>>>              context = new WebMarkupContainer("context");
>>>>              context.setOutputMarkupId(true);
>>>>              form.add(context);
>>>>
>>>>
>>>>                RadioGroup<Gender> gender = new RadioGroup<Gender>("gender",
>>>>                                new PropertyModel<Gender>(this,"gender"));
>>>>
>>>>                gender.setRequired(true);
>>>>                context.add(gender);
>>>>                // hombre
>>>>                Radio<Gender> sexoH = new Radio<Gender>("male", new
>>>> Model<Gender>(Gender.MALE), gender);
>>>>                gender.add(sexoH);
>>>>
>>>>                Radio<Gender> sexoM = new Radio<Gender>("female", new
>>>> Model<Gender>(Gender.FEMALE), gender);
>>>>                gender.add(sexoM);
>>>>
>>>>                add(new AjaxLink<Void>("makeMale") {
>>>>
>>>>                        private static final long serialVersionUID = 1L;
>>>>
>>>>                       �...@override
>>>>                        public void onClick(AjaxRequestTarget target) {
>>>>                                RadioPage.this.gender = Gender.MALE;
>>>>                                if(target != null) {
>>>>                                        target.addComponent(context);
>>>>                                }
>>>>                        }
>>>>                });
>>>>
>>>>                add(new AjaxLink<Void>("makeFemale") {
>>>>
>>>>                        private static final long serialVersionUID = 1L;
>>>>
>>>>                       �...@override
>>>>                        public void onClick(AjaxRequestTarget target) {
>>>>                                RadioPage.this.gender = Gender.FEMALE;
>>>>                                if(target != null) {
>>>>                                        target.addComponent(context);
>>>>                                }
>>>>                        }
>>>>                });
>>>>
>>>>                form.add(new AjaxSubmitLink("submit") {
>>>>
>>>>                        private static final long serialVersionUID = 1L;
>>>>
>>>>                       �...@override
>>>>                        protected void onSubmit(AjaxRequestTarget target, 
>>>> Form<?> form) {
>>>>                                form.info("Gender was set to " + 
>>>> RadioPage.this.gender);
>>>>                                target.addComponent(feedbackPanel);
>>>>                        }
>>>>
>>>>                       �...@override
>>>>                        protected void onError(AjaxRequestTarget target, 
>>>> Form<?> form) {
>>>>                                target.addComponent(feedbackPanel);
>>>>                        }
>>>>                });
>>>>
>>>>                feedbackPanel = new FeedbackPanel("feedback");
>>>>                feedbackPanel.setOutputMarkupId(true);
>>>>                add(feedbackPanel);
>>>>    }
>>>>
>>>>        public Gender getGender() {
>>>>                return gender;
>>>>        }
>>>>
>>>>        public void setGender(Gender gender) {
>>>>                this.gender = gender;
>>>>        }
>>>> }
>>>>
>>>> -----------------RadioPage.html--------------
>>>>
>>>> <html 
>>>> xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd";>
>>>>    <head>
>>>>        <title>Test</title>
>>>>    </head>
>>>>    <body>
>>>>        <form wicket:id="form">
>>>>                <div wicket:id="context">
>>>>                        <span wicket:id="gender">
>>>>                                        <input type="radio" 
>>>> wicket:id="male"/>
>>>>                                        <label for="radio3">Male</label>
>>>>                                        <input type="radio" 
>>>> wicket:id="female"/>
>>>>                                        <label for="radio4">Female</label>
>>>>                                </span>
>>>>                        </div>
>>>>                        <input wicket:id="submit" type="submit" value="AJAX 
>>>> submit"/>
>>>>                </form>
>>>>                <span wicket:id="feedback"></span>
>>>>                <p>
>>>>                        Updating RadioGroup via AJAX does not work:
>>>>                        <a wicket:id="makeMale">Make male</a> and <a
>>>> wicket:id="makeFemale">Make female</a>.
>>>>                </p>
>>>>    </body>
>>>> </html>
>>>>
>>>> and
>>>>
>>>> public enum Gender {
>>>>        FEMALE,
>>>>        MALE;
>>>> }
>>>>
>>>>
>>>> 2-You click on the AJAX submit button without selecting any of the
>>>> radio buttons. This seems to set the rawinput of  RadioGroup to null.
>>>> 3-You click now on one of the AJAX links (Make male or Make female in
>>>> the example) in order to fetch the "information"  and repaint the form
>>>> via AJAX. But radios checked condition is not updated:-(
>>>>
>>>> This seems to be because of following code on Radio.onComponentTag():
>>>>
>>>>                // compare the model objects of the group and self, if
>>>> the same add the
>>>>                // checked attribute, first check if there was a raw input 
>>>> on the group.
>>>>                if (group.hasRawInput())
>>>>                {
>>>>                        String rawInput = group.getRawInput();
>>>>                        if (rawInput != null && rawInput.equals(value))
>>>>                        {
>>>>                                tag.put("checked", "checked");
>>>>                        }
>>>>                }
>>>>
>>>> If I rewrite my gender RadioGroup as
>>>>
>>>> RadioGroup<Gender> gender = new RadioGroup<Gender>("gender",
>>>>                                new PropertyModel<Gender>(this,"gender")) {
>>>>
>>>>                        private static final long serialVersionUID = 1L;
>>>>
>>>>                       �...@override
>>>>                        public boolean isInputNullable() {
>>>>                                return false;
>>>>                        }
>>>>                };
>>>>
>>>> "everything" seems to be working fine. Am I missing some important
>>>> point on how to use radio groups or  is this a bug? Shall I file a
>>>> jira issue for this?
>>>>
>>>> Thanks in advance,
>>>>
>>>> Ernesto
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>>> For additional commands, e-mail: users-h...@wicket.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> For additional commands, e-mail: users-h...@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

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

Reply via email to