Any idea???I'm trapped by this problem......and no idea.....
overseastars wrote:
>
> Hi all
>
> I'm having problems with using AjaxFormComponentUpdatingBehavior.
> I'd like to make to ListChoices which contain a list of countries and
> cities. For example, if I select one item in the first ListChoice and the
> second ListChoice should display the related cities. Since I dont know how
> to get some lists of cities, I just arbitrarily pick up one list to use.
> the following is part of my code.
>
> My case is that it actually works when the frontpage is opened at the
> first time. However, after the first click, the second doesnt work and
> that getModelObjectAsString gives me null value. And if I refresh the
> page, two lists both become empty.
>
> Could someone please help me out?? Thanks in advance. BTW, I also wanna
> know how to get some lists of cities. :-DMany thanks..
>
> ************************************************************************************************************
> private String countries;
> private String countries1;
>
> private ListChoice countryListChoice;
> private ListChoice countryListChoice1;
> private List<String> tl;
> private List<String> testlist;
>
> public SearchForm(String id) {
> super(id);
>
> setModel(new CompoundPropertyModel(""));
> tl = CountryListChoice.getCOUNTRIES();
> testlist = CountryListChoice.getCOUNTRIES();
> setOutputMarkupId(true);
> CountryListChoice clc = new CountryListChoice();
> countryListChoice = new ListChoice("countries", new
> PropertyModel(this,
> "countries"), tl, clc.getRenderer());
> countryListChoice.setOutputMarkupId(true);
> add(countryListChoice);
>
> CountryListChoice clc1 = new CountryListChoice();
> countryListChoice1 = new ListChoice("countries1", new
> PropertyModel(this, "countries1"), testlist, clc.getRenderer());
> countryListChoice1.setOutputMarkupId(true);
> add(countryListChoice1);
>
> countryListChoice.add(new
> MyAjaxFormComponentUpdatingBehavior("onChange"){
>
> /* (non-Javadoc)
> * @see
> com.smartbooking.wicket.component.MyAjaxFormComponentUpdatingBehavior#onUpdate(org.apache.wicket.ajax.AjaxRequestTarget)
> */
> @Override
> protected void onUpdate(AjaxRequestTarget target) {
> // TODO Auto-generated method stub
> if(countryListChoice.getModelObject() != null){
> testlist.clear();
> String c =
> countryListChoice.getModelObjectAsString();
> System.out.println("\n\nour c : " + c + "\n\n");
> testlist.add(c);
> }else{
> testlist.clear();
> testlist.add("xing said null");
> System.out.println("\n\n really null!!!
> \n\n");
> }
> target.addComponent(countryListChoice1);
> }});
> }
> /**
> * @return the countries
> */
> public String getCountries() {
> return countries;
> }
>
> /**
> * @param countries the countries to set
> */
> public void setCountries(String countries) {
> this.countries = countries;
> }
>
> /**
> * @return the countries1
> */
> public String getCountries1() {
> return countries1;
> }
>
> /**
> * @param countries1 the countries1 to set
> */
> public void setCountries1(String countries1) {
> this.countries1 = countries1;
> }
>
>
--
View this message in context:
http://www.nabble.com/AjaxFormComponentUpdatingBehavior-problem-tp20032008p20045781.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]