I want to create a list of radio buttons [I have that working] and an ajax event to fire whenever a radio button is clicked [I have this working]. If the radio button matches the one I am interested in then I want to display additional information that must be filled in. A radio button selection is required.
I cannot get the additional information to display when I add the component back to the target. I think it is because the additional information is originally set to not visible so the output markup id is not written out. How would I go about doing this? It seems pretty standard. Do I need to use panels and swap the appropriate panel [1 - empty panel, 2 - panel with additional info] into the target when needed? That seems like a lot of code to do something fairly simple. My code is below. Thanks. Jeff ===================== HTML: <tr> <td><wicket:message key="userType">Type of User:</wicket:message></td> <td> <span wicket:id="accountType"> <input type="radio" />option 1 </span> </td> </tr> <tr> <td></td> <td><span wicket:id="typeBox">The additional information</span></td> </tr> Java Code: // Account Type sub box final WebMarkupContainer typeBox = new WebMarkupContainer("typeBox"); typeBox.setVisible(false); typeBox.setOutputMarkupId(true); add(typeBox); // Account Type Select List accountTypes = accountTypeDao.findAll(); ChoiceRenderer accountTypeChoiceRenderer = new ChoiceRenderer("name", "code"); RadioChoice accountTypeRadio = new RadioChoice("accountType", accountTypes, accountTypeChoiceRenderer); //accountTypeRadio.setRequired(true); // THIS SHOULD REALLY BE REQUIRED // add the on click to the radio button accountTypeRadio.add(new AjaxFormChoiceComponentUpdatingBehavior () { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { RadioChoice choice = (RadioChoice) getComponent(); choice.updateModel(); if (((AccountType) choice.getModelObject()).getCode().equalsIgnoreCase("REP")) { typeBox.setVisible(true); } else { typeBox.setVisible(false); } target.addComponent(typeBox); } }); _______________________________________ Jeffrey A. Schneller Envisa End-to-End E-Commerce for the Multi-Channel Merchant 281 Pleasant Street Framingham, MA 01701 P: (508) 405-1220 x115 C: (508) 954-8044 F: (508) 405-1219