RE: Multiple Selects in a JSP
Hi Ken, You need to be able to get the initial value of the first list in your Action Class, and then you can do the same thing the first time that you do on updates, in exactly the same way. We do this on edits, where we get the value out of the database. Always remember that Struts is two-way. If you want something to have an initial value other than the default, then in your Action class set the field in the form that gets set when the user puts a value in, in the jsp. -- Larry Maturo [EMAIL PROTECTED] -Original Message- From: Struts Newsgroup [mailto:@[EMAIL PROTECTED]] Sent: Friday, March 29, 2002 2:55 PM To: [EMAIL PROTECTED] Subject: Re: Multiple Selects in a JSP Subject: Re: Multiple Selects in a JSP From: Ken Holzer [EMAIL PROTECTED] === Thanks Larry, I was able to get this to work. I do have a related question. I have a jsp page that shows a history of activities I have the same two select fields on this jsp. Each row on the page is its own form so that they can be updated seperately. Is there a way to fill the second select list based on the value of the first list when the page is populated. I have gotten it to change when the 1st select is changed, but ai want it to display correctly when the page is first displayed. Thanks, Ken Maturo, Larry [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]... Hi Ken, I have a Struts white paper, with an example of this. It also has lots of other examples as well. You can get it at: http://stealthis.athensgroup.com/presentations/ under Model Layer Framework. Basically you set up both lists in the Action Class and put them into the session or request (depends on how you set this action up in struts-config.xml). When the user selects an item in the first list it submits the form, and in your action you retrieve the variable from the form that gets set. This allows you to redo the second list to match the first list, and then you put the new list back into the session (or request) and go back to your jsp to redisplay the new list. -- Larry -Original Message- From: Struts Newsgroup [mailto:@[EMAIL PROTECTED]] Sent: Thursday, March 28, 2002 12:55 PM To: [EMAIL PROTECTED] Subject: Re: Multiple Selects in a JSP Subject: Re: Multiple Selects in a JSP From: Ken Holzer [EMAIL PROTECTED] === Hi Larry, Do you have a sample app demoing this concept? I am not sure how the Action Form, Action Class and JSP should be setup. Are the lists built in the Action Form or the Action Class? Thanks for your help, Ken Maturo, Larry [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]... Hi Ken, Yes, but by using a small amount of JavaScript: html:select property=orgId onchange='document.forms[0].submit()' html:options collection=orgList property=value labelProperty=shortName/ /html:select You should 0 out the string field orgId in your form bean so that you can tell a selection was made comparing it to 0. -- Larry Maturo [EMAIL PROTECTED] -Original Message- From: Struts Newsgroup [mailto:@[EMAIL PROTECTED]] Sent: Tuesday, March 26, 2002 4:25 PM To: [EMAIL PROTECTED] Subject: Multiple Selects in a JSP Subject: Multiple Selects in a JSP From: Ken Holzer [EMAIL PROTECTED] === I have two selects in my JSP and I want to be able to dynamically change the options of the 2nd select based on the choice selected from the 1st select. Is there a way to do that using the Struts tags? Thanks, Ken -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Multiple Selects in a JSP
Subject: Re: Multiple Selects in a JSP From: Ken Holzer [EMAIL PROTECTED] === Thanks Larry, I was able to get this to work. I do have a related question. I have a jsp page that shows a history of activities I have the same two select fields on this jsp. Each row on the page is its own form so that they can be updated seperately. Is there a way to fill the second select list based on the value of the first list when the page is populated. I have gotten it to change when the 1st select is changed, but ai want it to display correctly when the page is first displayed. Thanks, Ken Maturo, Larry [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]... Hi Ken, I have a Struts white paper, with an example of this. It also has lots of other examples as well. You can get it at: http://stealthis.athensgroup.com/presentations/ under Model Layer Framework. Basically you set up both lists in the Action Class and put them into the session or request (depends on how you set this action up in struts-config.xml). When the user selects an item in the first list it submits the form, and in your action you retrieve the variable from the form that gets set. This allows you to redo the second list to match the first list, and then you put the new list back into the session (or request) and go back to your jsp to redisplay the new list. -- Larry -Original Message- From: Struts Newsgroup [mailto:@[EMAIL PROTECTED]] Sent: Thursday, March 28, 2002 12:55 PM To: [EMAIL PROTECTED] Subject: Re: Multiple Selects in a JSP Subject: Re: Multiple Selects in a JSP From: Ken Holzer [EMAIL PROTECTED] === Hi Larry, Do you have a sample app demoing this concept? I am not sure how the Action Form, Action Class and JSP should be setup. Are the lists built in the Action Form or the Action Class? Thanks for your help, Ken Maturo, Larry [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]... Hi Ken, Yes, but by using a small amount of JavaScript: html:select property=orgId onchange='document.forms[0].submit()' html:options collection=orgList property=value labelProperty=shortName/ /html:select You should 0 out the string field orgId in your form bean so that you can tell a selection was made comparing it to 0. -- Larry Maturo [EMAIL PROTECTED] -Original Message- From: Struts Newsgroup [mailto:@[EMAIL PROTECTED]] Sent: Tuesday, March 26, 2002 4:25 PM To: [EMAIL PROTECTED] Subject: Multiple Selects in a JSP Subject: Multiple Selects in a JSP From: Ken Holzer [EMAIL PROTECTED] === I have two selects in my JSP and I want to be able to dynamically change the options of the 2nd select based on the choice selected from the 1st select. Is there a way to do that using the Struts tags? Thanks, Ken -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Multiple Selects in a JSP
Subject: Re: Multiple Selects in a JSP From: Ken Holzer [EMAIL PROTECTED] === Hi Larry, Do you have a sample app demoing this concept? I am not sure how the Action Form, Action Class and JSP should be setup. Are the lists built in the Action Form or the Action Class? Thanks for your help, Ken Maturo, Larry [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]... Hi Ken, Yes, but by using a small amount of JavaScript: html:select property=orgId onchange='document.forms[0].submit()' html:options collection=orgList property=value labelProperty=shortName/ /html:select You should 0 out the string field orgId in your form bean so that you can tell a selection was made comparing it to 0. -- Larry Maturo [EMAIL PROTECTED] -Original Message- From: Struts Newsgroup [mailto:@[EMAIL PROTECTED]] Sent: Tuesday, March 26, 2002 4:25 PM To: [EMAIL PROTECTED] Subject: Multiple Selects in a JSP Subject: Multiple Selects in a JSP From: Ken Holzer [EMAIL PROTECTED] === I have two selects in my JSP and I want to be able to dynamically change the options of the 2nd select based on the choice selected from the 1st select. Is there a way to do that using the Struts tags? Thanks, Ken -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Multiple Selects in a JSP
Hi Ken, I have a Struts white paper, with an example of this. It also has lots of other examples as well. You can get it at: http://stealthis.athensgroup.com/presentations/ under Model Layer Framework. Basically you set up both lists in the Action Class and put them into the session or request (depends on how you set this action up in struts-config.xml). When the user selects an item in the first list it submits the form, and in your action you retrieve the variable from the form that gets set. This allows you to redo the second list to match the first list, and then you put the new list back into the session (or request) and go back to your jsp to redisplay the new list. -- Larry -Original Message- From: Struts Newsgroup [mailto:@[EMAIL PROTECTED]] Sent: Thursday, March 28, 2002 12:55 PM To: [EMAIL PROTECTED] Subject: Re: Multiple Selects in a JSP Subject: Re: Multiple Selects in a JSP From: Ken Holzer [EMAIL PROTECTED] === Hi Larry, Do you have a sample app demoing this concept? I am not sure how the Action Form, Action Class and JSP should be setup. Are the lists built in the Action Form or the Action Class? Thanks for your help, Ken Maturo, Larry [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]... Hi Ken, Yes, but by using a small amount of JavaScript: html:select property=orgId onchange='document.forms[0].submit()' html:options collection=orgList property=value labelProperty=shortName/ /html:select You should 0 out the string field orgId in your form bean so that you can tell a selection was made comparing it to 0. -- Larry Maturo [EMAIL PROTECTED] -Original Message- From: Struts Newsgroup [mailto:@[EMAIL PROTECTED]] Sent: Tuesday, March 26, 2002 4:25 PM To: [EMAIL PROTECTED] Subject: Multiple Selects in a JSP Subject: Multiple Selects in a JSP From: Ken Holzer [EMAIL PROTECTED] === I have two selects in my JSP and I want to be able to dynamically change the options of the 2nd select based on the choice selected from the 1st select. Is there a way to do that using the Struts tags? Thanks, Ken -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Multiple Selects in a JSP
Subject: Re: Multiple Selects in a JSP From: Pim [EMAIL PROTECTED] === From Using Struts: http://stealthis.athensgroup.com/presentations/Model_Layer_Framework/Struts_ Whitepaper.pdf Dependent Drop-Down Combo Box Lists In many situations, you will have two combo boxes, with the contents of the second dependent on the value selected in the first. That is, each item in the first combo box is associated with a list. To handle this, you need for the first combo box to do a submit when it changes, so that you have a chance to update the second. You do this with: html:select property=orgId onchange='document.forms[0].submit()' html:options collection=orgList property=value labelProperty=longName/ /html:select In this example, the property value, of the beans in orglist are orgIds and the labelProperty property is the name to display. When you are in your action class the first time, the orgId string property of your form bean will be null or blank. In subsequent submissions the orgId property of your form bean will contain a valid orgId, so that you can look up the list associated with that value, and thus populate the second drop-down combo box propery. Radio Button Input Gr, Pim Ken Holzer [EMAIL PROTECTED] wrote in message news:a7qs8p$p2o$[EMAIL PROTECTED]... I have two selects in my JSP and I want to be able to dynamically change the options of the 2nd select based on the choice selected from the 1st select. Is there a way to do that using the Struts tags? Thanks, Ken -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Multiple Selects in a JSP
Subject: Multiple Selects in a JSP From: Ken Holzer [EMAIL PROTECTED] === I have two selects in my JSP and I want to be able to dynamically change the options of the 2nd select based on the choice selected from the 1st select. Is there a way to do that using the Struts tags? Thanks, Ken -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Multiple Selects in a JSP
The selection takes place on the browser. Therefore, you need to use JavaScript to do it. This is unless you have a large amount of different options in select #1 and need to go to the server to get the options for select #2. You'd then need to do an onchange in select #1. That would be pretty annoying for the user. -Richard At 02:25 PM 3/26/2002 -0800, you wrote: Subject: Multiple Selects in a JSP From: Ken Holzer [EMAIL PROTECTED] === I have two selects in my JSP and I want to be able to dynamically change the options of the 2nd select based on the choice selected from the 1st select. Is there a way to do that using the Struts tags? Thanks, Ken -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Multiple Selects in a JSP
Hi Ken, Yes, but by using a small amount of JavaScript: html:select property=orgId onchange='document.forms[0].submit()' html:options collection=orgList property=value labelProperty=shortName/ /html:select You should 0 out the string field orgId in your form bean so that you can tell a selection was made comparing it to 0. -- Larry Maturo [EMAIL PROTECTED] -Original Message- From: Struts Newsgroup [mailto:@[EMAIL PROTECTED]] Sent: Tuesday, March 26, 2002 4:25 PM To: [EMAIL PROTECTED] Subject: Multiple Selects in a JSP Subject: Multiple Selects in a JSP From: Ken Holzer [EMAIL PROTECTED] === I have two selects in my JSP and I want to be able to dynamically change the options of the 2nd select based on the choice selected from the 1st select. Is there a way to do that using the Struts tags? Thanks, Ken -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]