Re: Label update after change of radiochoice by ajax not working
I've added a jira-issue (https://issues.apache.org/jira/browse/WICKET-2806) for this. Cheers Per - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Label update after change of radiochoice by ajax not working
Hi *, i have a courious situation here. My TestHomePanel is running green, but in browser the label is not updated. If i remove the css-class from the choices it works as expected. It seems that the lookup of the radios in the group is not working. But i don't find the place in code to check. Is someone seeing the cause or knows where the radios in the group will be handled? Cheers Per HomePanel.java import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.form.AjaxFormChoiceComponentUpdatingBehavior; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.markup.html.form.Radio; import org.apache.wicket.markup.html.form.RadioGroup; import org.apache.wicket.markup.html.panel.Panel; import org.apache.wicket.model.IModel; import org.apache.wicket.model.Model; public class HomePanel extends Panel { public HomePanel(String id) { super(id); FormVoid f = new FormVoid(form); add(f); IModelByte groupModel = new ModelByte(Byte.valueOf(1)); final RadioGroupByte g = new RadioGroupByte(rgroup, groupModel); f.add(g); g.add(new AjaxFormChoiceComponentUpdatingBehavior() { @Override protected void onUpdate(AjaxRequestTarget target) { target.addComponent(HomePanel.this); } }); g.add(new RadioByte(r1, new ModelByte(Byte.valueOf(1; g.add(new RadioByte(r2, new ModelByte(Byte.valueOf(2; Label l = new Label(result, groupModel); f.add(l); } } HomePanel.html html xmlns:wicket wicket:panel form wicket:id=form span wicket:id=result[Text]/span span wicket:id=rgroup input type=radio wicket:id=r1 class=abc input type=radio wicket:id=r2 class=abc /span /form /wicket:panel /html TestHomePanel.java import junit.framework.TestCase; import org.apache.wicket.util.tester.FormTester; import org.apache.wicket.util.tester.WicketTester; /** * Simple test using the WicketTester */ public class TestHomePanel extends TestCase { private WicketTester tester; @Override public void setUp() { tester = new WicketTester(new WicketApplication()); } public void testWorks() { tester.startPanel(HomePanel.class); assertChangedLabelOnClick(); } private void assertChangedLabelOnClick() { tester.assertLabel(panel:form:result, 1); FormTester f = tester.newFormTester(panel:form); f.select(rgroup, 1); f.submit(); tester.assertLabel(panel:form:result, 2); } } -- Sicherer, schneller und einfacher. Die aktuellen Internet-Browser - jetzt kostenlos herunterladen! http://portal.gmx.net/de/go/chbrowser - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: RadioChoice and Ajax to display a panel of dropdowns
Hey Jeff, did you override this? /** * Override this method if you want onBeforeRender to be called even when your component is not * visible. default this returns false. * * @return boolean, if true then onBeforeRender is called even for none visible components, * default false. * * @see Component#onBeforeRender() */ protected boolean callOnBeforeRenderIfNotVisible() { return false; } If you add a visible and an invisible panel you have to override this on the invisible one. hth Cheers Per 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 tdwicket:message key=userTypeType of User:/wicket:message/td td span wicket:id=accountType input type=radio /option 1 /span /td /tr tr td/td tdspan wicket:id=typeBoxThe 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 - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
RE: RadioChoice and Ajax to display a panel of dropdowns
I did not override the method.I just did and it is still not working. Here is what I have: Also, where would one find this type of information. I don't think the online example show it and blindly guessing methods to look at in javadoc doesn't seem efficient. HTML: tr tdwicket:message key=userTypeType of User:/wicket:message/td td span wicket:id=accountType input type=radio /option 1 /span /td /tr tr td/td tdspan wicket:id=typeBoxThe type box/span/td /tr Code: // Account Type sub box final WebMarkupContainer typeBox = new WebMarkupContainer(typeBox) { /* (non-Javadoc) * @see org.apache.wicket.Component#callOnBeforeRenderIfNotVisible() */ @Override protected boolean callOnBeforeRenderIfNotVisible() { return true; } }; 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); // 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); } }); add(accountTypeRadio); -Original Message- From: Per Newgro [mailto:per.new...@gmx.ch] Sent: Wednesday, September 30, 2009 2:17 AM To: users@wicket.apache.org Subject: Re: RadioChoice and Ajax to display a panel of dropdowns Hey Jeff, did you override this? /** * Override this method if you want onBeforeRender to be called even when your component is not * visible. default this returns false. * * @return boolean, if true then onBeforeRender is called even for none visible components, * default false. * * @see Component#onBeforeRender() */ protected boolean callOnBeforeRenderIfNotVisible() { return false; } If you add a visible and an invisible panel you have to override this on the invisible one. hth Cheers Per 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 tdwicket:message key=userTypeType of User:/wicket:message/td td span wicket:id=accountType input type=radio /option 1 /span /td /tr tr td/td tdspan wicket:id=typeBoxThe
Re: RadioChoice and Ajax to display a panel of dropdowns
Only a shot in the dark, but is typeBox.setOutputMarkupPlaceholderTag(true) helping? You could use it instead of setOutputMarkupId(true), because its done there to. Otherwise i would have to create a testcase for this situation. There are different places to get informations: - search this list - read the wiki - check the examples - read a wicket book (many good out there) It's all explained on the website. Or do you expect them elsewhere? Cheers Per I did not override the method.I just did and it is still not working. Here is what I have: Also, where would one find this type of information. I don't think the online example show it and blindly guessing methods to look at in javadoc doesn't seem efficient. HTML: tr tdwicket:message key=userTypeType of User:/wicket:message/td td span wicket:id=accountType input type=radio /option 1 /span /td /tr tr td/td tdspan wicket:id=typeBoxThe type box/span/td /tr Code: // Account Type sub box final WebMarkupContainer typeBox = new WebMarkupContainer(typeBox) { /* (non-Javadoc) * @see org.apache.wicket.Component#callOnBeforeRenderIfNotVisible() */ @Override protected boolean callOnBeforeRenderIfNotVisible() { return true; } }; 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); // 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); } }); add(accountTypeRadio); -Original Message- From: Per Newgro [mailto:per.new...@gmx.ch] Sent: Wednesday, September 30, 2009 2:17 AM To: users@wicket.apache.org Subject: Re: RadioChoice and Ajax to display a panel of dropdowns Hey Jeff, did you override this? /** * Override this method if you want onBeforeRender to be called even when your component is not * visible. default this returns false. * * @return boolean, if true then onBeforeRender is called even for none visible components, * default false. * * @see Component#onBeforeRender() */ protected boolean callOnBeforeRenderIfNotVisible() { return false; } If you add a visible and an invisible panel you have to override this on the invisible one. hth Cheers Per 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
RE: RadioChoice and Ajax to display a panel of dropdowns
Adding the call to that method seemed to solve the problem. The places you mentioned are the usual places to look for information. However I searched the list, read the wiki, checked the examples, and looked through some books. I also tried to google what I was trying to do. It just seemed like this was a pretty common thing to do and I would have thought an answer would have been found much quicker. Do you recommend any books in particular. I have Wicket in Action and have ordered Pro Wicket. Are there other books that I should be looking at? Thanks. Jeff -Original Message- From: Per Newgro [mailto:per.new...@gmx.ch] Sent: Wednesday, September 30, 2009 2:09 PM To: users@wicket.apache.org Subject: Re: RadioChoice and Ajax to display a panel of dropdowns Only a shot in the dark, but is typeBox.setOutputMarkupPlaceholderTag(true) helping? You could use it instead of setOutputMarkupId(true), because its done there to. Otherwise i would have to create a testcase for this situation. There are different places to get informations: - search this list - read the wiki - check the examples - read a wicket book (many good out there) It's all explained on the website. Or do you expect them elsewhere? Cheers Per I did not override the method.I just did and it is still not working. Here is what I have: Also, where would one find this type of information. I don't think the online example show it and blindly guessing methods to look at in javadoc doesn't seem efficient. HTML: tr tdwicket:message key=userTypeType of User:/wicket:message/td td span wicket:id=accountType input type=radio /option 1 /span /td /tr tr td/td tdspan wicket:id=typeBoxThe type box/span/td /tr Code: // Account Type sub box final WebMarkupContainer typeBox = new WebMarkupContainer(typeBox) { /* (non-Javadoc) * @see org.apache.wicket.Component#callOnBeforeRenderIfNotVisible() */ @Override protected boolean callOnBeforeRenderIfNotVisible() { return true; } }; 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); // 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); } }); add(accountTypeRadio); -Original Message- From: Per Newgro [mailto:per.new...@gmx.ch] Sent: Wednesday, September 30, 2009 2:17 AM To: users@wicket.apache.org Subject: Re: RadioChoice and Ajax to display a panel of dropdowns Hey Jeff, did you override this? /** * Override this method if you want onBeforeRender to be called even when your component is not * visible. default this returns false. * * @return boolean, if true then onBeforeRender is called even for none visible components, * default false. * * @see Component#onBeforeRender() */ protected boolean callOnBeforeRenderIfNotVisible() { return false; } If you add a visible and an invisible panel you have to override this on the invisible one. hth Cheers Per I want to create a list of radio buttons [I have that working] and an ajax event to fire
Re: RadioChoice and Ajax to display a panel of dropdowns
The books you mentioned are the places to look at. If i google wicket component not visible the third entry brings up the solution. And in the list this question was answered quite often. But it surely depends on search phrase. But now it's answered again. At least here you will get almost ever an answer. Cheers Per Adding the call to that method seemed to solve the problem. The places you mentioned are the usual places to look for information. However I searched the list, read the wiki, checked the examples, and looked through some books. I also tried to google what I was trying to do. It just seemed like this was a pretty common thing to do and I would have thought an answer would have been found much quicker. Do you recommend any books in particular. I have Wicket in Action and have ordered Pro Wicket. Are there other books that I should be looking at? Thanks. Jeff - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
RadioChoice and Ajax to display a panel of dropdowns
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 tdwicket:message key=userTypeType of User:/wicket:message/td td span wicket:id=accountType input type=radio /option 1 /span /td /tr tr td/td tdspan wicket:id=typeBoxThe 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
Re: RadioChoice with Ajax
it works, thank you very much!! Michael Sparer wrote: just a guess: from the AjaxFormComopnentUpdatingBehavior's javadoc: NOTE: This behavior does not work on Choices or Groups use the AjaxFormChoiceComponentUpdatingBehavior for that. regards, Michael radovan wrote: Hallo, I have this code: private static final ListString Orders = Arrays.asList(new String[] { asc, desc }); private final IModelString model = new ModelString(Orders.get(0)); RadioChoice radioChoice = new RadioChoice(orders, model, Orders); radioChoice.add(new AjaxFormComponentUpdatingBehavior(onchange) { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { System.out.println(model); } }); I expected, that model contains selected choice, but this print null. How I can get value of selected choice? - with Ajax (no submit button) -- View this message in context: http://www.nabble.com/RadioChoice-with-Ajax-tp19855494p19856526.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]
RadioChoice with Ajax
Hallo, I have this code: private static final ListString Orders = Arrays.asList(new String[] { asc, desc }); private final IModelString model = new ModelString(Orders.get(0)); RadioChoice radioChoice = new RadioChoice(orders, model, Orders); radioChoice.add(new AjaxFormComponentUpdatingBehavior(onchange) { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { System.out.println(model); } }); I expected, that model contains selected choice, but this print null. How I can get value of selected choice? - with Ajax (no submit button) -- View this message in context: http://www.nabble.com/RadioChoice-with-Ajax-tp19855494p19855494.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]
Re: RadioChoice with Ajax
just a guess: from the AjaxFormComopnentUpdatingBehavior's javadoc: NOTE: This behavior does not work on Choices or Groups use the AjaxFormChoiceComponentUpdatingBehavior for that. regards, Michael radovan wrote: Hallo, I have this code: private static final ListString Orders = Arrays.asList(new String[] { asc, desc }); private final IModelString model = new ModelString(Orders.get(0)); RadioChoice radioChoice = new RadioChoice(orders, model, Orders); radioChoice.add(new AjaxFormComponentUpdatingBehavior(onchange) { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { System.out.println(model); } }); I expected, that model contains selected choice, but this print null. How I can get value of selected choice? - with Ajax (no submit button) - Michael Sparer http://talk-on-tech.blogspot.com -- View this message in context: http://www.nabble.com/RadioChoice-with-Ajax-tp19855494p19856377.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]