How do have cascaded selects in Struts
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Lawrence_Maturo
Posted On:   Wednesday, December 12, 2001 11:46 AM

I have a case where the user first selects an organization from a list of ogranizations, and then selects a program from a list of programs. The catch is that the list of programs depends on which organization was selected. My thought is to fill in the list of programs initially with the list appropriate to the default organization. Then when the user selects a new organization I need to update the list of programs to match the selected organization. I'm not sure how to best handle this in struts. Ulitimitely, the user presses an edit button to the edit the selected program. My best guess is that the select should set a hidden variable and cause a submit. Then I could check the variable to see   More>>


I have a case where the user first selects an organization from a list of ogranizations, and then selects a program from a list of programs. The catch is that the list of programs depends on which organization was selected.



My thought is to fill in the list of programs initially with the list appropriate to the default organization.
Then when the user selects a new organization I need to update the list of programs to match the selected organization. I'm not sure how to best handle this in struts.



Ulitimitely, the user presses an edit button to the edit the selected program.
My best guess is that the select should set a hidden variable and cause a submit. Then I could check the variable to see if the submit was from selecting a new organization or from pressing edit. How exactly I would do this in struts I have no idea. I suspect some JavsScript would be required to make this work.



Any help would be appreciated, especially if I am looking at the problem the wrong way and there is a better solution I have not thought of.

   <<Less

Re: How do have cascaded selects in Struts

Posted By:   Ted_Husted  
Posted On:   Wednesday, December 12, 2001 06:07 PM

You can use the Javascript handler to cause a submit
as soon as they select an item. The Action would then
look at what organization is selected, populate that
select box as needed, and forward back to the same
page.


The edit button could set a hidden variable that the
Action could check to determine the operation. Many
developers do this.


The thing to watch for is to give the submit button its
own name. By default, it will be named "submit", which
conflicts with the Javascript "submit" method.


This leads to an alternative to the hidden variable.
If the submit buttons have different names, you can
check to see which one is present in the request.


HTH - Ted

About | Sitemap | Contact