Hello Igor, Thank you for your message. My code was taken from that example, but the problem was a different one. Finally I found the solution, was as simply as change the AbstractReadOnlyModel for the LoadableDetachableModel.
Thanks anyways! Oskar igor.vaynberg wrote: > > there is no difference between a regular page load and ajax > > see here > > http://wicketstuff.org/wicket13/ajax/choice.1 > > -igor > > > On Nov 13, 2007 7:13 PM, Toscano <[EMAIL PROTECTED]> wrote: >> >> Hello, >> >> I have two Dropdowns: Countries and Regions. When changing Countries, it >> goes to database and refresh the Regions with Ajax nicely. >> >> The first time the page loads, it will get the selected country from the >> database, and should show the regions but I don't really know how to do >> this. Normally, I can do with LoadableDetachableModel, and then assigning >> the ModelValue that corresponds, but with the Ajax behaviour I'm totally >> lost. >> >> Here is my code: >> >> countryWork.add(new AjaxFormComponentUpdatingBehavior("onchange") >> { >> protected void onUpdate(AjaxRequestTarget target) >> { >> target.addComponent(regionWork); >> regions = >> getRegionDaoInterface().getRegions(professionalInfo.getCountryWork().getCountryID()); >> if (regions.size()==0) regionWork.setEnabled(false); >> else regionWork.setEnabled(true); >> } >> }); >> >> Model regionModelChoices = new AbstractReadOnlyModel() >> { >> public Object getObject(Component component) >> { >> if (professionalInfo.getCountryWork()!=null) >> regions = >> getRegionDaoInterface().getRegions(professionalInfo.getCountryWork().getCountryID()); >> if (regions==null || regions.size()==0) >> regionWork.setEnabled(false); >> else >> regionWork.setEnabled(true); >> return regions; >> } >> }; >> >> >> How to load regions from a given country the first time the page loads >> without losing the ajax behaviour? >> >> As always, thank you very very much for your support, help, and time. >> Oskar >> >> >> -- >> View this message in context: >> http://www.nabble.com/DropdownChoice%2C-Ajax%2C-and-LoadableDetachableModel-tf4801900.html#a13739163 >> Sent from the Wicket - User mailing list archive at Nabble.com. >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- View this message in context: http://www.nabble.com/DropdownChoice%2C-Ajax%2C-and-LoadableDetachableModel-tf4801900.html#a13739470 Sent from the Wicket - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
