Hello,

I found some questions related to this topic, but I couldn't make it to
work. 
I have two dropdowns, countries and regions. The easy thing is that I load
the regions when the country has been selected, and I use
AjaxFormComponentUpdatingBehavior for this and works.
The thing is that we don't have Regions for all the countries, so in that
cases I want to disable the dropdown.

This is the code I have:


// countryWork is the first dropdown
countryWork.add(new AjaxFormComponentUpdatingBehavior("onchange")
{
            protected void onUpdate(AjaxRequestTarget target)
            {        target.addComponent(regionWork);            }
});

// and regionWork is the region

 IModel regionModelChoices = new AbstractReadOnlyModel()
        {
            public Object getObject(Component component)
            {
               if (professionalInfo.getCountryWork()!=null)
                     regions =
getRegionDaoInterface().getRegions(professionalInfo.getCountryWork().getCountryID());
                  if (regions.size()==0)
                           regionWork.setEnabled(false);
               else
                           regionWork.setEnabled(true);
               return regions;
            }
        };

          regionWork  = new DropDownChoice("regionWork", new Model(),
regionModelChoices,
          new ChoiceRenderer("regionName", "regionID"));
          regionWork.setOutputMarkupId(true);

The dropdown changes, but with one refresh delay. For example, I have
regions for Canada but not for Spain. If I change to Canada, nothing
happens, but the next change in the country will enable the dropdown.

Any ideas?

Thank you very much for your time,
Oskar
-- 
View this message in context: 
http://www.nabble.com/Enable-and-Disable-using-Ajax-tf4776221.html#a13662524
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to