RE: Not getting submitted values from textarea in logic:iterate
Hello: Does anyone have any ideas on how to get this to work? Is this a bug? Thanks, Neil -- Neil Aggarwal, JAMM Consulting, (214) 986-3533, www.JAMMConsulting.com FREE! Valuable info on how your business can reduce operating costs by 17% or more in 6 months or less! http://newsletter.JAMMConsulting.com -Original Message- From: Neil Aggarwal [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 20, 2005 10:41 AM To: 'Struts Users Mailing List' Subject: Not getting submitted values from textarea in logic:iterate Hello: I have a DynaForm with some beans stored in an array: form-bean name=admin.editClubForm type=org.apache.struts.validator.DynaValidatorForm form-property name=features type=persistent.Feature[]/ /form-bean I have the form-bean declared as session scope for my actions: action path=/admin/editClubInit type=admin.EditClubInit name=admin.editClubForm scope=session forward name=success path=/admin/editClub.do/ /action action path=/admin/editClub forward=admin.editClub / action path=/admin/editClubAction type=admin.EditClubAction name=admin.editClubForm scope=session forward name=failure path=/admin/editClub.do/ forward name=success path=/admin/showClubs.do redirect=true / /action The persistent.Feature class has a field text with setText and getText accessors. When want want to display the data, I first call /admin/editClubInit to populate the DynaForm. Here is the code that does that: Feature[] features = new Feature[NUM_FEATURES]; for( int i=0; iNUM_FEATURES; i++ ) { features[i] = new persistent.Feature(Test [+i+]); } df.set(features, features); After populating the form, the EditClubInit action forwards to user to the page to display the form. Here is the JSP code that shows the data: logic:iterate name=admin.editClubForm property=features id=feature br html:textarea name=feature property=text indexed=true rows=3 cols=75/ /logic:iterate The data appears correctly on the page. Unfortunately, when I submit the form to my action class to process it, I do not get the text I submitted. I get the original text that EditClubInit prepopulated the form with. Here is the code I am using to retrieve the data: Feature[] features = (Feature[]) df.get(features); for( int i=0; ifeatures.length; i++ ) { System.err.println( Feature[+i+] is +features[i].getText()); } Any ideas why this would not be working? If you need to see more details, I can provide them. I was trying to focus on what I thought would be helpful. Thanks, Neil -- Neil Aggarwal, JAMM Consulting, (214) 986-3533, www.JAMMConsulting.com FREE! Valuable info on how your business can reduce operating costs by 17% or more in 6 months or less! http://newsletter.JAMMConsulting.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Not getting submitted values from textarea in logic:iterate
Your html:textarea/ tag is using the 'name' attribute, which tells it to associate itself with a specific bean instead of the containing form bean. html:textarea name=feature property=text indexed=true rows=3 cols=75/ This binds the text area to the property named 'text' on the 'feature' bean defined by the enclosing logic:iterate/. That's not what you want. If you look at the request when you submit the form I think you'll find that the values from the text areas are submitted through a request parameter named 'text'. Try this instead: html:textarea property=features value=${feature}/ You might also be able to do something like html:textarea property=features[${i}]/ if you add indexId=i to your logic:iterate/ tag. L. Neil Aggarwal wrote: Hello: Does anyone have any ideas on how to get this to work? Is this a bug? Thanks, Neil -- Neil Aggarwal, JAMM Consulting, (214) 986-3533, www.JAMMConsulting.com FREE! Valuable info on how your business can reduce operating costs by 17% or more in 6 months or less! http://newsletter.JAMMConsulting.com -Original Message- From: Neil Aggarwal [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 20, 2005 10:41 AM To: 'Struts Users Mailing List' Subject: Not getting submitted values from textarea in logic:iterate Hello: I have a DynaForm with some beans stored in an array: form-bean name=admin.editClubForm type=org.apache.struts.validator.DynaValidatorForm form-property name=features type=persistent.Feature[]/ /form-bean I have the form-bean declared as session scope for my actions: action path=/admin/editClubInit type=admin.EditClubInit name=admin.editClubForm scope=session forward name=success path=/admin/editClub.do/ /action action path=/admin/editClub forward=admin.editClub / action path=/admin/editClubAction type=admin.EditClubAction name=admin.editClubForm scope=session forward name=failure path=/admin/editClub.do/ forward name=success path=/admin/showClubs.do redirect=true / /action The persistent.Feature class has a field text with setText and getText accessors. When want want to display the data, I first call /admin/editClubInit to populate the DynaForm. Here is the code that does that: Feature[] features = new Feature[NUM_FEATURES]; for( int i=0; iNUM_FEATURES; i++ ) { features[i] = new persistent.Feature(Test [+i+]); } df.set(features, features); After populating the form, the EditClubInit action forwards to user to the page to display the form. Here is the JSP code that shows the data: logic:iterate name=admin.editClubForm property=features id=feature br html:textarea name=feature property=text indexed=true rows=3 cols=75/ /logic:iterate The data appears correctly on the page. Unfortunately, when I submit the form to my action class to process it, I do not get the text I submitted. I get the original text that EditClubInit prepopulated the form with. Here is the code I am using to retrieve the data: Feature[] features = (Feature[]) df.get(features); for( int i=0; ifeatures.length; i++ ) { System.err.println( Feature[+i+] is +features[i].getText()); } Any ideas why this would not be working? If you need to see more details, I can provide them. I was trying to focus on what I thought would be helpful. Thanks, Neil -- Neil Aggarwal, JAMM Consulting, (214) 986-3533, www.JAMMConsulting.com FREE! Valuable info on how your business can reduce operating costs by 17% or more in 6 months or less! http://newsletter.JAMMConsulting.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Laurie, Open Source advocate, Java geek and novice blogger: http://www.holoweb.net/laurie - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Not getting submitted values from textarea in logic:iterate
Laurie: I need to get the value of the text field from the feature bean, not just the feature bean itself. So, I had the change your code to: logic:iterate name=admin.editClubForm property=features id=feature indexId=i html:textarea property=features[${i}].text value=${feature.text} rows=3 cols=75/ /logic:iterate And it worked perfectly. Thanks for tip! Neil -- Neil Aggarwal, JAMM Consulting, (214) 986-3533, www.JAMMConsulting.com FREE! Valuable info on how your business can reduce operating costs by 17% or more in 6 months or less! http://newsletter.JAMMConsulting.com -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Laurie Harper Sent: Thursday, July 21, 2005 5:04 PM To: user@struts.apache.org Subject: Re: Not getting submitted values from textarea in logic:iterate Your html:textarea/ tag is using the 'name' attribute, which tells it to associate itself with a specific bean instead of the containing form bean. html:textarea name=feature property=text indexed=true rows=3 cols=75/ This binds the text area to the property named 'text' on the 'feature' bean defined by the enclosing logic:iterate/. That's not what you want. If you look at the request when you submit the form I think you'll find that the values from the text areas are submitted through a request parameter named 'text'. Try this instead: html:textarea property=features value=${feature}/ You might also be able to do something like html:textarea property=features[${i}]/ if you add indexId=i to your logic:iterate/ tag. L. Neil Aggarwal wrote: Hello: Does anyone have any ideas on how to get this to work? Is this a bug? Thanks, Neil -- Neil Aggarwal, JAMM Consulting, (214) 986-3533, www.JAMMConsulting.com FREE! Valuable info on how your business can reduce operating costs by 17% or more in 6 months or less! http://newsletter.JAMMConsulting.com -Original Message- From: Neil Aggarwal [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 20, 2005 10:41 AM To: 'Struts Users Mailing List' Subject: Not getting submitted values from textarea in logic:iterate Hello: I have a DynaForm with some beans stored in an array: form-bean name=admin.editClubForm type=org.apache.struts.validator.DynaValidatorForm form-property name=features type=persistent.Feature[]/ /form-bean I have the form-bean declared as session scope for my actions: action path=/admin/editClubInit type=admin.EditClubInit name=admin.editClubForm scope=session forward name=success path=/admin/editClub.do/ /action action path=/admin/editClub forward=admin.editClub / action path=/admin/editClubAction type=admin.EditClubAction name=admin.editClubForm scope=session forward name=failure path=/admin/editClub.do/ forward name=success path=/admin/showClubs.do redirect=true / /action The persistent.Feature class has a field text with setText and getText accessors. When want want to display the data, I first call /admin/editClubInit to populate the DynaForm. Here is the code that does that: Feature[] features = new Feature[NUM_FEATURES]; for( int i=0; iNUM_FEATURES; i++ ) { features[i] = new persistent.Feature(Test [+i+]); } df.set(features, features); After populating the form, the EditClubInit action forwards to user to the page to display the form. Here is the JSP code that shows the data: logic:iterate name=admin.editClubForm property=features id=feature br html:textarea name=feature property=text indexed=true rows=3 cols=75/ /logic:iterate The data appears correctly on the page. Unfortunately, when I submit the form to my action class to process it, I do not get the text I submitted. I get the original text that EditClubInit prepopulated the form with. Here is the code I am using to retrieve the data: Feature[] features = (Feature[]) df.get(features); for( int i=0; ifeatures.length; i++ ) { System.err.println( Feature[+i+] is +features[i].getText()); } Any ideas why this would not be working? If you need to see more details, I can provide them. I was trying to focus on what I thought would be helpful. Thanks, Neil -- Neil Aggarwal, JAMM Consulting, (214) 986-3533, www.JAMMConsulting.com FREE! Valuable info on how your business can reduce operating costs by 17% or more in 6 months or less! http://newsletter.JAMMConsulting.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Laurie, Open Source advocate, Java geek and novice blogger: http://www.holoweb.net/laurie