Dear Forum,
I have added AjaxFormComponentUpdatingBehavior to a DropDownChoice to hide a
text field or to make it visible, according to the value selected from
DropDownChoice.

AjaxFormComponentUpdatingBehavior is hiding the text field, as expected, but
it is not making it visible when it should.
Surely, if it hides a form object, it should equally make it visible, should
it not?
Code:

public class HomePage extends WebPage {
        DropDownChoice<String> choice = new DropDownChoice<String>("choice", new
Model<String>(), Arrays.asList( new String[] { "A", "B", "C" } ));
        TextField<String> textField = new TextField<String>("textField", new
Model<String>());
        Form textDropDownAjaxForm = new Form("genericForm");
        
    public HomePage(final PageParameters parameters) {
        
        textDropDownAjaxForm.add(textField);
        textDropDownAjaxForm.add(choice);
        add(textDropDownAjaxForm);
        
        textField.setOutputMarkupId(true);
        choice.add(new AjaxFormComponentUpdatingBehavior("onchange") {
                protected void onUpdate(AjaxRequestTarget target) {
                        if ( choice.getModelObject() == "A" ){
                                *textField.setVisible(true);*
                        } else {
                                *textField.setVisible(false);*
                        }
                        *target.addComponent(textField);*
               }
        });
    }
}

and here is the HTML:
<body>
        <form wicket:id="genericForm">
            <select wicket:id="choice">
                <option>Choose one</option>
            </select>
            text field: <input wicket:id="textField" type="text" />
        </form>
    </body>

Thanks in advance for any help,
Lucas

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/AjaxFormComponentUpdatingBehavior-onchange-not-working-on-DropDownChoice-tp3674937p3674937.html
Sent from the Users forum mailing list archive at Nabble.com.

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

Reply via email to