Anyone, Please! A table with column of dropdowns
Dear All, I've been trying to for last three days to do this. Basically I've an HTML table one of its column gives user to select Block Type. Block Type is a list of reference values that are shown in an html:select element. Now to handle this situation I've created String[] getter/setter for block type on the Form object. When i submit the form with different block types selected in different rows the selected values are correctly populated to the Form's block type property. The only problem, when page is shown after submission, all the dropdowns have same value selected in them! I'd really appriciate any help on this subject. How, if at all, struts handles this situation. Regards, ATTA - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Anyone, Please! A table with column of dropdowns
ATTA wrote: Basically I've an HTML table one of its column gives user to select Block Type. Block Type is a list of reference values that are shown in an html:select element. Now to handle this situation I've created String[] getter/setter for block type on the Form object. When i submit the form with different block types selected in different rows the selected values are correctly populated to the Form's block type property. The only problem, when page is shown after submission, all the dropdowns have same value selected in them! Can you post the JSP that renders the many select lists? It sounds like you need indexed properties to populate several select lists with the same name. Otherwise, Struts might think that a String[] goes with a single select list that allows multiple items to be selected. -- Wendy Smoak Applications Systems Analyst, Sr. Arizona State University, PA, IRM
Re: Anyone, Please! A table with column of dropdowns
Sure, I can. And thanks for replying! I've attached the JSP and Form class. And yes, i thought that i might need indexed properties and did add the index property getter/setter to the Form. but i cannot seem to submit the form with indexed property getter/setter. and by the way, we're using struts 1.0.2. Regards, ATTA -- JSP --- html:form action=/public/test.do table border=1 tr class=tableheader tdName/td tdCategory/td /tr % List records = (List) session.getAttribute(records); % % for (int i = 0; i records.size(); i++) { % tr td %= records.get(i).toString() % /td td html:select property=category html:options collection=optionList property=value labelProperty=label/ /html:select /td /tr % } % /table br html:submit / /html:form --- END OF JSP --- FORM public class TestForm extends ActionForm { private String[] key = null; private String[] category = null; Vector v = null; public String[] getKey() { List l; Iterator i; return this.key; } public void setKey(String[] key) { this.key = key; } public String[] getCategory() { return this.category; } public void setCategory(String[] category) { this.category = category; } public void reset(ActionMapping arg0, HttpServletRequest arg1) { this.category = null; } } --- END OF FORM - Original Message - From: Wendy Smoak [EMAIL PROTECTED] To: 'Struts Users Mailing List' [EMAIL PROTECTED] Sent: Thursday, July 24, 2003 10:07 AM Subject: RE: Anyone, Please! A table with column of dropdowns ATTA wrote: Basically I've an HTML table one of its column gives user to select Block Type. Block Type is a list of reference values that are shown in an html:select element. Now to handle this situation I've created String[] getter/setter for block type on the Form object. When i submit the form with different block types selected in different rows the selected values are correctly populated to the Form's block type property. The only problem, when page is shown after submission, all the dropdowns have same value selected in them! Can you post the JSP that renders the many select lists? It sounds like you need indexed properties to populate several select lists with the same name. Otherwise, Struts might think that a String[] goes with a single select list that allows multiple items to be selected. -- Wendy Smoak Applications Systems Analyst, Sr. Arizona State University, PA, IRM - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Anyone, Please! A table with column of dropdowns
ATTA wrote: and by the way, we're using struts 1.0.2. I don't know if indexed properties work with 1.0, but I think that's what you need to use. Otherwise, how do you expect Struts to know which of the multiple values in your String[] goes with each of the select lists? -- Wendy Smoak Applications Systems Analyst, Sr. Arizona State University, PA, IRM
Re: Anyone, Please! A table with column of dropdowns
yes, that's a good question. i guess the same way struts passes all the correct selections to the Form object on submission ;) while we are on the subject, could you please refer me some further readings on Indexed Properties and how it could help me in this case? Thanks for your time. ATTA - Original Message - From: Wendy Smoak [EMAIL PROTECTED] To: 'Struts Users Mailing List' [EMAIL PROTECTED] Sent: Thursday, July 24, 2003 10:29 AM Subject: RE: Anyone, Please! A table with column of dropdowns ATTA wrote: and by the way, we're using struts 1.0.2. I don't know if indexed properties work with 1.0, but I think that's what you need to use. Otherwise, how do you expect Struts to know which of the multiple values in your String[] goes with each of the select lists? -- Wendy Smoak Applications Systems Analyst, Sr. Arizona State University, PA, IRM - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Anyone, Please! A table with column of dropdowns
yes, that's a good question. i guess the same way struts passes all the correct selections to the Form object on submission ;) By magic. ;) But in this case, who knows what order the request parameters came in, who knows what order they are stored in the String[], so it's fairly impossible to correctly pre-select the values. (Actually most browsers seem to submit request parameters in the same order they appear on the form, but I wouldn't want to rely on that.) while we are on the subject, could you please refer me some further readings on Indexed Properties and how it could help me in this case? I've never used them, (and I'm not totally sure they'll solve this problem,) so Google to the rescue... http://www.google.com/search?q=struts+indexed+properties -- Wendy Smoak Applications Systems Analyst, Sr. Arizona State University, PA, IRM
Re: Anyone, Please! A table with column of dropdowns
so far i've found these two link related: http://www.husted.com/struts/tips/006.html http://jakarta.apache.org/struts/faqs/indexedprops.html and i'm still lost! i'm kind of confused on this. i would see this as a very frequent occuring 'problem' in data-driven web apps and by the response of my mails on this forum (for last 4 days now), it seems that either its not a problem or there's an obvious, startight-forward way that everyone knows but noone's willing to share!!! anyhow, thanks once more for your time. ATTA - Original Message - From: Wendy Smoak [EMAIL PROTECTED] To: 'Struts Users Mailing List' [EMAIL PROTECTED] Sent: Thursday, July 24, 2003 11:33 AM Subject: RE: Anyone, Please! A table with column of dropdowns yes, that's a good question. i guess the same way struts passes all the correct selections to the Form object on submission ;) By magic. ;) But in this case, who knows what order the request parameters came in, who knows what order they are stored in the String[], so it's fairly impossible to correctly pre-select the values. (Actually most browsers seem to submit request parameters in the same order they appear on the form, but I wouldn't want to rely on that.) while we are on the subject, could you please refer me some further readings on Indexed Properties and how it could help me in this case? I've never used them, (and I'm not totally sure they'll solve this problem,) so Google to the rescue... http://www.google.com/search?q=struts+indexed+properties -- Wendy Smoak Applications Systems Analyst, Sr. Arizona State University, PA, IRM - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]