• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

populate one dropdown options on change of another dropdown

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I have two dropdowns in my jsp page. one dropdown is geographical unit and another dropdown is Country.
Whenever Geographical drop down changes, country dropdown should be populated again. I have used a4j:support to do this. But that Country dropdown is not repopulated. I don't want to use onchange="submit" attribute as it is creating problems.

This is my code in jsp page.



The code Service code is like this:



The countryList is populated properly on change of Geo Unit dropdown. But the Country dropdown is not rerendered.

Thank you very much in advance.

Regards
Valli
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Vallidevi Appana wrote:Hi all,

I have two dropdowns in my jsp page. one dropdown is geographical unit and another dropdown is Country.
Whenever Geographical drop down changes, country dropdown should be populated again. I have used a4j:support to do this. But that Country dropdown is not repopulated. I don't want to use onchange="submit" attribute as it is creating problems.

This is my code in jsp page.



The code Service code is like this:



The countryList is populated properly on change of Geo Unit dropdown. But the Country dropdown is not rerendered.

Thank you very much in advance.

Regards
Valli


hi,
I think you have to be call a method in <a4J:support> to populated the country values.
Then after, Just you just simply reRender the values in country drop down list.
May be it is useful to you.<a4j:support event="onchange" reRender="moons" value="{var.method()}"/>
 
Vallidevi Appana
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sivaji,

Thank you very much for your response.
There is no value attribute availabe for a4j:support component.
Can you give me any more suggestions.

Regards
Valli
 
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The ajaxSingle attribute causes the value of the first dropdown list to be set in the corresponding control property. Without it, the entire form would be submitted, and if any control on the form had an invalid value, the whole operation would be suppressed.

What I do to cascade dropdowns is to set the SelectItem list(s) on the dependent control(s) dynamically. That is, EntityMBean.getCountryList() contains logic like this:


I then pair that with a valueChangeListener attached to the GeoUnit control. It does this:


Because of the ordering of processes in the JSF lifecycle, this works out very neatly and has the side benefit that the same caching getCountryList method also works well when populating on initial form display.

Note that the valueChangeListener does not attempt to do major data operations itself - it just sets things up for when everything is neatly in place and ready to use.
 
Tim Holloway
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Almost forgot. "entityMBean" is a very unfortunate name. "MBean" is conventionally used as the ending part of JMX MBean's classname, where "EntityMBean" would the the Management Bean classname for the "Entity" class. MBeans should not contain application logic. They are intended to manage the app, not to be the app.

"Entity" isn't a really happy name either, since in the case of JSF and JPA/EJB, use of Domain Model objects directly as backing beans doesn't usually work well, as the two types of model objects (Domain and View) have different scoping requirements in almost all cases.
 
Vallidevi Appana
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tim,

Thank you very much for your response.
I have tried your solution and it is working fine as expected in FireFox browser.
But not working in IE9 explorer.
Could you suggest me any solution to make it work on IE 9 also.
Thank you very much in advance.

Regards
Valli
 
Tim Holloway
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There's nothing in my approach that varies depending on the OS, Browser or versions, so I think you need to check and see if there's something in your copy of IE9 that's interfering with the proper functioning of AJAX. Also check the RichFaces configuration options in web.xml and make sure that your WEB-INF/lib directory only contains JSF implementation classes if and only if the webapp server requires them to be there. Tomcat does require those libraries, JEE full-stack servers do not and they will encounter conflicts between your webapp's JSF classes and the JSF classes that are part of the webapp server.
 
reply
    Bookmark Topic Watch Topic
  • New Topic