Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[Struts 2] How to populate select control after selection of a value in another select control

 
Nicolas Benhamou
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm a newbie in Struts 2 and I don't find a good way to link <s:select> on my JSP page.

I have 3 <s:select> populated via 3 linked hierarchic tables : GROUP (id_group, group) > CATEGORY (id_category, id_group, category) > SKILL (id_skill, id_category, skill)

Here is my JSP page, a classic search & list form :



My java class contains methods :

listSkill(), listCategory(), listGroup() and associated Getter and Setter.

When I select a Group, I would like the <select> that display categories only contains categories of the selected Group.
Same thing for Category and Skills.

Thanks a lot !
 
Ranveer K Kumar
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to use javascript.


 
Nicolas Benhamou
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to me, a full javascript solution is not a good one. I would like to minimize client role.
Of course, I tried to do that kind of thing :

On my <select> onchange event :



In my listCategory java method, I retrieve the selected idGroup via the associated getter and then, I load the List<Category>.
Finally I set the list with new values.

In Ecclipse debug mode, the list is the right one but on my jsp page, the <select> is not refreshed.

Maybe a cache problem ?

Thanks !

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic