Re: xml validation with indexed properties.
> I'm using struts and got issue with their xml validation framework. I have > form with some indexed properties where element is just plain String. And I > need make validation for it. I tried to use indexedListProperty for this > case, but it doesn't work and as I read in 'Struts in Action' it works only > for indexed properties with nested properties(i.e. > indexedProperty[].nested) and it's not suits for my issue. Maybe anyone > knows how to resolve this? Hi, as workaround you could fallback to use validate() method. You might consider to crate a jira issue: https://issues.apache.org/jira/projects/WW Regards, Christoph This Email was scanned by Sophos Anti Virus
xml validation with indexed properties.
I'm using struts and got issue with their xml validation framework. I have form with some indexed properties where element is just plain String. And I need make validation for it. I tried to use indexedListProperty for this case, but it doesn't work and as I read in 'Struts in Action' it works only for indexed properties with nested properties(i.e. indexedProperty[].nested) and it's not suits for my issue. Maybe anyone knows how to resolve this?
OGNL Indexed and Object Indexed Properties
OGNL Indexed and Object Indexed Properties Hi, I'm wondering why this code is not working. I'm using struts 2.3.16.1 and ognl 3.0.6. In my action class I have this public String[] getFieldArray() { System.out.println( getFieldArray()); return null; } public void setFieldArray(String[] array) { } public MyListString getFieldList() { System.out.println( getFieldList()); return new MyListString(); } public void setFieldList(MyListString list) { } public MyMapString, String getFieldMap() { System.out.println( getFieldMap()); return new MyMapString, String(); } public void setFieldMap(MyMapString, String map) { } public String getFieldWithIndex(int index) { System.out.println( getFieldWithIndex( + index + )); return null; } public void setFieldWithIndex(int index, String value) { System.out.println( setFieldWithIndex( + index + , + value + )); } public String getFieldWithKey(String key) { System.out.println( getFieldWithKey( + key + )); return null; } public void setFieldWithKey(String key, String value) { System.out.println( setFieldWithKey( + key + , + value + )); } Note that MyList and MyMap are as follows class MyMapK, V implements MapK, V { ... } class MyListV implements ListV { ... } I have the get() methods overridden on the those classes On my jsp I have this s:property value=fieldArray[1]/ s:property value=fieldList[1]/ s:property value=fieldMap['1']/ s:property value=fieldWithIndex[1]/ s:property value=fieldWithKey['1']/ Result is getFieldArray() getFieldList() MyList.get(1) getFieldMap() MyMap.get(1) MyMap.get(1) Question: According to OGNL ( http://commons.apache.org/proper/commons-ognl/language-guide.html) under heading JavaBeans Indexed Properties and OGNL Object Indexed Properties, getFieldWithIndex(int index) should be called, but it isn't, same goes with getFieldWithKey(String key), why ? I looked at the latest OGNL source code (not the one I'm using since I couldn't find the source code for version 3.0.6) hoping if I could spot a method where it tries different get/set methods. Tried setting breakpoints at OGNLRuntime, ObjectPropertyAccessor but coulnd't see anything obvious. At the moment I have a few workarounds 1. Use the ones that are working, i.e. getFieldList() and getFieldMap(), implementing my own List and Map 2. Use java.util.List getList() and setList(java.util.List list), struts will create a new List and populate accordingly in the order in which they were submitted in the form The issue with this is, if I have a pair or triplet of things that go hand in hand, then it gets complex. e.g. name and address where address is optional in the form the user put name1, address1, name2 (with no address), and name3, address3 struts calls setName() with List containing name1, name2, name3 it also calls setAddress() with List containing address1, address3 There is no way the code can then figure out that that address3 is actually associated with name3 In the past I was able to get around this by supplying another data structure that tells the code which address belongs to which name but it involves JavaScript, and it gets messy quite quickly. 3. Bypass struts, in the get phase (showing the form) just use straight html combined with struts tags, during the set phase (submitting the form), will just get the parameters using HttpServletRequest e.g. during show form input type=text name=whateverName value=s:property value=whateverValue// instead of s:textfield ... /
Antwort: OGNL Indexed and Object Indexed Properties
Question: According to OGNL ( http://commons.apache.org/proper/commons-ognl/language-guide.html) under heading JavaBeans Indexed Properties and OGNL Object Indexed Properties, getFieldWithIndex(int index) should be called, but it isn't, same goes with getFieldWithKey(String key), why ? I looked at the latest OGNL source code (not the one I'm using since I couldn't find the source code for version 3.0.6) hoping if I could spot a method where it tries different get/set methods. Tried setting breakpoints at OGNLRuntime, ObjectPropertyAccessor but coulnd't see anything obvious. At the moment I have a few workarounds 1. Use the ones that are working, i.e. getFieldList() and getFieldMap(), implementing my own List and Map Another way would be OGNL method call syntax: s:property value=getFieldWithIndex(1)/ 2. Use java.util.List getList() and setList(java.util.List list), struts will create a new List and populate accordingly in the order in which they were submitted in the form The issue with this is, if I have a pair or triplet of things that go hand in hand, then it gets complex. e.g. name and address where address is optional in the form the user put name1, address1, name2 (with no address), and name3, address3 struts calls setName() with List containing name1, name2, name3 it also calls setAddress() with List containing address1, address3 There is no way the code can then figure out that that address3 is actually associated with name3 In the past I was able to get around this by supplying another data structure that tells the code which address belongs to which name but it involves JavaScript, and it gets messy quite quickly. struts/OGNL can store mulitple values in a map. You could use name as key and address as value: address: s:textfield name=map['name'] / That works well when you know names during get phase (when users cannot change names on that particular form). If users can also enter names here, you need javascript. Another use case of that map syntax is when the number of input fileds is dynamic. 3. Bypass struts, in the get phase (showing the form) just use straight html combined with struts tags, during the set phase (submitting the form), will just get the parameters using HttpServletRequest e.g. during show form input type=text name=whateverName value=s:property value=whateverValue// instead of s:textfield ... / This is always possible, of course. It means you have to generate parameter names during GET and parse them on POST. Usually I try to avoid this in my applications but there are (rare) cases I need to do that. If you do so, you have to think of how you do validation. You can still use struts validation when you generate the same parameter names again (in validate() method) and use s:fieldError tags with the same generated names. Regards, Christoph OGNL Indexed and Object Indexed Properties Hi, I'm wondering why this code is not working. I'm using struts 2.3.16.1 and ognl 3.0.6. In my action class I have this public String[] getFieldArray() { System.out.println( getFieldArray()); return null; } public void setFieldArray(String[] array) { } public MyListString getFieldList() { System.out.println( getFieldList()); return new MyListString(); } public void setFieldList(MyListString list) { } public MyMapString, String getFieldMap() { System.out.println( getFieldMap()); return new MyMapString, String(); } public void setFieldMap(MyMapString, String map) { } public String getFieldWithIndex(int index) { System.out.println( getFieldWithIndex( + index + )); return null; } public void setFieldWithIndex(int index, String value) { System.out.println( setFieldWithIndex( + index + , + value + )); } public String getFieldWithKey(String key) { System.out.println( getFieldWithKey( + key + )); return null; } public void setFieldWithKey(String key, String value) { System.out.println( setFieldWithKey( + key + , + value + )); } Note that MyList and MyMap are as follows class MyMapK, V implements MapK, V { ... } class MyListV implements ListV { ... } I have the get() methods overridden on the those classes On my jsp I have this s:property value=fieldArray[1]/ s:property value=fieldList[1]/ s:property value=fieldMap['1']/ s:property value=fieldWithIndex[1]/ s:property value=fieldWithKey['1']/ Result is getFieldArray() getFieldList() MyList.get(1) getFieldMap() MyMap.get(1) MyMap.get(1) Question: According to OGNL ( http://commons.apache.org/proper/commons-ognl/language-guide.html) under heading JavaBeans Indexed Properties and OGNL Object Indexed Properties, getFieldWithIndex(int index) should be called, but it isn't, same goes with getFieldWithKey(String key), why ? I looked at the latest OGNL source code (not the one I'm using since I couldn't find the source code for version 3.0.6) hoping if I could spot
Re: OGNL Indexed and Object Indexed Properties
My case is logically like this Imagine these data structure gamer: userId gameConsole type game: gameId gameName A game is associated to a gameConsole There are 2 types of gamers, for a type = CASUAL gamer, there are no games associated for a type = AVERAGE gamer, you can have games asscociated Data as follows userId: 1 gameConsole: nintendo type: CASUAL userId: 2 gameConsole: playstation type: AVERAGE gameId: 9, gameName: Gran Turismo gameId: 10, gameName: Winning Eleven Imagine I have a bean class called Wonky (that implements java.util.Map) that behaves like this Type = CASUAL Wonky.get(String key) will return a Wonky instance, if you then call getValue() on this instance it will return a gameConsole name (e.g. nintendo or playstation) Type = AVERAGE Wonky.get(String key) will return a Wonky instance, if you then call get(String key) on this instance it will return another Wonky instance, if you then call getValue() on this instance it will return a game name (e.g Gran Turismo or Winning Eleven) I want to be able to do this on a form s:textfield name=wonky['1'].value/ During get: shows the gameConsole of gamer with userId = 1 During set: sets the gameConsole for gamer with userId = 1 s:textfield name=wonky['1']['9'].value/ During get: shows the game with id = 9 associated with gamer with userId = 1 During set: set the game name with id = 9 associated with gamer with userId = 1 alternatively, I'm ok with this idea as well s:textfield name=wonky['1'].value['9'].value/ In this case Wonky behaves like this for Type = AVERAGE Wonky.get(String key) - Wonky instance, getValue() - return this; get(String key) - another Wonky instance, getValue() on that instance will return a game name (e.g Gran Turismo or Winning Eleven) I did more investigation Consider this code class MyMap implements Map { private Long id; public MyMap(Long id) { this.id = id; } ... @Override public Object get(Object key) { System.out.println(MyMap@ + id + .get( + key + )); return new MyMap(id + 1); } public String getValue() { System.out.println(MyMap@ + id + .getValue()); return Long.toString(id); } public void setValue(String value) { System.out.println(MyMap@ + id + .setValue( + value + )); } } On my action class public MyMap getFieldMap() { System.out.println( getFieldMap()); MyMap map = new MyMap(1L); return map; } public void setFieldMap(MyMap map) { } private Long index = 1L; public Long getIndex() { System.out.println( getIndex()); return index; } public void setIndex(Long index) { System.out.println( setIndex( + index + )); this.index = index; } On my jsp s:form action=... s:textfield name=fieldMap['%{index}']['%{index}'].value/ s:submit/ /s:form Result is During get getIndex() getIndex() getFieldMap() my...@1.get(1) my...@2.get(1) my...@3.get(value) getIndex() getIndex() Ok, getValue() isn't called, I can work with this, I can make all my keys numbers, if I detect a non-number I just route the call to getValue() I think since it implements a map, .value get interpreted as get(value); During set getFieldMap() my...@1.get(1) my...@2.get(1) This I can't work with since setValue() isn't called anywhere. On Tue, May 20, 2014 at 3:02 PM, Christoph Nenning christoph.nenn...@lex-com.net wrote: Question: According to OGNL ( http://commons.apache.org/proper/commons-ognl/language-guide.html) under heading JavaBeans Indexed Properties and OGNL Object Indexed Properties, getFieldWithIndex(int index) should be called, but it isn't, same goes with getFieldWithKey(String key), why ? I looked at the latest OGNL source code (not the one I'm using since I couldn't find the source code for version 3.0.6) hoping if I could spot a method where it tries different get/set methods. Tried setting breakpoints at OGNLRuntime, ObjectPropertyAccessor but coulnd't see anything obvious. At the moment I have a few workarounds 1. Use the ones that are working, i.e. getFieldList() and getFieldMap(), implementing my own List and Map Another way would be OGNL method call syntax: s:property value=getFieldWithIndex(1)/ 2. Use java.util.List getList() and setList(java.util.List list), struts will create a new List and populate accordingly in the order in which they were submitted in the form The issue with this is, if I have a pair or triplet of things that go hand in hand, then it gets complex. e.g. name and address where address is optional in the form the user put name1, address1, name2 (with no address), and name3, address3 struts calls setName() with List containing name1, name2, name3 it also calls setAddress() with List containing address1, address3 There is no way the code can then figure out that that address3 is actually associated with name3 In the past I was able to get around this by supplying another data structure that tells the code which address belongs to which name but it involves JavaScript, and it gets messy quite
Re: OGNL Indexed and Object Indexed Properties
Result is During get getIndex() getIndex() getFieldMap() my...@1.get(1) my...@2.get(1) my...@3.get(value) getIndex() getIndex() Ok, getValue() isn't called, I can work with this, I can make all my keys numbers, if I detect a non-number I just route the call to getValue() I think since it implements a map, .value get interpreted as get(value); During set getFieldMap() my...@1.get(1) my...@2.get(1) This I can't work with since setValue() isn't called anywhere. I had bad experience with more complex ONGL expressions like the following in own applications (other issues with that are registering typeConverters and validators): s:textfield name=wonky['1'].value/ s:textfield name=wonky['1']['9'].value/ s:textfield name=wonky['1'].value['9'].value/ Usually I define several maps in the action, like this: MapuserId, gameConsole gamerConsoles MapuserId, type gamerConsoleTypes MapuserId, gameId gamerGames ... Regards, Christoph My case is logically like this Imagine these data structure gamer: userId gameConsole type game: gameId gameName A game is associated to a gameConsole There are 2 types of gamers, for a type = CASUAL gamer, there are no games associated for a type = AVERAGE gamer, you can have games asscociated Data as follows userId: 1 gameConsole: nintendo type: CASUAL userId: 2 gameConsole: playstation type: AVERAGE gameId: 9, gameName: Gran Turismo gameId: 10, gameName: Winning Eleven Imagine I have a bean class called Wonky (that implements java.util.Map) that behaves like this Type = CASUAL Wonky.get(String key) will return a Wonky instance, if you then call getValue() on this instance it will return a gameConsole name (e.g. nintendo or playstation) Type = AVERAGE Wonky.get(String key) will return a Wonky instance, if you then call get(String key) on this instance it will return another Wonky instance, if you then call getValue() on this instance it will return a game name (e.g Gran Turismo or Winning Eleven) I want to be able to do this on a form s:textfield name=wonky['1'].value/ During get: shows the gameConsole of gamer with userId = 1 During set: sets the gameConsole for gamer with userId = 1 s:textfield name=wonky['1']['9'].value/ During get: shows the game with id = 9 associated with gamer with userId = 1 During set: set the game name with id = 9 associated with gamer with userId = 1 alternatively, I'm ok with this idea as well s:textfield name=wonky['1'].value['9'].value/ In this case Wonky behaves like this for Type = AVERAGE Wonky.get(String key) - Wonky instance, getValue() - return this; get(String key) - another Wonky instance, getValue() on that instance will return a game name (e.g Gran Turismo or Winning Eleven) I did more investigation Consider this code class MyMap implements Map { private Long id; public MyMap(Long id) { this.id = id; } ... @Override public Object get(Object key) { System.out.println(MyMap@ + id + .get( + key + )); return new MyMap(id + 1); } public String getValue() { System.out.println(MyMap@ + id + .getValue()); return Long.toString(id); } public void setValue(String value) { System.out.println(MyMap@ + id + .setValue( + value + )); } } On my action class public MyMap getFieldMap() { System.out.println( getFieldMap()); MyMap map = new MyMap(1L); return map; } public void setFieldMap(MyMap map) { } private Long index = 1L; public Long getIndex() { System.out.println( getIndex()); return index; } public void setIndex(Long index) { System.out.println( setIndex( + index + )); this.index = index; } On my jsp s:form action=... s:textfield name=fieldMap['%{index}']['%{index}'].value/ s:submit/ /s:form Result is During get getIndex() getIndex() getFieldMap() my...@1.get(1) my...@2.get(1) my...@3.get(value) getIndex() getIndex() Ok, getValue() isn't called, I can work with this, I can make all my keys numbers, if I detect a non-number I just route the call to getValue() I think since it implements a map, .value get interpreted as get(value); During set getFieldMap() my...@1.get(1) my...@2.get(1) This I can't work with since setValue() isn't called anywhere. On Tue, May 20, 2014 at 3:02 PM, Christoph Nenning christoph.nenn...@lex-com.net wrote: Question: According to OGNL ( http://commons.apache.org/proper/commons-ognl/language-guide.html) under heading JavaBeans Indexed Properties and OGNL Object Indexed Properties, getFieldWithIndex(int index) should be called, but it isn't, same goes with getFieldWithKey(String key), why ? I looked at the latest OGNL source code (not the one I'm using since I couldn't find the source code for version 3.0.6) hoping if I could spot a method where it tries different get/set methods. Tried setting breakpoints at OGNLRuntime
Re: OGNL Indexed and Object Indexed Properties
(MyMap@ + id + .setValue( + value + )); } } On my action class public MyMap getFieldMap() { System.out.println( getFieldMap()); MyMap map = new MyMap(1L); return map; } public void setFieldMap(MyMap map) { } private Long index = 1L; public Long getIndex() { System.out.println( getIndex()); return index; } public void setIndex(Long index) { System.out.println( setIndex( + index + )); this.index = index; } On my jsp s:form action=... s:textfield name=fieldMap['%{index}']['%{index}'].value/ s:submit/ /s:form Result is During get getIndex() getIndex() getFieldMap() my...@1.get(1) my...@2.get(1) my...@3.get(value) getIndex() getIndex() Ok, getValue() isn't called, I can work with this, I can make all my keys numbers, if I detect a non-number I just route the call to getValue() I think since it implements a map, .value get interpreted as get(value); During set getFieldMap() my...@1.get(1) my...@2.get(1) This I can't work with since setValue() isn't called anywhere. On Tue, May 20, 2014 at 3:02 PM, Christoph Nenning christoph.nenn...@lex-com.net wrote: Question: According to OGNL ( http://commons.apache.org/proper/commons-ognl/language-guide.html) under heading JavaBeans Indexed Properties and OGNL Object Indexed Properties, getFieldWithIndex(int index) should be called, but it isn't, same goes with getFieldWithKey(String key), why ? I looked at the latest OGNL source code (not the one I'm using since I couldn't find the source code for version 3.0.6) hoping if I could spot a method where it tries different get/set methods. Tried setting breakpoints at OGNLRuntime, ObjectPropertyAccessor but coulnd't see anything obvious. At the moment I have a few workarounds 1. Use the ones that are working, i.e. getFieldList() and getFieldMap(), implementing my own List and Map Another way would be OGNL method call syntax: s:property value=getFieldWithIndex(1)/ 2. Use java.util.List getList() and setList(java.util.List list), struts will create a new List and populate accordingly in the order in which they were submitted in the form The issue with this is, if I have a pair or triplet of things that go hand in hand, then it gets complex. e.g. name and address where address is optional in the form the user put name1, address1, name2 (with no address), and name3, address3 struts calls setName() with List containing name1, name2, name3 it also calls setAddress() with List containing address1, address3 There is no way the code can then figure out that that address3 is actually associated with name3 In the past I was able to get around this by supplying another data structure that tells the code which address belongs to which name but it involves JavaScript, and it gets messy quite quickly. struts/OGNL can store mulitple values in a map. You could use name as key and address as value: address: s:textfield name=map['name'] / That works well when you know names during get phase (when users cannot change names on that particular form). If users can also enter names here, you need javascript. Another use case of that map syntax is when the number of input fileds is dynamic. 3. Bypass struts, in the get phase (showing the form) just use straight html combined with struts tags, during the set phase (submitting the form), will just get the parameters using HttpServletRequest e.g. during show form input type=text name=whateverName value=s:property value=whateverValue// instead of s:textfield ... / This is always possible, of course. It means you have to generate parameter names during GET and parse them on POST. Usually I try to avoid this in my applications but there are (rare) cases I need to do that. If you do so, you have to think of how you do validation. You can still use struts validation when you generate the same parameter names again (in validate() method) and use s:fieldError tags with the same generated names. Regards, Christoph OGNL Indexed and Object Indexed Properties Hi, I'm wondering why this code is not working. I'm using struts 2.3.16.1 and ognl 3.0.6. In my action class I have this public String[] getFieldArray() { System.out.println( getFieldArray()); return null; } public void setFieldArray(String[] array) { } public MyListString getFieldList() { System.out.println( getFieldList()); return new MyListString(); } public void setFieldList(MyListString list) { } public MyMapString, String getFieldMap() { System.out.println( getFieldMap
Re: Validation of indexed properties
Hi Cielpa, 'Invalid property' would suggest that your form does not contain the property searchList. It is difficult to tell without a bit of background and seeing some code. Can you explain what you are doing and show me your struts-config.xml file. By the way, your form should be declared as a DynaValidatorForm. There is no such thing as a DynaValidatorActionForm. For example.. form-bean name=myForm type=org.apache.struts.action.DynaValidatorForm form-property name=searchList type=java.util.ArrayList/ /form-bean Hugh Cielpa wrote: Hey, I have a similar problem with DynaValidatorActionForm. It says that invalid property when i have a ArrayList in the form-property name=searchList type=java.util.ArrayList/ in the form-bean declaration. Any idea? Thanks and your help is appreciated. Silpa hugh11 wrote: I've got a problem relating to the validation of indexed properties in Struts 1.1 I get the following error message when I try to access an ArrayList of students in my DynaValidatorForm root cause java.lang.IndexOutOfBoundsException: Index: 1, Size: 0 java.util.ArrayList.RangeCheck(Unknown Source) java.util.ArrayList.get(Unknown Source) org.apache.struts.action.DynaActionForm.get(DynaActionForm.java:298) Here is some background to the problem... In my session I have an ArrayList called studentsList of objects of type experiment.mybeans.Student. A Student object has getter and setter methods for id, year and gradeAverage. In my students.jsp I create a table by iterating through my student objects like this... c:forEach var=students items=${sessionScope.group.studentsList} trtdhtml:text indexed=true name=students property=id//td tdhtml:text indexed=true name=students property=year//td tdhtml:text indexed=true name=students property=gradeAverage//td/tr /c:forEach As you can see the table contains empty text boxes and I would like to validate these have been filled in, so in struts-config.xml I create my dynavalidatorform as follows... form-bean name=studentsForm type=org.apache.struts.validator.DynaValidatorForm form-property name=students type=java.util.ArrayList / /form-bean And in validation.xml I place my validation rules... form name=studentsForm field property=id indexedListProperty=students depends=required arg0 key=error.studentid.required/ /field field property=year indexedListProperty=students depends=required arg0 key=error.studentyear.required/ /field field property=gradeAverage indexedListProperty=students depends=required arg0 key=error.studentgrade.required/ /field /form Now here is where things start to go a bit pear-shaped I have read somewhere online that I need to populate the form ArrayList before I get to my jsp page. So I have created an action class called PreStudentsAction.java which takes the student ArrayList out of the session and assigns it to the student ArrayList in the form before forwarding to the students.jsp page... public class PreStudentsAction extends Action{ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { DynaValidatorForm myForm = (DynaValidatorForm)form; Group group = (Group)request.getSession().getAttribute(group); ArrayListStudent students = group.getStudentsList(); myForm.set(students, students); return (mapping.findForward(success)); } } Finally when I run my application my table is displayed but when I fill in the table and press submit I get the IndexOutOfBounds error. It appears to me that the student ArrayList in the form remains empty and that my Action class was unsuccessful in populating the form's ArrayList. Can anybody see what I'm doing wrong? -- View this message in context: http://old.nabble.com/Validation-of-indexed-properties-tp27493794p27720862.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Validation of indexed properties
Sorry Cielpa, my mistake. Turns out there is such a thing as a DynaValidatorActionForm. Shows how much I know. Hugh hugh11 wrote: Hi Cielpa, 'Invalid property' would suggest that your form does not contain the property searchList. It is difficult to tell without a bit of background and seeing some code. Can you explain what you are doing and show me your struts-config.xml file. By the way, your form should be declared as a DynaValidatorForm. There is no such thing as a DynaValidatorActionForm. For example.. form-bean name=myForm type=org.apache.struts.action.DynaValidatorForm form-property name=searchList type=java.util.ArrayList/ /form-bean Hugh Cielpa wrote: Hey, I have a similar problem with DynaValidatorActionForm. It says that invalid property when i have a ArrayList in the form-property name=searchList type=java.util.ArrayList/ in the form-bean declaration. Any idea? Thanks and your help is appreciated. Silpa hugh11 wrote: I've got a problem relating to the validation of indexed properties in Struts 1.1 I get the following error message when I try to access an ArrayList of students in my DynaValidatorForm root cause java.lang.IndexOutOfBoundsException: Index: 1, Size: 0 java.util.ArrayList.RangeCheck(Unknown Source) java.util.ArrayList.get(Unknown Source) org.apache.struts.action.DynaActionForm.get(DynaActionForm.java:298) Here is some background to the problem... In my session I have an ArrayList called studentsList of objects of type experiment.mybeans.Student. A Student object has getter and setter methods for id, year and gradeAverage. In my students.jsp I create a table by iterating through my student objects like this... c:forEach var=students items=${sessionScope.group.studentsList} trtdhtml:text indexed=true name=students property=id//td tdhtml:text indexed=true name=students property=year//td tdhtml:text indexed=true name=students property=gradeAverage//td/tr /c:forEach As you can see the table contains empty text boxes and I would like to validate these have been filled in, so in struts-config.xml I create my dynavalidatorform as follows... form-bean name=studentsForm type=org.apache.struts.validator.DynaValidatorForm form-property name=students type=java.util.ArrayList / /form-bean And in validation.xml I place my validation rules... form name=studentsForm field property=id indexedListProperty=students depends=required arg0 key=error.studentid.required/ /field field property=year indexedListProperty=students depends=required arg0 key=error.studentyear.required/ /field field property=gradeAverage indexedListProperty=students depends=required arg0 key=error.studentgrade.required/ /field /form Now here is where things start to go a bit pear-shaped I have read somewhere online that I need to populate the form ArrayList before I get to my jsp page. So I have created an action class called PreStudentsAction.java which takes the student ArrayList out of the session and assigns it to the student ArrayList in the form before forwarding to the students.jsp page... public class PreStudentsAction extends Action{ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { DynaValidatorForm myForm = (DynaValidatorForm)form; Group group = (Group)request.getSession().getAttribute(group); ArrayListStudent students = group.getStudentsList(); myForm.set(students, students); return (mapping.findForward(success)); } } Finally when I run my application my table is displayed but when I fill in the table and press submit I get the IndexOutOfBounds error. It appears to me that the student ArrayList in the form remains empty and that my Action class was unsuccessful in populating the form's ArrayList. Can anybody see what I'm doing wrong? -- View this message in context: http://old.nabble.com/Validation-of-indexed-properties-tp27493794p27720956.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Validation of indexed properties
Hey, I have a similar problem with DynaValidatorActionForm. It says that invalid property when i have a ArrayList in the form-property name=searchList type=java.util.ArrayList/ in the form-bean declaration. Any idea? Thanks and your help is appreciated. Silpa hugh11 wrote: I've got a problem relating to the validation of indexed properties in Struts 1.1 I get the following error message when I try to access an ArrayList of students in my DynaValidatorForm root cause java.lang.IndexOutOfBoundsException: Index: 1, Size: 0 java.util.ArrayList.RangeCheck(Unknown Source) java.util.ArrayList.get(Unknown Source) org.apache.struts.action.DynaActionForm.get(DynaActionForm.java:298) Here is some background to the problem... In my session I have an ArrayList called studentsList of objects of type experiment.mybeans.Student. A Student object has getter and setter methods for id, year and gradeAverage. In my students.jsp I create a table by iterating through my student objects like this... c:forEach var=students items=${sessionScope.group.studentsList} trtdhtml:text indexed=true name=students property=id//td tdhtml:text indexed=true name=students property=year//td tdhtml:text indexed=true name=students property=gradeAverage//td/tr /c:forEach As you can see the table contains empty text boxes and I would like to validate these have been filled in, so in struts-config.xml I create my dynavalidatorform as follows... form-bean name=studentsForm type=org.apache.struts.validator.DynaValidatorForm form-property name=students type=java.util.ArrayList / /form-bean And in validation.xml I place my validation rules... form name=studentsForm field property=id indexedListProperty=students depends=required arg0 key=error.studentid.required/ /field field property=year indexedListProperty=students depends=required arg0 key=error.studentyear.required/ /field field property=gradeAverage indexedListProperty=students depends=required arg0 key=error.studentgrade.required/ /field /form Now here is where things start to go a bit pear-shaped I have read somewhere online that I need to populate the form ArrayList before I get to my jsp page. So I have created an action class called PreStudentsAction.java which takes the student ArrayList out of the session and assigns it to the student ArrayList in the form before forwarding to the students.jsp page... public class PreStudentsAction extends Action{ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { DynaValidatorForm myForm = (DynaValidatorForm)form; Group group = (Group)request.getSession().getAttribute(group); ArrayListStudent students = group.getStudentsList(); myForm.set(students, students); return (mapping.findForward(success)); } } Finally when I run my application my table is displayed but when I fill in the table and press submit I get the IndexOutOfBounds error. It appears to me that the student ArrayList in the form remains empty and that my Action class was unsuccessful in populating the form's ArrayList. Can anybody see what I'm doing wrong? -- View this message in context: http://old.nabble.com/Validation-of-indexed-properties-tp27493794p27714507.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Validation of indexed properties
I've got a problem relating to the validation of indexed properties in Struts 1.1 I get the following error message when I try to access an ArrayList of students in my DynaValidatorForm root cause java.lang.IndexOutOfBoundsException: Index: 1, Size: 0 java.util.ArrayList.RangeCheck(Unknown Source) java.util.ArrayList.get(Unknown Source) org.apache.struts.action.DynaActionForm.get(DynaActionForm.java:298) Here is some background to the problem... In my session I have an ArrayList called studentsList of objects of type experiment.mybeans.Student. A Student object has getter and setter methods for id, year and gradeAverage. In my students.jsp I create a table by iterating through my student objects like this... c:forEach var=students items=${sessionScope.group.studentsList} trtdhtml:text indexed=true name=students property=id//td tdhtml:text indexed=true name=students property=year//td tdhtml:text indexed=true name=students property=gradeAverage//td/tr /c:forEach As you can see the table contains empty text boxes and I would like to validate these have been filled in, so in struts-config.xml I create my dynavalidatorform as follows... form-bean name=studentsForm type=org.apache.struts.validator.DynaValidatorForm form-property name=students type=java.util.ArrayList / /form-bean And in validation.xml I place my validation rules... form name=studentsForm field property=id indexedListProperty=students depends=required arg0 key=error.studentid.required/ /field field property=year indexedListProperty=students depends=required arg0 key=error.studentyear.required/ /field field property=gradeAverage indexedListProperty=students depends=required arg0 key=error.studentgrade.required/ /field /form Now here is where things start to go a bit pear-shaped I have read somewhere online that I need to populate the form ArrayList before I get to my jsp page. So I have created an action class called PreStudentsAction.java which takes the student ArrayList out of the session and assigns it to the student ArrayList in the form before forwarding to the students.jsp page... public class PreStudentsAction extends Action{ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { DynaValidatorForm myForm = (DynaValidatorForm)form; Group group = (Group)request.getSession().getAttribute(group); ArrayListStudent students = group.getStudentsList(); myForm.set(students, students); return (mapping.findForward(success)); } } Finally when I run my application my table is displayed but when I fill in the table and press submit I get the IndexOutOfBounds error. It appears to me that the student ArrayList in the form remains empty and that my Action class was unsuccessful in populating the form's ArrayList. Can anybody see what I'm doing wrong? -- View this message in context: http://old.nabble.com/Validation-of-indexed-properties-tp27493794p27493794.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Multiple Logic iterate tags and setting indexed properties
Yes, It worked. Thank you so much Nikhil. Nikhil Walvekar wrote: Hi Thanuja, Can you please try using input tag (if its allowed)? *logic:iterate name=bookInfoForm id=bookl property=bookLists indexId=i logic:iterate id=book name=bookl property=books indexId=j input type=checkbox name=bookLists[%= i %].books[%= j %].selected value=true bean:write name=book property=name / /logic:iterate /logic:iterate * I will suggest you first try it with fixed size list (both), so you can initialize list in form bean. Regards, Nikhil On Wed, Apr 15, 2009 at 5:07 AM, thanuja thanuja_jayal...@yahoo.com wrote: Hi Nikhil, Thanks for the suggestion. I tried, but it is still not working. I am using struts tags and instead of input. If my class structure was like the below one, then the values will be updated without any problem when the form submitted. The problem comes when I have two logic iterates(as shown in my earlier post). class BookList String bookListName boolean selected class BookInfoForm extends ActionForm{ ArrayListBookList bookLists; public BookList getBookl(int index){ return bookLists.get(index); } public void setBookl(int index,BookList element){ bookLists.set(index, element); } } logic:iterate name=bookInfoForm id=bookl property=bookLists indexId=i html:checkbox name=bookl property=selected indexed=true value=true / bean:write name=bookl property=bookListName / /logic:iterate Thanks, Thanuja Nikhil Walvekar wrote: Hi Thanuja, Your checkbox tag should be rendered as input type=checkbox name=bookLists[i].books[j].selected value=true I don't think logic:iterate supports property as indexed. Probably you can create above tag using values you have. bookLists[i].books[j].selected will be converted as getBookList().get(i).getBooks().get(j).setSelected(value) you will have to make sure that none of the getters return null object. Regards, Nikhil On Tue, Apr 14, 2009 at 7:04 AM, thanuja thanuja_jayal...@yahoo.com wrote: Hi, I am using one logic iterate tag inside another. The data set at the inner loop should update form bean. Following explains what i tried to do. This way the data displays as I expected. But when I select the check box it won't update the corresponding 'Book' object. (The form has list of 'BookList' objects. Each BookList object has set of Book objects. I wanted to mark Book as selected.) class BookList ArrayListBook books class Book String name boolean selected class BookInfoForm extends ActionForm{ ArrayListBookList bookLists; public BookList getBookl(int index){ return bookLists.get(index); } public void setBookl(int index,BookList element){ bookLists.set(index, element); } public Book getBook(int index){ return bookLists.get(?).getBooks().get(index); } public void setBook(int index,Book element){ bookLists.get(?).getBooks().set(index,element); } } logic:iterate name=bookInfoForm id=bookl property=bookLists indexId=i logic:iterate id=book name=bookl property=books indexId=j html:checkbox name=book property=selected indexed=true value=true / bean:write name=book property=name / /logic:iterate /logic:iterate Thanks in advance, Thanuja -- View this message in context: http://www.nabble.com/Multiple-Logic-iterate-tags-and-setting-indexed-properties-tp23031690p23031690.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- Nikhil -- View this message in context: http://www.nabble.com/Multiple-Logic-iterate-tags-and-setting-indexed-properties-tp23031690p23050006.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- Nikhil -- View this message in context: http://www.nabble.com/Multiple-Logic-iterate-tags-and-setting-indexed-properties-tp23031690p23083353.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Multiple Logic iterate tags and setting indexed properties
Hi Thanuja, Can you please try using input tag (if its allowed)? *logic:iterate name=bookInfoForm id=bookl property=bookLists indexId=i logic:iterate id=book name=bookl property=books indexId=j input type=checkbox name=bookLists[%= i %].books[%= j %].selected value=true bean:write name=book property=name / /logic:iterate /logic:iterate * I will suggest you first try it with fixed size list (both), so you can initialize list in form bean. Regards, Nikhil On Wed, Apr 15, 2009 at 5:07 AM, thanuja thanuja_jayal...@yahoo.com wrote: Hi Nikhil, Thanks for the suggestion. I tried, but it is still not working. I am using struts tags and instead of input. If my class structure was like the below one, then the values will be updated without any problem when the form submitted. The problem comes when I have two logic iterates(as shown in my earlier post). class BookList String bookListName boolean selected class BookInfoForm extends ActionForm{ ArrayListBookList bookLists; public BookList getBookl(int index){ return bookLists.get(index); } public void setBookl(int index,BookList element){ bookLists.set(index, element); } } logic:iterate name=bookInfoForm id=bookl property=bookLists indexId=i html:checkbox name=bookl property=selected indexed=true value=true / bean:write name=bookl property=bookListName / /logic:iterate Thanks, Thanuja Nikhil Walvekar wrote: Hi Thanuja, Your checkbox tag should be rendered as input type=checkbox name=bookLists[i].books[j].selected value=true I don't think logic:iterate supports property as indexed. Probably you can create above tag using values you have. bookLists[i].books[j].selected will be converted as getBookList().get(i).getBooks().get(j).setSelected(value) you will have to make sure that none of the getters return null object. Regards, Nikhil On Tue, Apr 14, 2009 at 7:04 AM, thanuja thanuja_jayal...@yahoo.com wrote: Hi, I am using one logic iterate tag inside another. The data set at the inner loop should update form bean. Following explains what i tried to do. This way the data displays as I expected. But when I select the check box it won't update the corresponding 'Book' object. (The form has list of 'BookList' objects. Each BookList object has set of Book objects. I wanted to mark Book as selected.) class BookList ArrayListBook books class Book String name boolean selected class BookInfoForm extends ActionForm{ ArrayListBookList bookLists; public BookList getBookl(int index){ return bookLists.get(index); } public void setBookl(int index,BookList element){ bookLists.set(index, element); } public Book getBook(int index){ return bookLists.get(?).getBooks().get(index); } public void setBook(int index,Book element){ bookLists.get(?).getBooks().set(index,element); } } logic:iterate name=bookInfoForm id=bookl property=bookLists indexId=i logic:iterate id=book name=bookl property=books indexId=j html:checkbox name=book property=selected indexed=true value=true / bean:write name=book property=name / /logic:iterate /logic:iterate Thanks in advance, Thanuja -- View this message in context: http://www.nabble.com/Multiple-Logic-iterate-tags-and-setting-indexed-properties-tp23031690p23031690.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- Nikhil -- View this message in context: http://www.nabble.com/Multiple-Logic-iterate-tags-and-setting-indexed-properties-tp23031690p23050006.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- Nikhil
Re: Multiple Logic iterate tags and setting indexed properties
Hi Nikhil, Thanks for the suggestion. I tried, but it is still not working. I am using struts tags and instead of input. If my class structure was like the below one, then the values will be updated without any problem when the form submitted. The problem comes when I have two logic iterates(as shown in my earlier post). class BookList String bookListName boolean selected class BookInfoForm extends ActionForm{ ArrayListBookList bookLists; public BookList getBookl(int index){ return bookLists.get(index); } public void setBookl(int index,BookList element){ bookLists.set(index, element); } } logic:iterate name=bookInfoForm id=bookl property=bookLists indexId=i html:checkbox name=bookl property=selected indexed=true value=true / bean:write name=bookl property=bookListName / /logic:iterate Thanks, Thanuja Thanuja Nikhil Walvekar wrote: Hi Thanuja, Your checkbox tag should be rendered as input type=checkbox name=bookLists[i].books[j].selected value=true I don't think logic:iterate supports property as indexed. Probably you can create above tag using values you have. bookLists[i].books[j].selected will be converted as getBookList().get(i).getBooks().get(j).setSelected(value) you will have to make sure that none of the getters return null object. Regards, Nikhil On Tue, Apr 14, 2009 at 7:04 AM, thanuja thanuja_jayal...@yahoo.com wrote: Hi, I am using one logic iterate tag inside another. The data set at the inner loop should update form bean. Following explains what i tried to do. This way the data displays as I expected. But when I select the check box it won't update the corresponding 'Book' object. (The form has list of 'BookList' objects. Each BookList object has set of Book objects. I wanted to mark Book as selected.) class BookList ArrayListBook books class Book String name boolean selected class BookInfoForm extends ActionForm{ ArrayListBookList bookLists; public BookList getBookl(int index){ return bookLists.get(index); } public void setBookl(int index,BookList element){ bookLists.set(index, element); } public Book getBook(int index){ return bookLists.get(?).getBooks().get(index); } public void setBook(int index,Book element){ bookLists.get(?).getBooks().set(index,element); } } logic:iterate name=bookInfoForm id=bookl property=bookLists indexId=i logic:iterate id=book name=bookl property=books indexId=j html:checkbox name=book property=selected indexed=true value=true / bean:write name=book property=name / /logic:iterate /logic:iterate Thanks in advance, Thanuja -- View this message in context: http://www.nabble.com/Multiple-Logic-iterate-tags-and-setting-indexed-properties-tp23031690p23031690.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- Nikhil -- View this message in context: http://www.nabble.com/Multiple-Logic-iterate-tags-and-setting-indexed-properties-tp23031690p23050006.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Multiple Logic iterate tags and setting indexed properties
Hi, I am using one logic iterate tag inside another. The data set at the inner loop should update form bean. Following explains what i tried to do. This way the data displays as I expected. But when I select the check box it won't update the corresponding 'Book' object. (The form has list of 'BookList' objects. Each BookList object has set of Book objects. I wanted to mark Book as selected.) class BookList ArrayListBook books class Book String name boolean selected class BookInfoForm extends ActionForm{ ArrayListBookList bookLists; public BookList getBookl(int index){ return bookLists.get(index); } public void setBookl(int index,BookList element){ bookLists.set(index, element); } public Book getBook(int index){ return bookLists.get(?).getBooks().get(index); } public void setBook(int index,Book element){ bookLists.get(?).getBooks().set(index,element); } } logic:iterate name=bookInfoForm id=bookl property=bookLists indexId=i logic:iterate id=book name=bookl property=books indexId=j html:checkbox name=book property=selected indexed=true value=true / bean:write name=book property=name / /logic:iterate /logic:iterate Thanks in advance, Thanuja -- View this message in context: http://www.nabble.com/Multiple-Logic-iterate-tags-and-setting-indexed-properties-tp23031690p23031690.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Multiple Logic iterate tags and setting indexed properties
Hi Thanuja, Your checkbox tag should be rendered as input type=checkbox name=bookLists[i].books[j].selected value=true I don't think logic:iterate supports property as indexed. Probably you can create above tag using values you have. bookLists[i].books[j].selected will be converted as getBookList().get(i).getBooks().get(j).setSelected(value) you will have to make sure that none of the getters return null object. Regards, Nikhil On Tue, Apr 14, 2009 at 7:04 AM, thanuja thanuja_jayal...@yahoo.com wrote: Hi, I am using one logic iterate tag inside another. The data set at the inner loop should update form bean. Following explains what i tried to do. This way the data displays as I expected. But when I select the check box it won't update the corresponding 'Book' object. (The form has list of 'BookList' objects. Each BookList object has set of Book objects. I wanted to mark Book as selected.) class BookList ArrayListBook books class Book String name boolean selected class BookInfoForm extends ActionForm{ ArrayListBookList bookLists; public BookList getBookl(int index){ return bookLists.get(index); } public void setBookl(int index,BookList element){ bookLists.set(index, element); } public Book getBook(int index){ return bookLists.get(?).getBooks().get(index); } public void setBook(int index,Book element){ bookLists.get(?).getBooks().set(index,element); } } logic:iterate name=bookInfoForm id=bookl property=bookLists indexId=i logic:iterate id=book name=bookl property=books indexId=j html:checkbox name=book property=selected indexed=true value=true / bean:write name=book property=name / /logic:iterate /logic:iterate Thanks in advance, Thanuja -- View this message in context: http://www.nabble.com/Multiple-Logic-iterate-tags-and-setting-indexed-properties-tp23031690p23031690.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- Nikhil
Indexed properties in forms
Hi there, I am trying to migrate a form population module from struts1 to struts2 and I am not sure if struts2 supports indexed/mapped value properties. After reading OGNL docs I see that indexed properties are supported both with ints and objects. I guess they refer just to red de properties, not to set them in the action... so I am trying: s:textfield label=%{name} name='fieldEntry[%{id}]' / Where id is an integer. My action has the method: public void setFieldEntry(String fieldId, String value){} (I've tried fieldID with int, Integer and String) (Also I've tried String value and String[] value just in case it expects an array of strings) When I submit the form I get: 2009-02-11 02:14:49,195 WARN [com.opensymphony.xwork2.ognl.OgnlValueStack] Could not find property [struts.valueStack] 2009-02-11 02:14:49,198 INFO [STDOUT] ognl.OgnlException: target is null for setProperty(null, 1, [Ljava.lang.String;@410ef400) 2009-02-11 02:14:49,198 INFO [STDOUT] at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:1651) 2009-02-11 02:14:49,198 INFO [STDOUT] at ognl.ASTProperty.setValueBody(ASTProperty.java:101) 2009-02-11 02:14:49,199 INFO [STDOUT] at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177) 2009-02-11 02:14:49,199 INFO [STDOUT] at ognl.SimpleNode.setValue(SimpleNode.java:246) 2009-02-11 02:14:49,199 INFO [STDOUT] at ognl.ASTChain.setValueBody(ASTChain.java:172) 2009-02-11 02:14:49,199 INFO [STDOUT] at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177) 2009-02-11 02:14:49,199 INFO [STDOUT] at ognl.SimpleNode.setValue(SimpleNode.java:246) 2009-02-11 02:14:49,199 INFO [STDOUT] at ognl.Ognl.setValue(Ognl.java:476) 2009-02-11 02:14:49,199 INFO [STDOUT] at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:192) Thanks for any help -- View this message in context: http://www.nabble.com/Indexed-properties-in-forms-tp21946572p21946572.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Indexed properties in forms
You just need a collection/map getter/setter in the action, you don't need an indexed setter. http://struts.apache.org/2.x/docs/type-conversion.html#TypeConversion-CollectionandMapSupport Dave Ignacio de Córdoba wrote: Hi there, I am trying to migrate a form population module from struts1 to struts2 and I am not sure if struts2 supports indexed/mapped value properties. After reading OGNL docs I see that indexed properties are supported both with ints and objects. I guess they refer just to red de properties, not to set them in the action... so I am trying: s:textfield label=%{name} name='fieldEntry[%{id}]' / Where id is an integer. My action has the method: public void setFieldEntry(String fieldId, String value){} (I've tried fieldID with int, Integer and String) (Also I've tried String value and String[] value just in case it expects an array of strings) When I submit the form I get: 2009-02-11 02:14:49,195 WARN [com.opensymphony.xwork2.ognl.OgnlValueStack] Could not find property [struts.valueStack] 2009-02-11 02:14:49,198 INFO [STDOUT] ognl.OgnlException: target is null for setProperty(null, 1, [Ljava.lang.String;@410ef400) 2009-02-11 02:14:49,198 INFO [STDOUT] at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:1651) 2009-02-11 02:14:49,198 INFO [STDOUT] at ognl.ASTProperty.setValueBody(ASTProperty.java:101) 2009-02-11 02:14:49,199 INFO [STDOUT] at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177) 2009-02-11 02:14:49,199 INFO [STDOUT] at ognl.SimpleNode.setValue(SimpleNode.java:246) 2009-02-11 02:14:49,199 INFO [STDOUT] at ognl.ASTChain.setValueBody(ASTChain.java:172) 2009-02-11 02:14:49,199 INFO [STDOUT] at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177) 2009-02-11 02:14:49,199 INFO [STDOUT] at ognl.SimpleNode.setValue(SimpleNode.java:246) 2009-02-11 02:14:49,199 INFO [STDOUT] at ognl.Ognl.setValue(Ognl.java:476) 2009-02-11 02:14:49,199 INFO [STDOUT] at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:192) Thanks for any help - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Radio button default checked with Indexed properties
Hi, How can I get a radio button checked by default using indexed properties? I read in forums to do it in the reset method of the ActionForm, but dont know exactly how to do it... In my jsp I render X radio buttons, where X is the number of questions saved in the request Bean choices in My action class, I dont render them as separated radio buttons, here the code: logic:iterate id=choice name=choices scope=request html:radio property=control idName=choice value=value/ bean:write name=choice property=label/ -- (X radio buttons) /logic:iterate In the action form I only have get and set methods for variable control: getControl(), setControl() Everything workd fine, but need to get the radio checked by default to avoid a java error/exception if the user clicks the form Which code or what should I do? Thanks in advance guys ;)
Re: Problems with Indexed Properties, Hidden Values and Logic Iterate Tag
Anyone can help me, please? Thanks. cacodemon79 wrote: Hi to all. I'm using Struts 1.3, Tomcat 6.0 and Eclipse. I have a problem with Indexed Properties. I have a jsp that should save hidden values and pass it to the linked Action. I show you my code. JSP PAGE logic:notEmpty name=creazioneProfiloUtenteForm property=listaSport html:select property=sport styleId=sport o_n_c_h_a_n_g_e=javascript:submitForm('creazioneProfiloUtenteForm','caricamentoRuoliAttributiSport.do') html:optionsCollection property=listaSport / /html:select logic:iterate id=hSportBean name=creazioneProfiloUtenteForm property=listaSport html:hidden name=hSportBean property=label indexed=true / html:hidden name=hSportBean property=value indexed=true / /logic:iterate /logic:notEmpty where - 'listaSport' is a list containing a list of sports. This list is correctly populated by the previous Action through 'select' and 'optionsCollection' tags. - 'hSportBean' is a LabelValueBean list where I have to save the select options. *** ACTION FORM *** public class CreazioneProfiloUtenteForm extends ActionForm { private String sport; private ArrayList listaSport; private ArrayList listaRuoli; private Object[] ruoliSelezionati; public ActionErrors validate(ActionMapping mapping,HttpServletRequest request) { return null; } public void reset(ActionMapping mapping, HttpServletRequest request) { } public LabelValueBean getHSportBean(int index) { if(this.listaSport == null) { this.listaSport = new ArrayList(); } while(index = this.listaSport.size()) { this.listaSport.add(new LabelValueBean()); } return (LabelValueBean) listaSport.get(index); } public String getSport() { return sport; } public void setSport(String sport) { this.sport = sport; } public ArrayList getListaSport() { return listaSport; } public void setListaSport(ArrayList listaSport) { this.listaSport = listaSport; } public ArrayList getListaRuoli() { return listaRuoli; } public void setListaRuoli(ArrayList listaRuoli) { this.listaRuoli = listaRuoli; } public Object[] getRuoliSelezionati() { return ruoliSelezionati; } public void setRuoliSelezionati(Object[] ruoliSelezionati) { this.ruoliSelezionati = ruoliSelezionati; } } ** ACTION ** public class CaricamentoRuoliAttributiSportAction extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response) { CreazioneProfiloUtenteForm creazioneProfiloUtenteForm = (CreazioneProfiloUtenteForm) form;// TODO Auto-generated method stub sportSelezionato = creazioneProfiloUtenteForm.getSport(); //HERE I HAVE TO LOAD HIDDEN VALUES SAVED IN JSP PAGE ... ... } } The problem is that I can't load in Action the hidden values saved in the jsp page. I tried to print the values received System.out.println((creazioneProfiloUtenteForm.getHSportBean(0)).getLabel()) System.out.println((creazioneProfiloUtenteForm.getHSportBean(0)).getValue()); but I always obtain null values (for all indexes). So, I don't know how to solve my problem. I also followed guidelines in: http://faq.javaranch.com/java/IndexedProperties http://faq.javaranch.com/java/IndexedProperties http://struts.apache.org/1.x/struts-taglib/indexedprops.html http://struts.apache.org/1.x/struts-taglib/indexedprops.html http://mail-archives.apache.org/mod_mbox/struts-user/200604.mbox/[EMAIL PROTECTED] http://mail-archives.apache.org/mod_mbox/struts-user/200604.mbox/[EMAIL PROTECTED] Can you help me? Thanks a lot in advance. -- View this message in context: http://www.nabble.com/Problems-with-Indexed-Properties%2C-Hidden-Values-and-Logic-Iterate-Tag-tp19593011p19616277.html Sent from the Struts - User mailing list archive at Nabble.com
Problems with Indexed Properties, Hidden Values and Logic Iterate Tag
Hi to all. I'm using Struts 1.3, Tomcat 6.0 and Eclipse. I have a problem with Indexed Properties. I have a jsp that should save hidden values and pass it to the linked Action. I show you my code. JSP PAGE logic:notEmpty name=creazioneProfiloUtenteForm property=listaSport html:select property=sport styleId=sport o_n_c_h_a_n_g_e=javascript:submitForm('creazioneProfiloUtenteForm','caricamentoRuoliAttributiSport.do') html:optionsCollection property=listaSport / /html:select logic:iterate id=hSportBean name=creazioneProfiloUtenteForm property=listaSport html:hidden name=hSportBean property=label indexed=true / html:hidden name=hSportBean property=value indexed=true / /logic:iterate /logic:notEmpty where - 'listaSport' is a list containing a list of sports. This list is correctly populated by the previous Action through 'select' and 'optionsCollection' tags. - 'hSportBean' is a LabelValueBean list where I have to save the select options. *** ACTION FORM *** public class CreazioneProfiloUtenteForm extends ActionForm { private String sport; private ArrayList listaSport; private ArrayList listaRuoli; private Object[] ruoliSelezionati; public ActionErrors validate(ActionMapping mapping,HttpServletRequest request) { return null; } public void reset(ActionMapping mapping, HttpServletRequest request) { } public LabelValueBean getHSportBean(int index) { if(this.listaSport == null) { this.listaSport = new ArrayList(); } while(index = this.listaSport.size()) { this.listaSport.add(new LabelValueBean()); } return (LabelValueBean) listaSport.get(index); } public String getSport() { return sport; } public void setSport(String sport) { this.sport = sport; } public ArrayList getListaSport() { return listaSport; } public void setListaSport(ArrayList listaSport) { this.listaSport = listaSport; } public ArrayList getListaRuoli() { return listaRuoli; } public void setListaRuoli(ArrayList listaRuoli) { this.listaRuoli = listaRuoli; } public Object[] getRuoliSelezionati() { return ruoliSelezionati; } public void setRuoliSelezionati(Object[] ruoliSelezionati) { this.ruoliSelezionati = ruoliSelezionati; } } ** ACTION ** public class CaricamentoRuoliAttributiSportAction extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response) { CreazioneProfiloUtenteForm creazioneProfiloUtenteForm = (CreazioneProfiloUtenteForm) form;// TODO Auto-generated method stub sportSelezionato = creazioneProfiloUtenteForm.getSport(); //HERE I HAVE TO LOAD HIDDEN VALUES SAVED IN JSP PAGE ... ... } } The problem is that I can't load in Action the hidden values saved in the jsp page. I tried to print the values received System.out.println((creazioneProfiloUtenteForm.getHSportBean(0)).getLabel()) System.out.println((creazioneProfiloUtenteForm.getHSportBean(0)).getValue()); but I always obtain null values (for all indexes). So, I don't know how to solve my problem. I also followed guidelines in: http://faq.javaranch.com/java/IndexedProperties http://faq.javaranch.com/java/IndexedProperties http://struts.apache.org/1.x/struts-taglib/indexedprops.html http://struts.apache.org/1.x/struts-taglib/indexedprops.html http://mail-archives.apache.org/mod_mbox/struts-user/200604.mbox/[EMAIL PROTECTED] http://mail-archives.apache.org/mod_mbox/struts-user/200604.mbox/[EMAIL PROTECTED] Can you help me? Thanks a lot in advance. -- View this message in context: http://www.nabble.com/Problems-with-Indexed-Properties%2C-Hidden-Values-and-Logic-Iterate-Tag-tp19593011p19593011.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail
RE: Struts 2 Indexed Properties
We're using Struts2, but I was using Struts1/JSTL tags. I've tried using Struts2 tags and it renders the same HTML anyway. I've been debugging through the code and it seems to be having a problem picking up the entry x-work conversion properties. It throws a null pointer in the log file, then carries on. When I've got more time, I'll spend it on trying to debug the problem. Either I've done something stupid, or the project I'm working on has some configuration that is screwing things up a bit. It's not a project that I've worked on from the start. Jishnu Viswanath wrote: Re you using struts 2 itself? If yes it would look something like this s:iterator value=listName status=stat input name=someName[s:property value='stat.index'/] /s:iterator The code you send looks like struts 1 Regards, Jishnu Viswanath Software Engineer *(+9180)41190300 - 222(Ext) ll * ( + 91 ) 9731209330ll Tavant Technologies Inc., www.tavant.com PEOPLE :: PASSION :: EXCELLENCE -Original Message- From: YAQ [mailto:[EMAIL PROTECTED] Sent: Monday, July 14, 2008 4:05 PM To: user@struts.apache.org Subject: Struts 2 Indexed Properties Hi, I'm having problem with Struts2 and indexed properties. The list in my action is not being updated. My JSP is something like: logic:iterate id=coverTypes name=questionnaireVO.coverTypesList indexId=index input type=hidden id=questionnaireInputVO.coverTypesList[c:out value=${index} /].key name=questionnaireInputVO.coverTypesList[c:out value=${index} /].key value=c:out value=${coverTypes.key.id} / / input type=hidden id=questionnaireInputVO.coverTypesList[c:out value=${index} /].agreementType.key name=questionnaireInputVO.coverTypesList[c:out value=${index} /].agreementType.key value=c:out value=${coverTypes.agreementType.key.id} / / /logic:iterate I've discovered I need an entry in the x-work conversion properties: Element_questionnaireInputVO.coverTypesList=com.mypath.CoverTypeVO CreateIfNull_questionnaireInputVO.coverTypesList=true But I am getting the following error: [2008-07-14 12:13:07,860] [.Transports : 2] DEBUG [com.opensymphony.xwork2.util.InstantiatingNullHandler ] : Entering nullPropertyValue [EMAIL PROTECTED], property=coverTypesList] [2008-07-14 12:13:07,860] [.Transports : 2] ERROR [com.opensymphony.xwork2.util.InstantiatingNullHandler ] : Could not create and/or set value back on to object org.springframework.beans.factory.BeanCreationException: Error creating bean with name '[Lcom.mypath.CoverTypeVO;': Could not resolve matching constructor at org.springframework.beans.factory.support.ConstructorResolver.autowireCo nstructor(ConstructorResolver.java:178) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac tory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:799) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac tory.autowire(AbstractAutowireCapableBeanFactory.java:255) at com.opensymphony.xwork2.spring.SpringObjectFactory.buildBean(SpringObjec tFactory.java:145) at com.opensymphony.xwork2.util.InstantiatingNullHandler.createObject(Insta ntiatingNullHandler.java:123) at com.opensymphony.xwork2.util.InstantiatingNullHandler.nullPropertyValue( InstantiatingNullHandler.java:104) at ognl.ASTProperty.getValueBody(ASTProperty.java:94) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at ognl.SimpleNode.getValue(SimpleNode.java:210) at ognl.ASTChain.setValueBody(ASTChain.java:168) at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177) at ognl.SimpleNode.setValue(SimpleNode.java:246) at ognl.Ognl.setValue(Ognl.java:476) at com.opensymphony.xwork2.util.OgnlUtil.setValue(OgnlUtil.java:186) at com.opensymphony.xwork2.util.OgnlValueStack.setValue(OgnlValueStack.java :158) at com.opensymphony.xwork2.util.OgnlValueStack.setValue(OgnlValueStack.java :146) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters( ParametersInterceptor.java:193) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(Pa rametersInterceptor.java:159) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(Me thodFilterInterceptor.java:86) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultAct ionInvocation.java:224) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultAct ionInvocation.java:223) at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerS tack.java:455) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvo cation.java:221
Struts 2 Indexed Properties
Hi, I'm having problem with Struts2 and indexed properties. The list in my action is not being updated. My JSP is something like: logic:iterate id=coverTypes name=questionnaireVO.coverTypesList indexId=index input type=hidden id=questionnaireInputVO.coverTypesList[c:out value=${index} /].key name=questionnaireInputVO.coverTypesList[c:out value=${index} /].key value=c:out value=${coverTypes.key.id} / / input type=hidden id=questionnaireInputVO.coverTypesList[c:out value=${index} /].agreementType.key name=questionnaireInputVO.coverTypesList[c:out value=${index} /].agreementType.key value=c:out value=${coverTypes.agreementType.key.id} / / /logic:iterate I've discovered I need an entry in the x-work conversion properties: Element_questionnaireInputVO.coverTypesList=com.mypath.CoverTypeVO CreateIfNull_questionnaireInputVO.coverTypesList=true But I am getting the following error: [2008-07-14 12:13:07,860] [.Transports : 2] DEBUG [com.opensymphony.xwork2.util.InstantiatingNullHandler ] : Entering nullPropertyValue [EMAIL PROTECTED], property=coverTypesList] [2008-07-14 12:13:07,860] [.Transports : 2] ERROR [com.opensymphony.xwork2.util.InstantiatingNullHandler ] : Could not create and/or set value back on to object org.springframework.beans.factory.BeanCreationException: Error creating bean with name '[Lcom.mypath.CoverTypeVO;': Could not resolve matching constructor at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:178) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:799) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowire(AbstractAutowireCapableBeanFactory.java:255) at com.opensymphony.xwork2.spring.SpringObjectFactory.buildBean(SpringObjectFactory.java:145) at com.opensymphony.xwork2.util.InstantiatingNullHandler.createObject(InstantiatingNullHandler.java:123) at com.opensymphony.xwork2.util.InstantiatingNullHandler.nullPropertyValue(InstantiatingNullHandler.java:104) at ognl.ASTProperty.getValueBody(ASTProperty.java:94) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at ognl.SimpleNode.getValue(SimpleNode.java:210) at ognl.ASTChain.setValueBody(ASTChain.java:168) at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177) at ognl.SimpleNode.setValue(SimpleNode.java:246) at ognl.Ognl.setValue(Ognl.java:476) at com.opensymphony.xwork2.util.OgnlUtil.setValue(OgnlUtil.java:186) at com.opensymphony.xwork2.util.OgnlValueStack.setValue(OgnlValueStack.java:158) at com.opensymphony.xwork2.util.OgnlValueStack.setValue(OgnlValueStack.java:146) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters(ParametersInterceptor.java:193) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:159) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) at com.ing.itrf.starlite.common.interceptor.StarliteSecurityInterceptor.intercept(StarliteSecurityInterceptor.java:54) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:170) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) at com.ing.itrf.starlite.common.interceptor.StarliteDebugInterceptor.intercept(StarliteDebugInterceptor.java:54) at com.opensymphony.xwork2.DefaultActionInvocation$2
Struts 2 Indexed Properties
Hi, I'm having problem with Struts2 and indexed properties. The list in my action is not being updated. My JSP is something like: logic:iterate id=coverTypes name=questionnaireVO.coverTypesList indexId=index input type=hidden id=questionnaireInputVO.coverTypesList[c:out value=${index} /].key name=questionnaireInputVO.coverTypesList[c:out value=${index} /].key value=c:out value=${coverTypes.key.id} / / input type=hidden id=questionnaireInputVO.coverTypesList[c:out value=${index} /].agreementType.key name=questionnaireInputVO.coverTypesList[c:out value=${index} /].agreementType.key value=c:out value=${coverTypes.agreementType.key.id} / / /logic:iterate I've discovered I need an entry in the x-work conversion properties: Element_questionnaireInputVO.coverTypesList=com.mypath.CoverTypeVO CreateIfNull_questionnaireInputVO.coverTypesList=true But I am getting the following error: [2008-07-14 12:13:07,860] [.Transports : 2] DEBUG [com.opensymphony.xwork2.util.InstantiatingNullHandler ] : Entering nullPropertyValue [EMAIL PROTECTED], property=coverTypesList] [2008-07-14 12:13:07,860] [.Transports : 2] ERROR [com.opensymphony.xwork2.util.InstantiatingNullHandler ] : Could not create and/or set value back on to object org.springframework.beans.factory.BeanCreationException: Error creating bean with name '[Lcom.mypath.CoverTypeVO;': Could not resolve matching constructor at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:178) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:799) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowire(AbstractAutowireCapableBeanFactory.java:255) at com.opensymphony.xwork2.spring.SpringObjectFactory.buildBean(SpringObjectFactory.java:145) at com.opensymphony.xwork2.util.InstantiatingNullHandler.createObject(InstantiatingNullHandler.java:123) at com.opensymphony.xwork2.util.InstantiatingNullHandler.nullPropertyValue(InstantiatingNullHandler.java:104) at ognl.ASTProperty.getValueBody(ASTProperty.java:94) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at ognl.SimpleNode.getValue(SimpleNode.java:210) at ognl.ASTChain.setValueBody(ASTChain.java:168) at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177) at ognl.SimpleNode.setValue(SimpleNode.java:246) at ognl.Ognl.setValue(Ognl.java:476) at com.opensymphony.xwork2.util.OgnlUtil.setValue(OgnlUtil.java:186) at com.opensymphony.xwork2.util.OgnlValueStack.setValue(OgnlValueStack.java:158) at com.opensymphony.xwork2.util.OgnlValueStack.setValue(OgnlValueStack.java:146) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters(ParametersInterceptor.java:193) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:159) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) at com.ing.itrf.starlite.common.interceptor.StarliteSecurityInterceptor.intercept(StarliteSecurityInterceptor.java:54) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:170) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223) at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221) at com.ing.itrf.starlite.common.interceptor.StarliteDebugInterceptor.intercept(StarliteDebugInterceptor.java:54) at com.opensymphony.xwork2.DefaultActionInvocation$2
RE: Struts 2 Indexed Properties
Re you using struts 2 itself? If yes it would look something like this s:iterator value=listName status=stat input name=someName[s:property value='stat.index'/] /s:iterator The code you send looks like struts 1 Regards, Jishnu Viswanath Software Engineer *(+9180)41190300 - 222(Ext) ll * ( + 91 ) 9731209330ll Tavant Technologies Inc., www.tavant.com PEOPLE :: PASSION :: EXCELLENCE -Original Message- From: YAQ [mailto:[EMAIL PROTECTED] Sent: Monday, July 14, 2008 4:05 PM To: user@struts.apache.org Subject: Struts 2 Indexed Properties Hi, I'm having problem with Struts2 and indexed properties. The list in my action is not being updated. My JSP is something like: logic:iterate id=coverTypes name=questionnaireVO.coverTypesList indexId=index input type=hidden id=questionnaireInputVO.coverTypesList[c:out value=${index} /].key name=questionnaireInputVO.coverTypesList[c:out value=${index} /].key value=c:out value=${coverTypes.key.id} / / input type=hidden id=questionnaireInputVO.coverTypesList[c:out value=${index} /].agreementType.key name=questionnaireInputVO.coverTypesList[c:out value=${index} /].agreementType.key value=c:out value=${coverTypes.agreementType.key.id} / / /logic:iterate I've discovered I need an entry in the x-work conversion properties: Element_questionnaireInputVO.coverTypesList=com.mypath.CoverTypeVO CreateIfNull_questionnaireInputVO.coverTypesList=true But I am getting the following error: [2008-07-14 12:13:07,860] [.Transports : 2] DEBUG [com.opensymphony.xwork2.util.InstantiatingNullHandler ] : Entering nullPropertyValue [EMAIL PROTECTED], property=coverTypesList] [2008-07-14 12:13:07,860] [.Transports : 2] ERROR [com.opensymphony.xwork2.util.InstantiatingNullHandler ] : Could not create and/or set value back on to object org.springframework.beans.factory.BeanCreationException: Error creating bean with name '[Lcom.mypath.CoverTypeVO;': Could not resolve matching constructor at org.springframework.beans.factory.support.ConstructorResolver.autowireCo nstructor(ConstructorResolver.java:178) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac tory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:799) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac tory.autowire(AbstractAutowireCapableBeanFactory.java:255) at com.opensymphony.xwork2.spring.SpringObjectFactory.buildBean(SpringObjec tFactory.java:145) at com.opensymphony.xwork2.util.InstantiatingNullHandler.createObject(Insta ntiatingNullHandler.java:123) at com.opensymphony.xwork2.util.InstantiatingNullHandler.nullPropertyValue( InstantiatingNullHandler.java:104) at ognl.ASTProperty.getValueBody(ASTProperty.java:94) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at ognl.SimpleNode.getValue(SimpleNode.java:210) at ognl.ASTChain.setValueBody(ASTChain.java:168) at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177) at ognl.SimpleNode.setValue(SimpleNode.java:246) at ognl.Ognl.setValue(Ognl.java:476) at com.opensymphony.xwork2.util.OgnlUtil.setValue(OgnlUtil.java:186) at com.opensymphony.xwork2.util.OgnlValueStack.setValue(OgnlValueStack.java :158) at com.opensymphony.xwork2.util.OgnlValueStack.setValue(OgnlValueStack.java :146) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters( ParametersInterceptor.java:193) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(Pa rametersInterceptor.java:159) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(Me thodFilterInterceptor.java:86) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultAct ionInvocation.java:224) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultAct ionInvocation.java:223) at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerS tack.java:455) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvo cation.java:221) at com.ing.itrf.starlite.common.interceptor.StarliteSecurityInterceptor.int ercept(StarliteSecurityInterceptor.java:54) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultAct ionInvocation.java:224) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultAct ionInvocation.java:223) at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerS tack.java:455) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvo cation.java:221) at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(Servle tConfigInterceptor.java:170
Re: [S2] Indexed properties, Type Conversion and Validation
I've made some progress on this on my own. I needed to write my own version of VisitorFieldValidator to make it work however. Once that was done, the model was being validated but all the error messages were being assigned to the wrong field names. The reason for this is that the field names on my form are governed by the format defined in the Type Conversion wiki entry: All the field names are defined as collectionName(unique_id).propertyName where unique_id is the id defined by the KeyProperties_ property entry in my model's conversion properties file. The VisitorFieldValidator uses the Collection index when constructing the field name used to associate an error with a field: for (int i = 0; i array.length; i++) { Object o = array[i]; validateObject(fieldName + [ + i + ], o, visitorContext); } So none of the errors get assigned back to the correct field name and then can't be displayed properly. Getting the error messages associated with the right field name was a bit of a trick however and I don't particularly like my implementation since it seems fragile to me but I can't currently see a way around it. For my approach to work I needed to obtain o's unique Id and and assign it in place of the value i in the code snippet above (i also needed to change the square-brackets to parentheses). I know that in all my use cases o is going to have a getId method so I just hard-coded that. Ideally, I'd like to be able to use something in the xwork or OGNL APIs to determine the KeyParameter from the conversion.properties file so that my code is more dynamic but it seems pretty clear that all that information is tightly encapsulated and out of reach. Is there a sanctioned way for getting at the KeyParameter information based on existing APIs? -- View this message in context: http://www.nabble.com/-S2--Indexed-properties%2C-Type-Conversion-and-Validation-tp14654165p14676430.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[S2] Indexed properties, Type Conversion and Validation
Hey All- I'm developing an application using the ModelDriven approach. On of my forms is a grid style data entry page and I'm having a difficult time getting validation to work. I used the approach specified by Patrick Lightbody (http://struts.apache.org/2.0.11/docs/type-conversion.html) for handling the rendering and updating of collections. With this approach my validations aren't firing. I tried using the VisitorFieldValidator to push the validations out to the Model but that isn't working. The code that populates the edit grid is along the following lines: s:iterator id=category value=productCategories tr tds:textfield name=productCategories(%{id}).sortOrder value=%{sortOrder} size=2 cssClass=txt//td /tr /s:iterator The object graph underlying all this looks like this: BrandAction-Brand-ProductCategory The Brand is the model returned by the BrandAction's getModel() method. I have my validation configuration files defined in the same package as the model classes and a validation configuration file defined for the action with the visitor validator defined within it: validators field name=productCategories field-validator type=visitor true /field-validator /field /validators Has anyone successfully got declarative validation working with indexed properties? Can anyone suggest what I might be doing wrong here? -- View this message in context: http://www.nabble.com/-S2--Indexed-properties%2C-Type-Conversion-and-Validation-tp14654165p14654165.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: S1 Indexed Properties question
In that case, i think you need mapped properties instead of indexed properties. read this: http://struts.apache.org/1.2.9/faqs/indexedprops.html Mapped properties and javascript need to cooperate together in order to solve the problem. Wish this would help. On 10/20/07, Pavel Sapozhnikov [EMAIL PROTECTED] wrote: Hi I have a question so I need to have a form that will be able to create dynamic text boxes. I heard this can be done using indexed properties in struts 1. Basically what I need is like a button that will say Add A Person then when u click on that button two text boxes will come up in one row Last Name and First Name. So clicking on that button would add this row with two text boxes but I need this to be utilizing struts indexed properties. If anyone could point me in the right direction or maybe have an example of such it would be greately appreciated. This indexed properties stuff is also very new to me. Thanks Pavel -- Pavel Sapozhnikov xFact, Inc [EMAIL PROTECTED] -- Fitzwilliam Python [EMAIL PROTECTED]
S1 Indexed Properties question
Hi I have a question so I need to have a form that will be able to create dynamic text boxes. I heard this can be done using indexed properties in struts 1. Basically what I need is like a button that will say Add A Person then when u click on that button two text boxes will come up in one row Last Name and First Name. So clicking on that button would add this row with two text boxes but I need this to be utilizing struts indexed properties. If anyone could point me in the right direction or maybe have an example of such it would be greately appreciated. This indexed properties stuff is also very new to me. Thanks Pavel -- Pavel Sapozhnikov xFact, Inc [EMAIL PROTECTED]
Re: [S2] Indexed properties
You are not the only one that thinks so. There are some OGNL expression issues involved that are confusing too: s:iterator id=contacto value=referidos status=status s:fielderror s:param value=%{'referidos[' + #status.index + '].email'}/ /s:fielderror s:textfield name=referidos[%{#status.index}].email / /s:iterator in the s:param: s:param value=referidos[%{#status.index}].email / won't work (the same expression as the textfield) But s:param evaluates the expression in a different way when placing it as a child: s:paramreferidos[%{#status.index}].email/s:param but this won't work either. Now this won't work either: s:param%{'referidos[' + #status.index + '].email'}/s:param On top of that, you usually want to use your form with the simple theme when using indexed fields because you may want them arranged in a way different than the 2 column table xhtml them (this is my current case anyway). If you are brave enough you may modify or create a new theme for those indexed forms. Other issues you may encounter commonly is: a) adding a new field set (object to your collection). b) delete a file set (object from your collection) when there is at least one. c) Should validation occur only when submitting the form? or in each modification? for example when adding/deleting a new field set? Regards, Gabriel 2007/10/10, Jake Robb [EMAIL PROTECTED]: Okay, so I figured out the right syntax for the question I posted yesterday (subject: List properties in Struts 2). Let's say I have a List of key-value pairs and I want to render the entire list to the user as a form. In Struts 1.x, here's the JSP snippet: logic:iterate list=pairs html:text name=pairs property=key indexed=true / html:text name=pairs property=value indexed=true / /logic:iterate But in S2, I have to do this: s:iterator value=pairs status=status s:textfield name=%{'pairs['+#status.index+'].name'} / s:textfield name=%{'pairs['+#status.index+'].value'} / /s:iterator It seems to me that this use case is common enough that the S2 method should be more friendly and obvious, and should not involve assembling an OGNL expression manually in the JSP. It seems to me that bringing back Struts 1's iterator-aware field tags would be relatively straightforward. It'd be extra nice if the tag simply recognized that the value being pulled in from an iterator automatically, so that you didn't even need the indexed attribute: s:iterator value=pairs id=pair s:textfield name=name / s:textfield name=value / /s:iterator How difficult would that be? It already works to *populate* a form; I just can't submit back to the action and have it fill in my object. Am I the only one that thinks that the current S2 way is a huge pain? -Jake Robb - 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]
[S2] Indexed properties
Okay, so I figured out the right syntax for the question I posted yesterday (subject: List properties in Struts 2). Let's say I have a List of key-value pairs and I want to render the entire list to the user as a form. In Struts 1.x, here's the JSP snippet: logic:iterate list=pairs html:text name=pairs property=key indexed=true / html:text name=pairs property=value indexed=true / /logic:iterate But in S2, I have to do this: s:iterator value=pairs status=status s:textfield name=%{'pairs['+#status.index+'].name'} / s:textfield name=%{'pairs['+#status.index+'].value'} / /s:iterator It seems to me that this use case is common enough that the S2 method should be more friendly and obvious, and should not involve assembling an OGNL expression manually in the JSP. It seems to me that bringing back Struts 1's iterator-aware field tags would be relatively straightforward. It'd be extra nice if the tag simply recognized that the value being pulled in from an iterator automatically, so that you didn't even need the indexed attribute: s:iterator value=pairs id=pair s:textfield name=name / s:textfield name=value / /s:iterator How difficult would that be? It already works to *populate* a form; I just can't submit back to the action and have it fill in my object. Am I the only one that thinks that the current S2 way is a huge pain? -Jake Robb - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Iterate and write indexed properties in place using logic:iterate
What container are you using? If you're using Tomcat 5, or any container that supports JSP 2.0, and you're using the Servlet 2.4 schema in your web.xml, then EL expressions in your JSP will be natively supported, without any additional jar files. Also, if you're using a JSP 2.0 container, you should NOT use Struts-EL, as it won't work properly. You wouldn't need to anyway, as the normal Struts tags would work fine with EL expressions in that container. Concerning dependency on the JSTL, there is no other tag library that should be higher on your no-brainer list of dependencies. Without it, your code will be messier and harder to maintain. -Original Message- From: Francesco Pretto [mailto:[EMAIL PROTECTED] Sent: Sunday, March 25, 2007 7:53 AM To: user@struts.apache.org Subject: Iterate and write indexed properties in place using logic:iterate Hi! What i'm trying to obtain is somewhat described in the faqs here, http://struts.apache.org/1.2.9/faqs/indexedprops.html , using the struts EL extension. This is the problem: i have an ArrayList of objects, called list, all of type Type. I want to individually write on the field field1 of each objects in the ArrayList. Using EL extensions, code would probably like this (i haven't tryed): logic.el:iterate id=idIterate name=MyForm property=list type=Type index=index html-el:text name=MyForm property=list[${index}].field1 / /logic-el:iterate The problem i absolutely don't want to add another dependency to my project, if not strictly necessary, and i have the sensation i can obtain the same using only logic:iterate. Unfortunately, this: logic:iterate id=idIterate name=MyForm property=list type=Type html:text name=IdIterate property=field1 / /logic:iterate doesn't work, as the iteration is not in-place, in the same property of the bean MyForm, but probably is copied somewhere and remain in the page context, so user written fields are lost when go on with other pages of the form. What i want to obtain is to write directly on the form bean properties. I saw that from struts 1.1 exist indexed tags, but i'm unable to use them, if they can give me the functionality i need. I tryed something like: logic:iterate id=idIterate name=MyForm property=list type=Type html:text name=MyForm property=list[].field1 indexed=true / /logic:iterate or similars, but it doesn't work as i expected, and in the reference there aren't examples of use :-( . Please, can you tell me how to obtain this using only logic:iterate (if possible)? Please note i must use struts 1.2.9 only for my project, unfortunately. Thanks for the help! Francesco - 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]
Iterate and write indexed properties in place using logic:iterate
Hi! What i'm trying to obtain is somewhat described in the faqs here, http://struts.apache.org/1.2.9/faqs/indexedprops.html , using the struts EL extension. This is the problem: i have an ArrayList of objects, called list, all of type Type. I want to individually write on the field field1 of each objects in the ArrayList. Using EL extensions, code would probably like this (i haven't tryed): logic.el:iterate id=idIterate name=MyForm property=list type=Type index=index html-el:text name=MyForm property=list[${index}].field1 / /logic-el:iterate The problem i absolutely don't want to add another dependency to my project, if not strictly necessary, and i have the sensation i can obtain the same using only logic:iterate. Unfortunately, this: logic:iterate id=idIterate name=MyForm property=list type=Type html:text name=IdIterate property=field1 / /logic:iterate doesn't work, as the iteration is not in-place, in the same property of the bean MyForm, but probably is copied somewhere and remain in the page context, so user written fields are lost when go on with other pages of the form. What i want to obtain is to write directly on the form bean properties. I saw that from struts 1.1 exist indexed tags, but i'm unable to use them, if they can give me the functionality i need. I tryed something like: logic:iterate id=idIterate name=MyForm property=list type=Type html:text name=MyForm property=list[].field1 indexed=true / /logic:iterate or similars, but it doesn't work as i expected, and in the reference there aren't examples of use :-( . Please, can you tell me how to obtain this using only logic:iterate (if possible)? Please note i must use struts 1.2.9 only for my project, unfortunately. Thanks for the help! Francesco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Iterate and write indexed properties in place using logic:iterate
Hey, nested tags should be actually cited, at least in the 1.3.5 faqs at http://struts.apache.org/1.3.5/struts-taglib/indexedprops.html ! However, found a very simple solution that works perfectly! nested:iterate id=idIterate name=MyForm property=list nested:text property=field1/ /html:select Thanks with nabble.com and it's powerful search function :-) Bye, Francesco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Indexed Properties with nested Tags
Hi Nagesh, Actionform design will not change when using nested tags or logic tags. When using nested tags PROPERLY then data will be be set automatically by struts framework. If you read line by line below and undertstand the code from struts userguide/API then then you an easily catch the logic behind. Feel free to write for any doubt.. Raghuveer -Original Message- From: nagesh.kumar [mailto:[EMAIL PROTECTED] Sent: Monday, January 29, 2007 2:57 PM To: [EMAIL PROTECTED] Subject: RE: Indexed Properties with nested Tags Hi raghu, Iam also using the same issue .. nested:text name=Result property=description / Ho u r cacthing the data in the Action from the form after submitting Please forward that peace of code to me Thanks in Advance Nagesh -Original Message- From: Adam K [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 22, 2006 10:10 PM To: [EMAIL PROTECTED] Cc: Struts Users Mailing List Subject: Re: Indexed Properties with nested Tags Thanks for the lengthy example, but there is one part that I am completly lost on. I thought that the following occurred: Click link to open page, formbean is reset aciton poppulates formbean jsp retrieves values from the formbean. User sees the screen prepopulated. User modifies the information and clicks on submit. The bean is again reset the action is called to put information in the formbean (this is the part I have no data) the jsp then pulls the data from the formbean. What is the purpose of the System.out.println that you have at the end of your action ? thanks again, Adam On 11/21/06, Raghuveer [EMAIL PROTECTED] wrote: Hi Adam, Use the sample code as requested by you. You can ask me any help with nested Tags and from advanced struts *JSP* nested:notEmpty name=ProdSelectionForm property=results nested:iterate name=ProdSelectionForm property=results id=Result type=com.test.javabeans.TestObject tr tdnested:text name=Result property=description / /td /tr /nested:iterate /nested:notEmpty *ActionForm* ** public class ProdSelectionForm extends ActionForm { Collection arlResults=null; //can be arrayalist /** * @return Returns the arlResults. */ public Collection getResults() { return arlResults; } /** * @param arlResultsThe arlResultsto set. */ public void setResults(Collection arlResults) { this.arlResults= arlResults; } /** * * toString representation of object * @return An instance of StringBuffer with Struts Action Form properties * */ public String toString() { StringBuffer sbTemp = new StringBuffer(); sbTemp.append({); sbTemp.append(arlResults= ); sbTemp.append(arlResults); sbTemp.append(}); return sbTemp.toString(); }//end of toString }//end Actionform *TestObject Java Bean* import java.io.Serializable; public class TestObject implements Serializable String description =null; int numProducts =0; /** * @return Returns the description. */ public String getDescription() { return description; } /** * @param description The description to set. */ public void setDescription(String description) { this.description = description; } /** * @return Returns the numProducts. */ public int getNumProducts() { return numProducts; } /** * @param numProducts The numProducts to set. */ public void setNumProducts(int numProducts) { this.numProducts = numProducts; } }//end object ** *Action Class (loading the page)* ** ** ProdSelectionForm prodSelectionForm= (ProdSelectionForm) form; com.test.javabeans.TestObject obj1=new com.test.javabeans.TestObject (); obj1.setDescription(desc1); obj1.setNumProducts (1); com.test.javabeans.TestObject obj2=new com.test.javabeans.TestObject (); obj1.setDescription(desc2); obj1.setNumProducts (2); ArrayList arlResults=new ArrayList (); arlResults.add(obj1); arlResults.add(obj2); prodSelectionForm.setResults(arlResults); *Action Class (Submitting the page)* When you submit the page just print the actionform you wouyld see the updated results of description ,numproducts in action ProdSelectionForm prodSelectionForm= (ProdSelectionForm) form; System.out.println(prodSelectionForm=+prodSelectionForm); Regards Raghu -Original Message- *From:* Adam K [mailto:[EMAIL PROTECTED] *Sent:* Wednesday, November 22, 2006 3:06 AM *To:* [EMAIL PROTECTED] *Cc:* Struts Users Mailing List *Subject:* Re: Indexed Properties If you might be able to provide a sample I would be very greatful. As it stands I have come up with the following : changing the JSP to : logic:notEmpty name=ProdSelectionForm property=results logic:iterate name=ProdSelectionForm property=results id=Result tr tdhtml:text name=Result property=description indexed=true / /td /tr /logic:iterate /logic:notEmpty Result seemed more natural as it is a single element
FW: Struts1: CHALLENGE Indexed Properties can not be used with FORMS on REQUEST scope! TRUE or NOT TRUE?
Hi folks, Unfortunately I have not got any reactions about my statement yet? I really would like to hear some views on this matter. Kind Regards Urso Wieske -Oorspronkelijk bericht- Van: Urso Wieske Verzonden: donderdag 7 december 2006 14:11 Aan: 'Struts Users Mailing List' Onderwerp: Struts1: CHALLENGE Indexed Properties can not be used with FORMS on REQUEST scope! TRUE or NOT TRUE? Hi folks, Very low reactions on my posting about indexed properties, form, beanutils and request scope. I therefore impose the following CHALLENGE STATEMENT: Indexed Properties can not be used with FORMS on REQUEST scope! I am curious to know who is able to support or reject this statement, beceause until now I was not able do implement this scenario without exceptions. Ted Husted: I would really like your view on the above... :-) Kind regards Urso Wieske - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts1: CHALLENGE Indexed Properties can not be used with FORMS on REQUEST scope! TRUE or NOT TRUE?
I did'nt see your code in your posting but if you're looking for an example for using Indexed Properties please reference http://struts.apache.org/1.x/struts-taglib/indexedprops.html M- --- This e-mail message (including attachments, if any) is intended for the use of the individual or entity to which it is addressed and may contain information that is privileged, proprietary , confidential and exempt from disclosure. If you are not the intended recipient, you are notified that any dissemination, distribution or copying of this communication is strictly prohibited. --- Le présent message électronique (y compris les pièces qui y sont annexées, le cas échéant) s'adresse au destinataire indiqué et peut contenir des renseignements de caractère privé ou confidentiel. Si vous n'êtes pas le destinataire de ce document, nous vous signalons qu'il est strictement interdit de le diffuser, de le distribuer ou de le reproduire. - Original Message - From: Urso Wieske [EMAIL PROTECTED] To: user@struts.apache.org Sent: Friday, December 08, 2006 3:58 AM Subject: FW: Struts1: CHALLENGE Indexed Properties can not be used with FORMS on REQUEST scope! TRUE or NOT TRUE? Hi folks, Unfortunately I have not got any reactions about my statement yet? I really would like to hear some views on this matter. Kind Regards Urso Wieske -Oorspronkelijk bericht- Van: Urso Wieske Verzonden: donderdag 7 december 2006 14:11 Aan: 'Struts Users Mailing List' Onderwerp: Struts1: CHALLENGE Indexed Properties can not be used with FORMS on REQUEST scope! TRUE or NOT TRUE? Hi folks, Very low reactions on my posting about indexed properties, form, beanutils and request scope. I therefore impose the following CHALLENGE STATEMENT: Indexed Properties can not be used with FORMS on REQUEST scope! I am curious to know who is able to support or reject this statement, beceause until now I was not able do implement this scenario without exceptions. Ted Husted: I would really like your view on the above... :-) Kind regards Urso Wieske - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Struts1: CHALLENGE Indexed Properties can not be used with FORMS on REQUEST scope! TRUE or NOT TRUE?
Hi, I've only recently started putting my forms on request scope, and encountered this issue with DynaValidatorForm. A request scoped out of the box DynaValidatorForm is also unable to handle indexed properties e.g. throws IndexOutOfBoundsException in DynaActionForm.get(string, int) - I guess this is just one of those Struts quirks encountered from time to time. My actual form extends DynaValidatorForm so I suppose I could override this method and populate the array with my object type (see how LazyValidatorForm does it). Perhaps the struts indexed properties documentation could improve how various form implementations should grow arrays. This exercise has taught me that having the form on session scope won't necessarily solve the problem...ie if more http params are posted than the array size. Cheers, Paul p.s. for a DynaForm the request parameters are passed through a Map so the form List is not populated in any particular order - although it matches the http request params exactly when its completed. I havn't worked with ActionForms so that may be the case there too - but I'd keep the form at request scope. From: Urso Wieske [mailto:[EMAIL PROTECTED] Sent: Fri 8/12/2006 7:58 PM To: user@struts.apache.org Subject: FW: Struts1: CHALLENGE Indexed Properties can not be used with FORMS on REQUEST scope! TRUE or NOT TRUE? Hi folks, Unfortunately I have not got any reactions about my statement yet? I really would like to hear some views on this matter. Kind Regards Urso Wieske -Oorspronkelijk bericht- Van: Urso Wieske Verzonden: donderdag 7 december 2006 14:11 Aan: 'Struts Users Mailing List' Onderwerp: Struts1: CHALLENGE Indexed Properties can not be used with FORMS on REQUEST scope! TRUE or NOT TRUE? Hi folks, Very low reactions on my posting about indexed properties, form, beanutils and request scope. I therefore impose the following CHALLENGE STATEMENT: Indexed Properties can not be used with FORMS on REQUEST scope! I am curious to know who is able to support or reject this statement, beceause until now I was not able do implement this scenario without exceptions. Ted Husted: I would really like your view on the above... :-) Kind regards Urso Wieske - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ** This message is intended for the addressee named and may contain privileged information or confidential information or both. If you are not the intended recipient please delete it and notify the sender. ** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts1: CHALLENGE Indexed Properties can not be used with FORMS on REQUEST scope! TRUE or NOT TRUE?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Paul, Strachan, Paul wrote: A request scoped out of the box DynaValidatorForm is also unable to handle indexed properties e.g. throws IndexOutOfBoundsException in DynaActionForm.get(string, int) I've never used get(String, int), but I use request-scoped indexed properties all the time and use getStrings(String) just fine in that case. My setup in struct-config.xml: form-bean name=questionSetForm type=org.apache.struts.validator.DynaValidatorForm form-property name=id type=java.lang.String / form-property name=name type=java.lang.String / form-property name=description type=java.lang.String / form-property name=addQuestionId type=java.lang.String[] / form-property name=deleteQuestionId type=java.lang.String[] / /form-bean Part of my form-handler action: // Add and remove the appropriate questions. List questions = getQuestionList(existingQuestions, questionSetForm.getStrings(addQuestionId), questionSetForm.getStrings(deleteQuestionId)); If you are getting IndexOutOfBoundsException, then your loop might be running too long. How are you determining what the maximum index is that you can use? - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFeXZH9CaO5/Lv0PARAk8cAKDAtrEWWH1nl34JU75mKkGfh+IPswCffh6X 56p3VYmREkJLNH5by0RVysM= =yUyl -END PGP SIGNATURE- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Struts1: CHALLENGE Indexed Properties can not be used with FORMS on REQUEST scope! TRUE or NOT TRUE?
Chris, In my DynForm I'm actually using a java.util.ArrayList (contains my bean objects). the http request contains properties: checkList[0].resultId=34checkList[1].resultId=45 etc I havn't debugged using a String[] but the BeanUtilsBean.populate method works differently with properties. I'm not sure the best approach to handle an empty arraylist, but the point is you still have to do *something* - I'm just not sure what. Dumb question: - assuming your String[] is empty when the processPopulate starts, what is the code to grow it to accomodate a variable number of http request parameters? Thanks, Paul From: Christopher Schultz [mailto:[EMAIL PROTECTED] Sent: Sat 9/12/2006 1:27 AM To: Struts Users Mailing List Subject: Re: Struts1: CHALLENGE Indexed Properties can not be used with FORMS on REQUEST scope! TRUE or NOT TRUE? -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Paul, Strachan, Paul wrote: A request scoped out of the box DynaValidatorForm is also unable to handle indexed properties e.g. throws IndexOutOfBoundsException in DynaActionForm.get(string, int) I've never used get(String, int), but I use request-scoped indexed properties all the time and use getStrings(String) just fine in that case. My setup in struct-config.xml: form-bean name=questionSetForm type=org.apache.struts.validator.DynaValidatorForm form-property name=id type=java.lang.String / form-property name=name type=java.lang.String / form-property name=description type=java.lang.String / form-property name=addQuestionId type=java.lang.String[] / form-property name=deleteQuestionId type=java.lang.String[] / /form-bean Part of my form-handler action: // Add and remove the appropriate questions. List questions = getQuestionList(existingQuestions, questionSetForm.getStrings(addQuestionId), questionSetForm.getStrings(deleteQuestionId)); If you are getting IndexOutOfBoundsException, then your loop might be running too long. How are you determining what the maximum index is that you can use? - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org http://enigmail.mozdev.org/ iD8DBQFFeXZH9CaO5/Lv0PARAk8cAKDAtrEWWH1nl34JU75mKkGfh+IPswCffh6X 56p3VYmREkJLNH5by0RVysM= =yUyl -END PGP SIGNATURE- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ** This message is intended for the addressee named and may contain privileged information or confidential information or both. If you are not the intended recipient please delete it and notify the sender. ** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Struts1: CHALLENGE Indexed Properties can not be used with FORMS on REQUEST scope! TRUE or NOT TRUE?
I should have mentioned the get(String, int) is called to get the business object (bean) from the array, so it can then set the property. Since the array is empty it fails with any index. The only solution I can see is to override this method or use LazyValidatorForm (LazyDynaBean). Is there a recommended solution? From: Strachan, Paul [mailto:[EMAIL PROTECTED] Sent: Sat 9/12/2006 2:54 AM To: Struts Users Mailing List Subject: RE: Struts1: CHALLENGE Indexed Properties can not be used with FORMS on REQUEST scope! TRUE or NOT TRUE? Chris, In my DynForm I'm actually using a java.util.ArrayList (contains my bean objects). the http request contains properties: checkList[0].resultId=34checkList[1].resultId=45 etc I havn't debugged using a String[] but the BeanUtilsBean.populate method works differently with properties. I'm not sure the best approach to handle an empty arraylist, but the point is you still have to do *something* - I'm just not sure what. Dumb question: - assuming your String[] is empty when the processPopulate starts, what is the code to grow it to accomodate a variable number of http request parameters? Thanks, Paul From: Christopher Schultz [mailto:[EMAIL PROTECTED] Sent: Sat 9/12/2006 1:27 AM To: Struts Users Mailing List Subject: Re: Struts1: CHALLENGE Indexed Properties can not be used with FORMS on REQUEST scope! TRUE or NOT TRUE? -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Paul, Strachan, Paul wrote: A request scoped out of the box DynaValidatorForm is also unable to handle indexed properties e.g. throws IndexOutOfBoundsException in DynaActionForm.get(string, int) I've never used get(String, int), but I use request-scoped indexed properties all the time and use getStrings(String) just fine in that case. My setup in struct-config.xml: form-bean name=questionSetForm type=org.apache.struts.validator.DynaValidatorForm form-property name=id type=java.lang.String / form-property name=name type=java.lang.String / form-property name=description type=java.lang.String / form-property name=addQuestionId type=java.lang.String[] / form-property name=deleteQuestionId type=java.lang.String[] / /form-bean Part of my form-handler action: // Add and remove the appropriate questions. List questions = getQuestionList(existingQuestions, questionSetForm.getStrings(addQuestionId), questionSetForm.getStrings(deleteQuestionId)); If you are getting IndexOutOfBoundsException, then your loop might be running too long. How are you determining what the maximum index is that you can use? - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org http://enigmail.mozdev.org/ http://enigmail.mozdev.org/ iD8DBQFFeXZH9CaO5/Lv0PARAk8cAKDAtrEWWH1nl34JU75mKkGfh+IPswCffh6X 56p3VYmREkJLNH5by0RVysM= =yUyl -END PGP SIGNATURE- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ** This message is intended for the addressee named and may contain privileged information or confidential information or both. If you are not the intended recipient please delete it and notify the sender. ** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ** This message is intended for the addressee named and may contain privileged information or confidential information or both. If you are not the intended recipient please delete it and notify the sender. ** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts1: CHALLENGE Indexed Properties can not be used with FORMS on REQUEST scope! TRUE or NOT TRUE?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Paul, Strachan, Paul wrote: Chris, In my DynForm I'm actually using a java.util.ArrayList (contains my bean objects). So, you have type=java.util.ArrayList in your form bean definition? Are you sure that Struts knows how to handle that? It might just be creating a new ArrayList for your bean property and then not going anything after that. Have you tried calling yourFormBean.get(yourArrayList) and checking to see what it inside of it? the http request contains properties: checkList[0].resultId=34checkList[1].resultId=45 etc Okay, I have my form submitting multiple addQuestionId parameters with no specific subscripts. Perhaps you are trying to do something slightly differently than I am. Apologies if I missed the point. Dumb question: - assuming your String[] is empty when the processPopulate starts, what is the code to grow it to accomodate a variable number of http request parameters? I don't have to worry about it... Struts handles parsing the request parameters and setting up the array entirely. I merely call getStrings() on my dyna form bean and I get the data. - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFeZG59CaO5/Lv0PARAv2OAKCCllzEmXCL5mdJAMwnXCJquMwvSQCdEXvX c5UsdhF01rQCoBc88rt2RsU= =K+l5 -END PGP SIGNATURE- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Struts1: CHALLENGE Indexed Properties can not be used with FORMS on REQUEST scope! TRUE or NOT TRUE?
Chris, So, you have type=java.util.ArrayList in your form bean definition? Yes Are you sure that Struts knows how to handle that? Yes, it creates a new (empty) arraylist Have you tried calling yourFormBean.get(yourArrayList) and checking to see what it inside of it? not sure what you mean - the action method is never called as the RequestProcessor cant populate the DynaForm from http request parameters... I think the solution (for DynaForm on request scope) is: a) override the get(String,int) method (is dynamic=true required?) b) use LazyValidatorForm (or/with LazyDynaBean) c) put the form on session d) include a new mapping attribute ;) e.g. form-property name=items type=java.util.ArrayList indexedBean=com.example.MyBean / thanks for your responses...I hope Urso is happy too! Cheers, Paul From: Christopher Schultz [mailto:[EMAIL PROTECTED] Sent: Sat 9/12/2006 3:24 AM To: Struts Users Mailing List Subject: Re: Struts1: CHALLENGE Indexed Properties can not be used with FORMS on REQUEST scope! TRUE or NOT TRUE? -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Paul, Strachan, Paul wrote: Chris, In my DynForm I'm actually using a java.util.ArrayList (contains my bean objects). So, you have type=java.util.ArrayList in your form bean definition? Are you sure that Struts knows how to handle that? It might just be creating a new ArrayList for your bean property and then not going anything after that. Have you tried calling yourFormBean.get(yourArrayList) and checking to see what it inside of it? the http request contains properties: checkList[0].resultId=34checkList[1].resultId=45 etc Okay, I have my form submitting multiple addQuestionId parameters with no specific subscripts. Perhaps you are trying to do something slightly differently than I am. Apologies if I missed the point. Dumb question: - assuming your String[] is empty when the processPopulate starts, what is the code to grow it to accomodate a variable number of http request parameters? I don't have to worry about it... Struts handles parsing the request parameters and setting up the array entirely. I merely call getStrings() on my dyna form bean and I get the data. - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org http://enigmail.mozdev.org/ iD8DBQFFeZG59CaO5/Lv0PARAv2OAKCCllzEmXCL5mdJAMwnXCJquMwvSQCdEXvX c5UsdhF01rQCoBc88rt2RsU= =K+l5 -END PGP SIGNATURE- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ** This message is intended for the addressee named and may contain privileged information or confidential information or both. If you are not the intended recipient please delete it and notify the sender. ** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts1: CHALLENGE Indexed Properties can not be used with FORMS on REQUEST scope! TRUE or NOT TRUE?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Paul, Strachan, Paul wrote: Have you tried calling yourFormBean.get(yourArrayList) and checking to see what it inside of it? not sure what you mean - the action method is never called as the RequestProcessor cant populate the DynaForm from http request parameters... Oh... so it bombs in populatePopulate before your Action.execute is called? Hmm... I think the solution (for DynaForm on request scope) is: a) override the get(String,int) method (is dynamic=true required?) How will this help? I thought you said that your action code wasn't being executed. If that's the case, then it will still bomb before you get a chance to call get(String,int). b) use LazyValidatorForm (or/with LazyDynaBean) Is this because poking something into foo[3] will auto-expand in a LazyDynaBean? c) put the form on session I'm not sure how this helps at all. Can you describe why you think this will work? If you have a multi-page flow that expects your form bean to continue to hold information from past pages, then you will certainly need to store the bean in the session. If this is a one-page form submission, then I'm not sure why the choice of bean scope is relevant. d) include a new mapping attribute ;) e.g. form-property name=items type=java.util.ArrayList indexedBean=com.example.MyBean / How is this different from your existing setup? - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFeZhG9CaO5/Lv0PARAv1KAJsH9k0vAqGWb9zH/K9vKQXbmymO3wCeNtg6 MK7aLdO7GI5+2v4/mq22kZ0= =QSGv -END PGP SIGNATURE- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Struts1: CHALLENGE Indexed Properties can not be used with FORMS on REQUEST scope! TRUE or NOT TRUE?
Hi Chris, How will this help? I thought you said that your action code wasn't being executed. If that's the case, then it will still bomb before you get a chance to call get(String,int). this method is (eventually) called as part of the processPopulate (its what fails)...but unfortunately it doesnt seem to be designed for overriding. Is this because poking something into foo[3] will auto-expand in a LazyDynaBean? correct, it fills the array (from current size to index) with a LazyDynaBean (by default) - this bean can have any property set. I'm not sure how this helps at all. Can you describe why you think this will work? if the form is on the session, struts doesn't construct a new one - so we still have the original array (on the form), which can be accessed and updated with the request parameters - *but* theres an assumption that exactly the same number of request params will be submitted. I'm not sure the implications are fully understood by many users...including me until now (thanks Urso) If you have a multi-page flow that expects your form bean to continue to hold information from past pages, then you will certainly need to store the bean in the session. If this is a one-page form submission, then I'm not sure why the choice of bean scope is relevant. there are many choices...:) How is this different from your existing setup? well, firstly there is no such attribute as indexedBean - but if there was struts could instantiate it and populate the property (sort of how LazyValidatorForm works). Paul From: Christopher Schultz [mailto:[EMAIL PROTECTED] Sent: Sat 9/12/2006 3:52 AM To: Struts Users Mailing List Subject: Re: Struts1: CHALLENGE Indexed Properties can not be used with FORMS on REQUEST scope! TRUE or NOT TRUE? -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Paul, Strachan, Paul wrote: Have you tried calling yourFormBean.get(yourArrayList) and checking to see what it inside of it? not sure what you mean - the action method is never called as the RequestProcessor cant populate the DynaForm from http request parameters... Oh... so it bombs in populatePopulate before your Action.execute is called? Hmm... I think the solution (for DynaForm on request scope) is: a) override the get(String,int) method (is dynamic=true required?) How will this help? I thought you said that your action code wasn't being executed. If that's the case, then it will still bomb before you get a chance to call get(String,int). b) use LazyValidatorForm (or/with LazyDynaBean) Is this because poking something into foo[3] will auto-expand in a LazyDynaBean? c) put the form on session I'm not sure how this helps at all. Can you describe why you think this will work? If you have a multi-page flow that expects your form bean to continue to hold information from past pages, then you will certainly need to store the bean in the session. If this is a one-page form submission, then I'm not sure why the choice of bean scope is relevant. d) include a new mapping attribute ;) e.g. form-property name=items type=java.util.ArrayList indexedBean=com.example.MyBean / How is this different from your existing setup? - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org http://enigmail.mozdev.org/ iD8DBQFFeZhG9CaO5/Lv0PARAv1KAJsH9k0vAqGWb9zH/K9vKQXbmymO3wCeNtg6 MK7aLdO7GI5+2v4/mq22kZ0= =QSGv -END PGP SIGNATURE- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ** This message is intended for the addressee named and may contain privileged information or confidential information or both. If you are not the intended recipient please delete it and notify the sender. ** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts1: Indexed Properties, BeanUtils populate, Form on REQUEST scope
So what BeanUtils exception are you getting? Your jsp should be generating the following? input type=.. name=someWrapper[0].propA ... input type=.. name=someWrapper[1].propA ... BeanUtils will try and access the indexed getter - getSomeWrapper(0) and then call setPropA(...) - presumably its one of these methods ist having problems with? Anyway the problem usually with request scope beans is that when it calls the getSomeWrapper(index) method the array isn't initialized and it returns null - if you put logic to automatically grow your array in the getSomeWrapper(index) method then it should solve this. Niall On 12/6/06, Urso Wieske [EMAIL PROTECTED] wrote: Hi folks, I have problem with the scenario Indexed Properties, BeanUtils and Form on REQUEST scope. When I select a a value from (1 or 2) from the dropdownlist and submit the form, I get an exception from BeanUtils.populate method about some getter which can be found!?? IF change the scope of myForm to Session in my struts configuration, then I don't have a problem with beanutils. But I want my form on request scope! I have described below my problem scenario. Is there a solution to this problem?? (form on request scope) I have looked in diffenrent aspects but I am not sure what is happening here with BeanUtils: - commons BeanUtil JAR version issue? - scope (request/session) issue? - JRE/Beanutil issue? - program issue of in my scenario? - array issue? Thanks Urso Wieske Scenario abstraction of my problem: 1.PrepareAction/myForm {forward} 2.viewJSP -{submit}--- 3.ProcessAction/myForm Action Mapping Configuration relevant settings: 1) myForm (MyForm class) is on request scope 3) myForm(MyForm class) is on request scope MyForm considerations: I have a property someWrappers of type array of SomeWrapper (thus, not a List type!) properties: - SomeWrapper [] getSomeWrappers() { return someWrappers;} - void getSomeWrappers(SomeWrapper [] someWrapper) {this.someWrappers = someWrapper;} - SomeWrapper getSomeWrapper(int index) {return someWrappers[index];} - void setSomeWrapper(int index, SomeWrapper someWrapper) {this.someWrappers[index] = someWrapper;} I have changed the name of the indexed property from plural to single noun (someWrapper,... to bypass the JRE1.3/1.4 - JavaBeans specs - BeanUtils issue. My Target runtime is JRE5. viewJSP is a JSP file which has the following structure: html:form action=/someAction . logic:notEmpty name=myForm property=someWrappers logic:iterate property=someWrappers id=someWrapper html:select name=someWrapper property=propA indexed=true html:option value=11/html:option html:option value=22/html:option /html:select logic:iterate /logic:notEmpty . /html:form - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Struts1: Indexed Properties, BeanUtils populate, Form on REQUEST scope
Hi Niall, Thanks for the reply! Apparantly this problem is quite difficult to get answer upon. You're the only one until now. Well, I was getting different exception in different scenario. - When I put an array initialization (someWrappers = )in myForm's default constructor, I would get Array Out Of Bound exceptions. - When I don't do an array initialization for myForm (on REQUEST scope), I would get a method invocation exception from BeanUtils.poulate() due to some getter property descriptor that can't be found. (?) But I have declared all my getters and setters (see fot your self below). I checked my generated HTML sources (from JSP), but they are all rendered as expected. That is, like you have specified below. Weird, huh? When I chang my scope to session... it seems to work. But I don't want my form in sessin scope. (And if this is working indeed in session scope why not for requests scope?) The solution that you propose... I have seen it too on the internet. But this solution does not guarantee the right order of the array elements. And order IS a Requirement for my problem area. Any hints? Kind regards, Urso Wieske -Oorspronkelijk bericht- Van: Niall Pemberton [mailto:[EMAIL PROTECTED] Verzonden: donderdag 7 december 2006 9:40 Aan: Struts Users Mailing List Onderwerp: Re: Struts1: Indexed Properties, BeanUtils populate, Form on REQUEST scope So what BeanUtils exception are you getting? Your jsp should be generating the following? input type=.. name=someWrapper[0].propA ... input type=.. name=someWrapper[1].propA ... BeanUtils will try and access the indexed getter - getSomeWrapper(0) and then call setPropA(...) - presumably its one of these methods ist having problems with? Anyway the problem usually with request scope beans is that when it calls the getSomeWrapper(index) method the array isn't initialized and it returns null - if you put logic to automatically grow your array in the getSomeWrapper(index) method then it should solve this. Niall On 12/6/06, Urso Wieske [EMAIL PROTECTED] wrote: Hi folks, I have problem with the scenario Indexed Properties, BeanUtils and Form on REQUEST scope. When I select a a value from (1 or 2) from the dropdownlist and submit the form, I get an exception from BeanUtils.populate method about some getter which can be found!?? IF change the scope of myForm to Session in my struts configuration, then I don't have a problem with beanutils. But I want my form on request scope! I have described below my problem scenario. Is there a solution to this problem?? (form on request scope) I have looked in diffenrent aspects but I am not sure what is happening here with BeanUtils: - commons BeanUtil JAR version issue? - scope (request/session) issue? - JRE/Beanutil issue? - program issue of in my scenario? - array issue? Thanks Urso Wieske Scenario abstraction of my problem: 1.PrepareAction/myForm {forward} 2.viewJSP -{submit}--- 3.ProcessAction/myForm Action Mapping Configuration relevant settings: 1) myForm (MyForm class) is on request scope 3) myForm(MyForm class) is on request scope MyForm considerations: I have a property someWrappers of type array of SomeWrapper (thus, not a List type!) properties: - SomeWrapper [] getSomeWrappers() { return someWrappers;} - void getSomeWrappers(SomeWrapper [] someWrapper) {this.someWrappers = someWrapper;} - SomeWrapper getSomeWrapper(int index) {return someWrappers[index];} - void setSomeWrapper(int index, SomeWrapper someWrapper) {this.someWrappers[index] = someWrapper;} I have changed the name of the indexed property from plural to single noun (someWrapper,... to bypass the JRE1.3/1.4 - JavaBeans specs - BeanUtils issue. My Target runtime is JRE5. viewJSP is a JSP file which has the following structure: html:form action=/someAction . logic:notEmpty name=myForm property=someWrappers logic:iterate property=someWrappers id=someWrapper html:select name=someWrapper property=propA indexed=true html:option value=11/html:option html:option value=22/html:option /html:select logic:iterate /logic:notEmpty . /html:form - 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]
Struts1: CHALLENGE Indexed Properties can not be used with FORMS on REQUEST scope! TRUE or NOT TRUE?
Hi folks, Very low reactions on my posting about indexed properties, form, beanutils and request scope. I therefore impose the following CHALLENGE STATEMENT: Indexed Properties can not be used with FORMS on REQUEST scope! I am curious to know who is able to support or reject this statement, beceause until now I was not able do implement this scenario without exceptions. Ted Husted: I would really like your view on the above... :-) Kind regards Urso Wieske - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts1: Indexed Properties, BeanUtils populate, Form on REQUEST scope
On 12/7/06, Urso Wieske [EMAIL PROTECTED] wrote: Hi Niall, Thanks for the reply! Apparantly this problem is quite difficult to get answer upon. You're the only one until now. Well, I was getting different exception in different scenario. - When I put an array initialization (someWrappers = )in myForm's default constructor, I would get Array Out Of Bound exceptions. - When I don't do an array initialization for myForm (on REQUEST scope), I would get a method invocation exception from BeanUtils.poulate() due to some getter property descriptor that can't be found. (?) But I have declared all my getters and setters (see fot your self below). I checked my generated HTML sources (from JSP), but they are all rendered as expected. That is, like you have specified below. Weird, huh? When I chang my scope to session... it seems to work. But I don't want my form in sessin scope. (And if this is working indeed in session scope why not for requests scope?) The solution that you propose... I have seen it too on the internet. But this solution does not guarantee the right order of the array elements. And order IS a Requirement for my problem area. You can't control which order http sends the request parameters in - but theres no reason why you can't just grow your array to cope with whatever size the indexed getter is asking for. public SomeWrapper getSomeWrapper(int index) { if (wrappers == null) { wrappers = new SomeWrapper[index + 1]; } // Grow the array if (wrappers.length index + 1) { newWrappers = new SomeWrapper[index + 1]; System.arraycopy(wrappers, 0, newWrappers, 0, wrappers.length); wrappers = newWrappers; } if (wrappers[index] == null) { wrappers[index] = new SomeWrapper(); } return wrappers[index]; } LazyDynaBeans do this for you: http://struts.apache.org/1.x/userGuide/building_controller.html#lazy_action_form_classes Also more info on lazy index growth is here on the wiki: http://wiki.apache.org/struts/StrutsCatalogLazyList Niall Any hints? Kind regards, Urso Wieske -Oorspronkelijk bericht- Van: Niall Pemberton [mailto:[EMAIL PROTECTED] Verzonden: donderdag 7 december 2006 9:40 Aan: Struts Users Mailing List Onderwerp: Re: Struts1: Indexed Properties, BeanUtils populate, Form on REQUEST scope So what BeanUtils exception are you getting? Your jsp should be generating the following? input type=.. name=someWrapper[0].propA ... input type=.. name=someWrapper[1].propA ... BeanUtils will try and access the indexed getter - getSomeWrapper(0) and then call setPropA(...) - presumably its one of these methods ist having problems with? Anyway the problem usually with request scope beans is that when it calls the getSomeWrapper(index) method the array isn't initialized and it returns null - if you put logic to automatically grow your array in the getSomeWrapper(index) method then it should solve this. Niall On 12/6/06, Urso Wieske [EMAIL PROTECTED] wrote: Hi folks, I have problem with the scenario Indexed Properties, BeanUtils and Form on REQUEST scope. When I select a a value from (1 or 2) from the dropdownlist and submit the form, I get an exception from BeanUtils.populate method about some getter which can be found!?? IF change the scope of myForm to Session in my struts configuration, then I don't have a problem with beanutils. But I want my form on request scope! I have described below my problem scenario. Is there a solution to this problem?? (form on request scope) I have looked in diffenrent aspects but I am not sure what is happening here with BeanUtils: - commons BeanUtil JAR version issue? - scope (request/session) issue? - JRE/Beanutil issue? - program issue of in my scenario? - array issue? Thanks Urso Wieske Scenario abstraction of my problem: 1.PrepareAction/myForm {forward} 2.viewJSP -{submit}--- 3.ProcessAction/myForm Action Mapping Configuration relevant settings: 1) myForm (MyForm class) is on request scope 3) myForm(MyForm class) is on request scope MyForm considerations: I have a property someWrappers of type array of SomeWrapper (thus, not a List type!) properties: - SomeWrapper [] getSomeWrappers() { return someWrappers;} - void getSomeWrappers(SomeWrapper [] someWrapper) {this.someWrappers = someWrapper;} - SomeWrapper getSomeWrapper(int index) {return someWrappers[index];} - void setSomeWrapper(int index, SomeWrapper someWrapper) {this.someWrappers[index] = someWrapper;} I have changed the name of the indexed property from plural to single noun (someWrapper,... to bypass the JRE1.3/1.4 - JavaBeans specs - BeanUtils issue. My Target runtime is JRE5. viewJSP is a JSP file which has the following structure: html:form action=/someAction . logic:notEmpty name=myForm property=someWrappers logic:iterate property=someWrappers id=someWrapper
RE: Struts1: Indexed Properties, BeanUtils populate, Form on REQUEST scope
I completely agree with you about how HTTP handles requestparameter. If this is the only solution, then I will have to do some reengineering work in my porblem area to deal with ordering. :-( This is really annoying. I can't imagine I am the first person with this problem. I don;t really see the problem with Struts handling this issue. At form creation/instantiation time by Struts framwork, you always know the amount of indexed parameters. You just count them! :-) So, you the size of the array to be created. The only thing left to do is to put the elements in their proper order. Example: RequestString on submit . someWrapper[0].name=blabla1someWrapper[1].name=blabla2someWrapper[2].name=blabla3.. Voila, you have created a array of size 3, because there three occurrences of indexed property someWrapper[x].name. Kind Regards, Urso -Oorspronkelijk bericht- Van: Niall Pemberton [mailto:[EMAIL PROTECTED] Verzonden: donderdag 7 december 2006 14:16 Aan: Struts Users Mailing List Onderwerp: Re: Struts1: Indexed Properties, BeanUtils populate, Form on REQUEST scope On 12/7/06, Urso Wieske [EMAIL PROTECTED] wrote: Hi Niall, Thanks for the reply! Apparantly this problem is quite difficult to get answer upon. You're the only one until now. Well, I was getting different exception in different scenario. - When I put an array initialization (someWrappers = )in myForm's default constructor, I would get Array Out Of Bound exceptions. - When I don't do an array initialization for myForm (on REQUEST scope), I would get a method invocation exception from BeanUtils.poulate() due to some getter property descriptor that can't be found. (?) But I have declared all my getters and setters (see fot your self below). I checked my generated HTML sources (from JSP), but they are all rendered as expected. That is, like you have specified below. Weird, huh? When I chang my scope to session... it seems to work. But I don't want my form in sessin scope. (And if this is working indeed in session scope why not for requests scope?) The solution that you propose... I have seen it too on the internet. But this solution does not guarantee the right order of the array elements. And order IS a Requirement for my problem area. You can't control which order http sends the request parameters in - but theres no reason why you can't just grow your array to cope with whatever size the indexed getter is asking for. public SomeWrapper getSomeWrapper(int index) { if (wrappers == null) { wrappers = new SomeWrapper[index + 1]; } // Grow the array if (wrappers.length index + 1) { newWrappers = new SomeWrapper[index + 1]; System.arraycopy(wrappers, 0, newWrappers, 0, wrappers.length); wrappers = newWrappers; } if (wrappers[index] == null) { wrappers[index] = new SomeWrapper(); } return wrappers[index]; } LazyDynaBeans do this for you: http://struts.apache.org/1.x/userGuide/building_controller.html#lazy_action_form_classes Also more info on lazy index growth is here on the wiki: http://wiki.apache.org/struts/StrutsCatalogLazyList Niall Any hints? Kind regards, Urso Wieske -Oorspronkelijk bericht- Van: Niall Pemberton [mailto:[EMAIL PROTECTED] Verzonden: donderdag 7 december 2006 9:40 Aan: Struts Users Mailing List Onderwerp: Re: Struts1: Indexed Properties, BeanUtils populate, Form on REQUEST scope So what BeanUtils exception are you getting? Your jsp should be generating the following? input type=.. name=someWrapper[0].propA ... input type=.. name=someWrapper[1].propA ... BeanUtils will try and access the indexed getter - getSomeWrapper(0) and then call setPropA(...) - presumably its one of these methods ist having problems with? Anyway the problem usually with request scope beans is that when it calls the getSomeWrapper(index) method the array isn't initialized and it returns null - if you put logic to automatically grow your array in the getSomeWrapper(index) method then it should solve this. Niall On 12/6/06, Urso Wieske [EMAIL PROTECTED] wrote: Hi folks, I have problem with the scenario Indexed Properties, BeanUtils and Form on REQUEST scope. When I select a a value from (1 or 2) from the dropdownlist and submit the form, I get an exception from BeanUtils.populate method about some getter which can be found!?? IF change the scope of myForm to Session in my struts configuration, then I don't have a problem with beanutils. But I want my form on request scope! I have described below my problem scenario. Is there a solution to this problem?? (form on request scope) I have looked in diffenrent aspects but I am not sure what is happening here with BeanUtils: - commons BeanUtil JAR version issue? - scope (request/session) issue? - JRE/Beanutil issue? - program issue of in my scenario
RE: Struts1: Indexed Properties, BeanUtils populate, Form on REQUEST scope
Guys, Girls, Help. -Oorspronkelijk bericht- Van: Urso Wieske Verzonden: donderdag 7 december 2006 14:29 Aan: Struts Users Mailing List Onderwerp: RE: Struts1: Indexed Properties, BeanUtils populate, Form on REQUEST scope I completely agree with you about how HTTP handles requestparameter. If this is the only solution, then I will have to do some reengineering work in my porblem area to deal with ordering. :-( This is really annoying. I can't imagine I am the first person with this problem. I don;t really see the problem with Struts handling this issue. At form creation/instantiation time by Struts framwork, you always know the amount of indexed parameters. You just count them! :-) So, you the size of the array to be created. The only thing left to do is to put the elements in their proper order. Example: RequestString on submit . someWrapper[0].name=blabla1someWrapper[1].name=blabla2someWrapper[2].name=blabla3.. Voila, you have created a array of size 3, because there three occurrences of indexed property someWrapper[x].name. Kind Regards, Urso -Oorspronkelijk bericht- Van: Niall Pemberton [mailto:[EMAIL PROTECTED] Verzonden: donderdag 7 december 2006 14:16 Aan: Struts Users Mailing List Onderwerp: Re: Struts1: Indexed Properties, BeanUtils populate, Form on REQUEST scope On 12/7/06, Urso Wieske [EMAIL PROTECTED] wrote: Hi Niall, Thanks for the reply! Apparantly this problem is quite difficult to get answer upon. You're the only one until now. Well, I was getting different exception in different scenario. - When I put an array initialization (someWrappers = )in myForm's default constructor, I would get Array Out Of Bound exceptions. - When I don't do an array initialization for myForm (on REQUEST scope), I would get a method invocation exception from BeanUtils.poulate() due to some getter property descriptor that can't be found. (?) But I have declared all my getters and setters (see fot your self below). I checked my generated HTML sources (from JSP), but they are all rendered as expected. That is, like you have specified below. Weird, huh? When I chang my scope to session... it seems to work. But I don't want my form in sessin scope. (And if this is working indeed in session scope why not for requests scope?) The solution that you propose... I have seen it too on the internet. But this solution does not guarantee the right order of the array elements. And order IS a Requirement for my problem area. You can't control which order http sends the request parameters in - but theres no reason why you can't just grow your array to cope with whatever size the indexed getter is asking for. public SomeWrapper getSomeWrapper(int index) { if (wrappers == null) { wrappers = new SomeWrapper[index + 1]; } // Grow the array if (wrappers.length index + 1) { newWrappers = new SomeWrapper[index + 1]; System.arraycopy(wrappers, 0, newWrappers, 0, wrappers.length); wrappers = newWrappers; } if (wrappers[index] == null) { wrappers[index] = new SomeWrapper(); } return wrappers[index]; } LazyDynaBeans do this for you: http://struts.apache.org/1.x/userGuide/building_controller.html#lazy_action_form_classes Also more info on lazy index growth is here on the wiki: http://wiki.apache.org/struts/StrutsCatalogLazyList Niall Any hints? Kind regards, Urso Wieske -Oorspronkelijk bericht- Van: Niall Pemberton [mailto:[EMAIL PROTECTED] Verzonden: donderdag 7 december 2006 9:40 Aan: Struts Users Mailing List Onderwerp: Re: Struts1: Indexed Properties, BeanUtils populate, Form on REQUEST scope So what BeanUtils exception are you getting? Your jsp should be generating the following? input type=.. name=someWrapper[0].propA ... input type=.. name=someWrapper[1].propA ... BeanUtils will try and access the indexed getter - getSomeWrapper(0) and then call setPropA(...) - presumably its one of these methods ist having problems with? Anyway the problem usually with request scope beans is that when it calls the getSomeWrapper(index) method the array isn't initialized and it returns null - if you put logic to automatically grow your array in the getSomeWrapper(index) method then it should solve this. Niall On 12/6/06, Urso Wieske [EMAIL PROTECTED] wrote: Hi folks, I have problem with the scenario Indexed Properties, BeanUtils and Form on REQUEST scope. When I select a a value from (1 or 2) from the dropdownlist and submit the form, I get an exception from BeanUtils.populate method about some getter which can be found!?? IF change the scope of myForm to Session in my struts configuration, then I don't have a problem with beanutils. But I want my form on request scope! I have described below my problem scenario. Is there a solution to this problem?? (form on request
Re: Struts1: Indexed Properties, BeanUtils populate, Form on REQUEST scope
On 12/7/06, Urso Wieske [EMAIL PROTECTED] wrote: I completely agree with you about how HTTP handles requestparameter. If this is the only solution, then I will have to do some reengineering work in my porblem area to deal with ordering. :-( This is really annoying. I can't imagine I am the first person with this problem. I don;t really see the problem with Struts handling this issue. I don't see it as one as I use lazy dyna beans - but I am biased towards them :-) At form creation/instantiation time by Struts framwork, you always know the amount of indexed parameters. You just count them! :-) Well the only ready made solution Struts provides is the Lazy action form (or LazyDynaBean) link I gave you. The alternative is to use either the solution I gave you or one of the other style lazy list techniques listed on the wiki I provided. Other than that you could customize the request processor in between the form being created and populated. Niall So, you the size of the array to be created. The only thing left to do is to put the elements in their proper order. Example: RequestString on submit . someWrapper[0].name=blabla1someWrapper[1].name=blabla2someWrapper[2].name=blabla3.. Voila, you have created a array of size 3, because there three occurrences of indexed property someWrapper[x].name. Kind Regards, Urso -Oorspronkelijk bericht- Van: Niall Pemberton [mailto:[EMAIL PROTECTED] Verzonden: donderdag 7 december 2006 14:16 Aan: Struts Users Mailing List Onderwerp: Re: Struts1: Indexed Properties, BeanUtils populate, Form on REQUEST scope On 12/7/06, Urso Wieske [EMAIL PROTECTED] wrote: Hi Niall, Thanks for the reply! Apparantly this problem is quite difficult to get answer upon. You're the only one until now. Well, I was getting different exception in different scenario. - When I put an array initialization (someWrappers = )in myForm's default constructor, I would get Array Out Of Bound exceptions. - When I don't do an array initialization for myForm (on REQUEST scope), I would get a method invocation exception from BeanUtils.poulate() due to some getter property descriptor that can't be found. (?) But I have declared all my getters and setters (see fot your self below). I checked my generated HTML sources (from JSP), but they are all rendered as expected. That is, like you have specified below. Weird, huh? When I chang my scope to session... it seems to work. But I don't want my form in sessin scope. (And if this is working indeed in session scope why not for requests scope?) The solution that you propose... I have seen it too on the internet. But this solution does not guarantee the right order of the array elements. And order IS a Requirement for my problem area. You can't control which order http sends the request parameters in - but theres no reason why you can't just grow your array to cope with whatever size the indexed getter is asking for. public SomeWrapper getSomeWrapper(int index) { if (wrappers == null) { wrappers = new SomeWrapper[index + 1]; } // Grow the array if (wrappers.length index + 1) { newWrappers = new SomeWrapper[index + 1]; System.arraycopy(wrappers, 0, newWrappers, 0, wrappers.length); wrappers = newWrappers; } if (wrappers[index] == null) { wrappers[index] = new SomeWrapper(); } return wrappers[index]; } LazyDynaBeans do this for you: http://struts.apache.org/1.x/userGuide/building_controller.html#lazy_action_form_classes Also more info on lazy index growth is here on the wiki: http://wiki.apache.org/struts/StrutsCatalogLazyList Niall Any hints? Kind regards, Urso Wieske -Oorspronkelijk bericht- Van: Niall Pemberton [mailto:[EMAIL PROTECTED] Verzonden: donderdag 7 december 2006 9:40 Aan: Struts Users Mailing List Onderwerp: Re: Struts1: Indexed Properties, BeanUtils populate, Form on REQUEST scope So what BeanUtils exception are you getting? Your jsp should be generating the following? input type=.. name=someWrapper[0].propA ... input type=.. name=someWrapper[1].propA ... BeanUtils will try and access the indexed getter - getSomeWrapper(0) and then call setPropA(...) - presumably its one of these methods ist having problems with? Anyway the problem usually with request scope beans is that when it calls the getSomeWrapper(index) method the array isn't initialized and it returns null - if you put logic to automatically grow your array in the getSomeWrapper(index) method then it should solve this. Niall On 12/6/06, Urso Wieske [EMAIL PROTECTED] wrote: Hi folks, I have problem with the scenario Indexed Properties, BeanUtils and Form on REQUEST scope. When I select a a value from (1 or 2) from the dropdownlist and submit the form, I get an exception from BeanUtils.populate method about some getter which can be found!?? IF change the scope
Struts1: Indexed Properties, BeanUtils populate, Form on REQUEST scope
Hi folks, I have problem with the scenario Indexed Properties, BeanUtils and Form on REQUEST scope. When I select a a value from (1 or 2) from the dropdownlist and submit the form, I get an exception from BeanUtils.populate method about some getter which can be found!?? IF change the scope of myForm to Session in my struts configuration, then I don't have a problem with beanutils. But I want my form on request scope! I have described below my problem scenario. Is there a solution to this problem?? (form on request scope) I have looked in diffenrent aspects but I am not sure what is happening here with BeanUtils: - commons BeanUtil JAR version issue? - scope (request/session) issue? - JRE/Beanutil issue? - program issue of in my scenario? - array issue? Thanks Urso Wieske Scenario abstraction of my problem: 1.PrepareAction/myForm {forward} 2.viewJSP -{submit}--- 3.ProcessAction/myForm Action Mapping Configuration relevant settings: 1) myForm (MyForm class) is on request scope 3) myForm(MyForm class) is on request scope MyForm considerations: I have a property someWrappers of type array of SomeWrapper (thus, not a List type!) properties: - SomeWrapper [] getSomeWrappers() { return someWrappers;} - void getSomeWrappers(SomeWrapper [] someWrapper) {this.someWrappers = someWrapper;} - SomeWrapper getSomeWrapper(int index) {return someWrappers[index];} - void setSomeWrapper(int index, SomeWrapper someWrapper) {this.someWrappers[index] = someWrapper;} I have changed the name of the indexed property from plural to single noun (someWrapper,... to bypass the JRE1.3/1.4 - JavaBeans specs - BeanUtils issue. My Target runtime is JRE5. viewJSP is a JSP file which has the following structure: html:form action=/someAction . logic:notEmpty name=myForm property=someWrappers logic:iterate property=someWrappers id=someWrapper html:select name=someWrapper property=propA indexed=true html:option value=11/html:option html:option value=22/html:option /html:select logic:iterate /logic:notEmpty . /html:form
RE: Struts1: Indexed Properties, BeanUtils populate, Form on REQUEST scope
Typo: When I select a a value from (1 or 2) from the dropdownlist and submit the form, I get an exception from BeanUtils.populate method about some getter which can NOT be found!?? Sorry -Oorspronkelijk bericht- Van: Urso Wieske Verzonden: woensdag 6 december 2006 13:44 Aan: user@struts.apache.org Onderwerp: Struts1: Indexed Properties, BeanUtils populate, Form on REQUEST scope Hi folks, I have problem with the scenario Indexed Properties, BeanUtils and Form on REQUEST scope. When I select a a value from (1 or 2) from the dropdownlist and submit the form, I get an exception from BeanUtils.populate method about some getter which can be found!?? IF change the scope of myForm to Session in my struts configuration, then I don't have a problem with beanutils. But I want my form on request scope! I have described below my problem scenario. Is there a solution to this problem?? (form on request scope) I have looked in diffenrent aspects but I am not sure what is happening here with BeanUtils: - commons BeanUtil JAR version issue? - scope (request/session) issue? - JRE/Beanutil issue? - program issue of in my scenario? - array issue? Thanks Urso Wieske Scenario abstraction of my problem: 1.PrepareAction/myForm {forward} 2.viewJSP -{submit}--- 3.ProcessAction/myForm Action Mapping Configuration relevant settings: 1) myForm (MyForm class) is on request scope 3) myForm(MyForm class) is on request scope MyForm considerations: I have a property someWrappers of type array of SomeWrapper (thus, not a List type!) properties: - SomeWrapper [] getSomeWrappers() { return someWrappers;} - void getSomeWrappers(SomeWrapper [] someWrapper) {this.someWrappers = someWrapper;} - SomeWrapper getSomeWrapper(int index) {return someWrappers[index];} - void setSomeWrapper(int index, SomeWrapper someWrapper) {this.someWrappers[index] = someWrapper;} I have changed the name of the indexed property from plural to single noun (someWrapper,... to bypass the JRE1.3/1.4 - JavaBeans specs - BeanUtils issue. My Target runtime is JRE5. viewJSP is a JSP file which has the following structure: html:form action=/someAction . logic:notEmpty name=myForm property=someWrappers logic:iterate property=someWrappers id=someWrapper html:select name=someWrapper property=propA indexed=true html:option value=11/html:option html:option value=22/html:option /html:select logic:iterate /logic:notEmpty . /html:form - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Indexed Properties
I think it's the getResultsPage method that causes your problem. If the results is none, and the parameter index equels any value that is large than 0, an OutOfBound Exception will occur. 2006/11/18, Adam K [EMAIL PROTECTED]: public Product getResultsPage(int index) { if(this.results == null) { this.results = new ArrayList(); } while(index = this.results.size()) { this.results.add(new Product()); } return (Product) results.get(index); } -- Wong Tseng 王曾
Re: Indexed Properties
Just think If the struts dosen't set these indexed properties from the lower bound to the upper bound in a ascending order, an outofbound exception will occur. -- Wong Tseng 王曾
Re: Indexed Properties
On 11/22/06, Adam K [EMAIL PROTECTED] wrote: If you might be able to provide a sample I would be very greatful. As it stands I have come up with the following : changing the JSP to : logic:notEmpty name=ProdSelectionForm property=results logic:iterate name=ProdSelectionForm property=results id=Result tr tdhtml:text property=result.description indexed=true / /td /tr /logic:iterate /logic:notEmpty Hmm.. As i said try something like this logic:notEmpty name=ProdSelectionForm property=results logic:iterate name=ProdSelectionForm property=results id=Result tr !--Note the change in the following line.-- tdhtml:text property=result.description indexed=true / /td /tr /logic:iterate /logic:notEmpty In case you dont encounter any error while loading the page. please post the HTML generated. That would give a good idea of what is going wrong. Result seemed more natural as it is a single element of the results. All I want to be able to do is pull 3 things out of an object, display them in a scope of request, and allow the user to update the list and submit the form and have the changes be picked up - who would have thought that would be so incredibly complex ? *Note* The part that leads me to believe it's a misunderstanding of the tags involved is that I can get a single textfield to work perfectly, with all the requirements (other than it being an object with multiple properties). On 11/21/06, Raghuveer [EMAIL PROTECTED] wrote: hi Adam, I understand description,numProducts are properties in User defined Object/java bean in results(getResults(),setResults(..)) Collection in your actionForm. For this kind of requirments there will not be any change in actionform even though ,complixety increases in nesting.. Solution is to use Nested Tags. Nested tags are used for nesting a object inside the other. In your requirment results is a nested property in your actionform. results collection has a collection of objects. I have used Nested tags for most complex requirments and succeeded. Nested Tags is the real power of Struts... Regards Raghu -Original Message- From: Adam K [mailto:[EMAIL PROTECTED] Sent: Saturday, November 18, 2006 2:55 AM To: Struts Users Mailing List Subject: Re: Indexed Properties Thanks for the suggestion I'll keep trying things and see what I can get from it. On 11/17/06, Hubert Rabago [EMAIL PROTECTED] wrote: Lots of people have done it. Search the archives [1]. Search for indexed and lazyList. I've done it with both ActionForm and DynaActionForm. Hubert [1] http://struts.apache.org/mail.html On 11/17/06, Adam K [EMAIL PROTECTED] wrote: I think I have found the problem - or at least a potential cause. Would it be correct in stating that this will not work using ActionForm (what I was using) and that I must instead use DynaActionForm ? Thanks for the time thus far. On 11/17/06, Hubert Rabago [EMAIL PROTECTED] wrote: Adam, Try adding a getResultsPage() that doesn't take params and always returns a valid collection. (Throw in the setResultsPage() that accepts a collection as well.) Hubert On 11/17/06, Adam K [EMAIL PROTECTED] wrote: This has been driving me nuts for the past little bit. I have a page that is populated using indexed properties. The prepopulation works fine, and I get the results as I would expect them, but trying to submit the form I get an index out of bounds exception. I know that it is being caused because the page doesn't have the arrayList to use in the indexed properties. I guess my question boils down to using indexed properties properly. I will start by putting in an explanation of what I have and what I am trying to do: The following is what I am working with : JSP: logic:notEmpty name=ProdSelectionForm property=results logic:iterate name=ProdSelectionForm property=results id=ResultsPage tr tdbean:write name=ResultsPage property=description //td td html:text name=ResultsPage property=numProducts indexed=true / /td /tr /logic:iterate /logic:notEmpty What I am trying to achieve is that a user clicks on a link, they are sent to page, and all of the values are prepopulated. The page is then displayed and the user has the option to modify any of the variables that they want to before resubmitting the page. (When they resubmit the form has a url parameter attached to it). What is happening (or at least what I believe is happening is the following: link is clicked, reset is called action sets the variables, page is displayed, user can modify the page and resubmit, reset
Re: Indexed Properties
Just thought that I would say that the following will be incredibly helpful to anyone working on indexed properties in the future: (It has a complete working example) http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topicf=58t=009880 thanks to everyone for all of the help. On 11/23/06, Puneet Lakhina [EMAIL PROTECTED] wrote: On 11/22/06, Adam K [EMAIL PROTECTED] wrote: If you might be able to provide a sample I would be very greatful. As it stands I have come up with the following : changing the JSP to : logic:notEmpty name=ProdSelectionForm property=results logic:iterate name=ProdSelectionForm property=results id=Result tr tdhtml:text property=result.description indexed=true / /td /tr /logic:iterate /logic:notEmpty Hmm.. As i said try something like this logic:notEmpty name=ProdSelectionForm property=results logic:iterate name=ProdSelectionForm property=results id=Result tr !--Note the change in the following line.-- tdhtml:text property=result.description indexed=true / /td /tr /logic:iterate /logic:notEmpty In case you dont encounter any error while loading the page. please post the HTML generated. That would give a good idea of what is going wrong. Result seemed more natural as it is a single element of the results. All I want to be able to do is pull 3 things out of an object, display them in a scope of request, and allow the user to update the list and submit the form and have the changes be picked up - who would have thought that would be so incredibly complex ? *Note* The part that leads me to believe it's a misunderstanding of the tags involved is that I can get a single textfield to work perfectly, with all the requirements (other than it being an object with multiple properties). On 11/21/06, Raghuveer [EMAIL PROTECTED] wrote: hi Adam, I understand description,numProducts are properties in User defined Object/java bean in results(getResults(),setResults(..)) Collection in your actionForm. For this kind of requirments there will not be any change in actionform even though ,complixety increases in nesting.. Solution is to use Nested Tags. Nested tags are used for nesting a object inside the other. In your requirment results is a nested property in your actionform. results collection has a collection of objects. I have used Nested tags for most complex requirments and succeeded. Nested Tags is the real power of Struts... Regards Raghu -Original Message- From: Adam K [mailto:[EMAIL PROTECTED] Sent: Saturday, November 18, 2006 2:55 AM To: Struts Users Mailing List Subject: Re: Indexed Properties Thanks for the suggestion I'll keep trying things and see what I can get from it. On 11/17/06, Hubert Rabago [EMAIL PROTECTED] wrote: Lots of people have done it. Search the archives [1]. Search for indexed and lazyList. I've done it with both ActionForm and DynaActionForm. Hubert [1] http://struts.apache.org/mail.html On 11/17/06, Adam K [EMAIL PROTECTED] wrote: I think I have found the problem - or at least a potential cause. Would it be correct in stating that this will not work using ActionForm (what I was using) and that I must instead use DynaActionForm ? Thanks for the time thus far. On 11/17/06, Hubert Rabago [EMAIL PROTECTED] wrote: Adam, Try adding a getResultsPage() that doesn't take params and always returns a valid collection. (Throw in the setResultsPage() that accepts a collection as well.) Hubert On 11/17/06, Adam K [EMAIL PROTECTED] wrote: This has been driving me nuts for the past little bit. I have a page that is populated using indexed properties. The prepopulation works fine, and I get the results as I would expect them, but trying to submit the form I get an index out of bounds exception. I know that it is being caused because the page doesn't have the arrayList to use in the indexed properties. I guess my question boils down to using indexed properties properly. I will start by putting in an explanation of what I have and what I am trying to do: The following is what I am working with : JSP: logic:notEmpty name=ProdSelectionForm property=results logic:iterate name=ProdSelectionForm property=results id=ResultsPage tr tdbean:write name=ResultsPage property=description //td td html:text name=ResultsPage property=numProducts indexed=true / /td /tr /logic:iterate /logic:notEmpty What I am trying to achieve is that a user clicks on a link, they are sent to page, and all
Re: Indexed Properties with nested Tags
Thanks for the lengthy example, but there is one part that I am completly lost on. I thought that the following occurred: Click link to open page, formbean is reset aciton poppulates formbean jsp retrieves values from the formbean. User sees the screen prepopulated. User modifies the information and clicks on submit. The bean is again reset the action is called to put information in the formbean (this is the part I have no data) the jsp then pulls the data from the formbean. What is the purpose of the System.out.println that you have at the end of your action ? thanks again, Adam On 11/21/06, Raghuveer [EMAIL PROTECTED] wrote: Hi Adam, Use the sample code as requested by you. You can ask me any help with nested Tags and from advanced struts *JSP* nested:notEmpty name=ProdSelectionForm property=results nested:iterate name=ProdSelectionForm property=results id=Result type=com.test.javabeans.TestObject tr tdnested:text name=Result property=description / /td /tr /nested:iterate /nested:notEmpty *ActionForm* ** public class ProdSelectionForm extends ActionForm { Collection arlResults=null; //can be arrayalist /** * @return Returns the arlResults. */ public Collection getResults() { return arlResults; } /** * @param arlResultsThe arlResultsto set. */ public void setResults(Collection arlResults) { this.arlResults= arlResults; } /** * * toString representation of object * @return An instance of StringBuffer with Struts Action Form properties * */ public String toString() { StringBuffer sbTemp = new StringBuffer(); sbTemp.append({); sbTemp.append(arlResults= ); sbTemp.append(arlResults); sbTemp.append(}); return sbTemp.toString(); }//end of toString }//end Actionform *TestObject Java Bean* import java.io.Serializable; public class TestObject implements Serializable String description =null; int numProducts =0; /** * @return Returns the description. */ public String getDescription() { return description; } /** * @param description The description to set. */ public void setDescription(String description) { this.description = description; } /** * @return Returns the numProducts. */ public int getNumProducts() { return numProducts; } /** * @param numProducts The numProducts to set. */ public void setNumProducts(int numProducts) { this.numProducts = numProducts; } }//end object ** *Action Class (loading the page)* ** ** ProdSelectionForm prodSelectionForm= (ProdSelectionForm) form; com.test.javabeans.TestObject obj1=new com.test.javabeans.TestObject (); obj1.setDescription(desc1); obj1.setNumProducts (1); com.test.javabeans.TestObject obj2=new com.test.javabeans.TestObject (); obj1.setDescription(desc2); obj1.setNumProducts (2); ArrayList arlResults=new ArrayList (); arlResults.add(obj1); arlResults.add(obj2); prodSelectionForm.setResults(arlResults); *Action Class (Submitting the page)* When you submit the page just print the actionform you wouyld see the updated results of description ,numproducts in action ProdSelectionForm prodSelectionForm= (ProdSelectionForm) form; System.out.println(prodSelectionForm=+prodSelectionForm); Regards Raghu -Original Message- *From:* Adam K [mailto:[EMAIL PROTECTED] *Sent:* Wednesday, November 22, 2006 3:06 AM *To:* [EMAIL PROTECTED] *Cc:* Struts Users Mailing List *Subject:* Re: Indexed Properties If you might be able to provide a sample I would be very greatful. As it stands I have come up with the following : changing the JSP to : logic:notEmpty name=ProdSelectionForm property=results logic:iterate name=ProdSelectionForm property=results id=Result tr tdhtml:text name=Result property=description indexed=true / /td /tr /logic:iterate /logic:notEmpty Result seemed more natural as it is a single element of the results. All I want to be able to do is pull 3 things out of an object, display them in a scope of request, and allow the user to update the list and submit the form and have the changes be picked up - who would have thought that would be so incredibly complex ? *Note* The part that leads me to believe it's a misunderstanding of the tags involved is that I can get a single textfield to work perfectly, with all the requirements (other than it being an object with multiple properties). On 11/21/06, Raghuveer [EMAIL PROTECTED] wrote: hi Adam, I understand description,numProducts are properties in User defined Object/java bean in results(getResults(),setResults(..)) Collection in your actionForm. For this kind of requirments there will not be any change in actionform even though ,complixety increases in nesting.. Solution is to use Nested Tags. Nested tags are used for nesting a object inside the other. In your requirment results is a nested property in your actionform. results collection has a collection of objects. I have used Nested tags for most complex
Re: Indexed Properties with nested Tags
I should also like to say that the one part that seems to be giving me the most problem is the setting of the variables in action when it is submitted. The other thing I am curious about is if what I am doing is incorrect. I am using one action for both the submit as well as the prepopulate based on a url parameter. thanks once again. Adam On 11/22/06, Adam K [EMAIL PROTECTED] wrote: Thanks for the lengthy example, but there is one part that I am completly lost on. I thought that the following occurred: Click link to open page, formbean is reset aciton poppulates formbean jsp retrieves values from the formbean. User sees the screen prepopulated. User modifies the information and clicks on submit. The bean is again reset the action is called to put information in the formbean (this is the part I have no data) the jsp then pulls the data from the formbean. What is the purpose of the System.out.println that you have at the end of your action ? thanks again, Adam On 11/21/06, Raghuveer [EMAIL PROTECTED] wrote: Hi Adam, Use the sample code as requested by you. You can ask me any help with nested Tags and from advanced struts *JSP* nested:notEmpty name=ProdSelectionForm property=results nested:iterate name=ProdSelectionForm property=results id=Result type=com.test.javabeans.TestObject tr tdnested:text name=Result property=description / /td /tr /nested:iterate /nested:notEmpty *ActionForm* ** public class ProdSelectionForm extends ActionForm { Collection arlResults=null; //can be arrayalist /** * @return Returns the arlResults. */ public Collection getResults() { return arlResults; } /** * @param arlResultsThe arlResultsto set. */ public void setResults(Collection arlResults) { this.arlResults= arlResults; } /** * * toString representation of object * @return An instance of StringBuffer with Struts Action Form properties * */ public String toString() { StringBuffer sbTemp = new StringBuffer(); sbTemp.append({); sbTemp.append(arlResults= ); sbTemp.append(arlResults); sbTemp.append(}); return sbTemp.toString(); }//end of toString }//end Actionform *TestObject Java Bean* import java.io.Serializable; public class TestObject implements Serializable String description =null; int numProducts =0; /** * @return Returns the description. */ public String getDescription() { return description; } /** * @param description The description to set. */ public void setDescription(String description) { this.description = description; } /** * @return Returns the numProducts. */ public int getNumProducts() { return numProducts; } /** * @param numProducts The numProducts to set. */ public void setNumProducts(int numProducts) { this.numProducts = numProducts; } }//end object ** *Action Class (loading the page)* ** ** ProdSelectionForm prodSelectionForm= (ProdSelectionForm) form; com.test.javabeans.TestObject obj1=new com.test.javabeans.TestObject (); obj1.setDescription(desc1); obj1.setNumProducts (1); com.test.javabeans.TestObject obj2=new com.test.javabeans.TestObject(); obj1.setDescription(desc2); obj1.setNumProducts (2); ArrayList arlResults=new ArrayList (); arlResults.add(obj1); arlResults.add(obj2); prodSelectionForm.setResults(arlResults); *Action Class (Submitting the page)* When you submit the page just print the actionform you wouyld see the updated results of description ,numproducts in action ProdSelectionForm prodSelectionForm= (ProdSelectionForm) form; System.out.println(prodSelectionForm=+prodSelectionForm); Regards Raghu -Original Message- *From:* Adam K [mailto:[EMAIL PROTECTED] *Sent:* Wednesday, November 22, 2006 3:06 AM *To:* [EMAIL PROTECTED] *Cc:* Struts Users Mailing List *Subject:* Re: Indexed Properties If you might be able to provide a sample I would be very greatful. As it stands I have come up with the following : changing the JSP to : logic:notEmpty name=ProdSelectionForm property=results logic:iterate name=ProdSelectionForm property=results id=Result tr tdhtml:text name=Result property=description indexed=true / /td /tr /logic:iterate /logic:notEmpty Result seemed more natural as it is a single element of the results. All I want to be able to do is pull 3 things out of an object, display them in a scope of request, and allow the user to update the list and submit the form and have the changes be picked up - who would have thought that would be so incredibly complex ? *Note* The part that leads me to believe it's a misunderstanding of the tags involved is that I can get a single textfield to work perfectly, with all the requirements (other than it being an object with multiple properties). On 11/21/06, Raghuveer [EMAIL PROTECTED] wrote: hi Adam, I understand
RE: Indexed Properties with nested Tags
From: Adam K [mailto:[EMAIL PROTECTED] What is the purpose of the System.out.println that you have at the end of your action ? Debugging? Dave - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Indexed Properties with nested Tags
Alright, I guess I should have thought that. I was worried that my fundamental understanding for this was wrong. For debugging I am putting my information into a String which is not being iterated (it for some reason always works, but those that are iterated over don't for some reason. I have no problem prepopulating, and no problem showing the form again, it's only when I try to have what the user inputs get placed into the form that is where I am lost. thanks once again for all the help everyone, sorry if I sound like a broken record. On 11/22/06, Dave Newton [EMAIL PROTECTED] wrote: From: Adam K [mailto:[EMAIL PROTECTED] What is the purpose of the System.out.println that you have at the end of your action ? Debugging? Dave - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Indexed Properties with nested Tags
I am 100% sure. I have extensively used these futures and successful. Using Nested Tags will decrease the Lines of Code,Easy Maintenance.. Nested tags will take care of setting the latest values to form bean .There will not be any change in ActionForm/Action class. Framework will take care of setting the data to actionform for nested properties from nested tags. Form bean may have getters and setter of scalar types(string,int...) or nested types(user defined object,collection...). If you have done every thing as below,Your latest values from jsp will be set to form bean when JSP page is Submitted. Clarification 1 Add below method in TestObject Java Bean also.This will help you understand the Object Content/Data during population and submit. public String toString() { StringBuffer sbTemp = new StringBuffer(); sbTemp.append({); sbTemp.append(description= ); sbTemp.append(description); sbTemp.append(numProducts = ); sbTemp.append(numProducts ); sbTemp.append(}); return sbTemp.toString(); }//end of toString Clarification 2 System .out.println is added in order to make you understand that when JSP is submitted you will have latest data in arlResults collection in actionform. Regards, Raghu -Original Message- From: Adam K [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 22, 2006 10:16 PM To: [EMAIL PROTECTED] Cc: Struts Users Mailing List Subject: Re: Indexed Properties with nested Tags I should also like to say that the one part that seems to be giving me the most problem is the setting of the variables in action when it is submitted. The other thing I am curious about is if what I am doing is incorrect. I am using one action for both the submit as well as the prepopulate based on a url parameter. thanks once again. Adam On 11/22/06, Adam K [EMAIL PROTECTED] wrote: Thanks for the lengthy example, but there is one part that I am completly lost on. I thought that the following occurred: Click link to open page, formbean is reset aciton poppulates formbean jsp retrieves values from the formbean. User sees the screen prepopulated. User modifies the information and clicks on submit. The bean is again reset the action is called to put information in the formbean (this is the part I have no data) the jsp then pulls the data from the formbean. What is the purpose of the System.out.println that you have at the end of your action ? thanks again, Adam On 11/21/06, Raghuveer [EMAIL PROTECTED] wrote: Hi Adam, Use the sample code as requested by you. You can ask me any help with nested Tags and from advanced struts JSP nested:notEmpty name=ProdSelectionForm property=results nested:iterate name=ProdSelectionForm property=results id=Result type=com.test.javabeans.TestObject tr tdnested:text name=Result property=description / /td /tr /nested:iterate /nested:notEmpty ActionForm public class ProdSelectionForm extends ActionForm { Collection arlResults=null; //can be arrayalist /** * @return Returns the arlResults. */ public Collection getResults() { return arlResults; } /** * @param arlResultsThe arlResultsto set. */ public void setResults(Collection arlResults) { this.arlResults= arlResults; } /** * * toString representation of object * @return An instance of StringBuffer with Struts Action Form properties * */ public String toString() { StringBuffer sbTemp = new StringBuffer(); sbTemp.append({); sbTemp.append(arlResults= ); sbTemp.append(arlResults); sbTemp.append(}); return sbTemp.toString(); }//end of toString }//end Actionform TestObject Java Bean import java.io.Serializable; public class TestObject implements Serializable String description =null; int numProducts =0; /** * @return Returns the description. */ public String getDescription() { return description; } /** * @param description The description to set. */ public void setDescription(String description) { this.description = description; } /** * @return Returns the numProducts. */ public int getNumProducts() { return numProducts; } /** * @param numProducts The numProducts to set. */ public void setNumProducts(int numProducts) { this.numProducts = numProducts; } }//end object Action Class (loading the page) ProdSelectionForm prodSelectionForm= (ProdSelectionForm) form; com.test.javabeans.TestObject obj1=new com.test.javabeans.TestObject (); obj1.setDescription
RE: Indexed Properties with nested Tags
In JSP make sure you add taglib directive %@ taglib uri=/tags/struts-nested prefix=nested % or %@ taglib uri=/WEB-INF/struts-nested prefix=nested % -Original Message- From: Raghu [mailto:[EMAIL PROTECTED] Sent: Thursday, November 23, 2006 9:47 AM To: 'Adam K' Cc: 'Struts Users Mailing List' Subject: RE: Indexed Properties with nested Tags I am 100% sure. I have extensively used these futures and successful. Using Nested Tags will decrease the Lines of Code,Easy Maintenance.. Nested tags will take care of setting the latest values to form bean .There will not be any change in ActionForm/Action class. Framework will take care of setting the data to actionform for nested properties from nested tags. Form bean may have getters and setter of scalar types(string,int...) or nested types(user defined object,collection...). If you have done every thing as below,Your latest values from jsp will be set to form bean when JSP page is Submitted. Clarification 1 Add below method in TestObject Java Bean also.This will help you understand the Object Content/Data during population and submit. public String toString() { StringBuffer sbTemp = new StringBuffer(); sbTemp.append({); sbTemp.append(description= ); sbTemp.append(description); sbTemp.append(numProducts = ); sbTemp.append(numProducts ); sbTemp.append(}); return sbTemp.toString(); }//end of toString Clarification 2 System .out.println is added in order to make you understand that when JSP is submitted you will have latest data in arlResults collection in actionform. Regards, Raghu -Original Message- From: Adam K [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 22, 2006 10:16 PM To: [EMAIL PROTECTED] Cc: Struts Users Mailing List Subject: Re: Indexed Properties with nested Tags I should also like to say that the one part that seems to be giving me the most problem is the setting of the variables in action when it is submitted. The other thing I am curious about is if what I am doing is incorrect. I am using one action for both the submit as well as the prepopulate based on a url parameter. thanks once again. Adam On 11/22/06, Adam K [EMAIL PROTECTED] wrote: Thanks for the lengthy example, but there is one part that I am completly lost on. I thought that the following occurred: Click link to open page, formbean is reset aciton poppulates formbean jsp retrieves values from the formbean. User sees the screen prepopulated. User modifies the information and clicks on submit. The bean is again reset the action is called to put information in the formbean (this is the part I have no data) the jsp then pulls the data from the formbean. What is the purpose of the System.out.println that you have at the end of your action ? thanks again, Adam On 11/21/06, Raghuveer [EMAIL PROTECTED] wrote: Hi Adam, Use the sample code as requested by you. You can ask me any help with nested Tags and from advanced struts JSP nested:notEmpty name=ProdSelectionForm property=results nested:iterate name=ProdSelectionForm property=results id=Result type=com.test.javabeans.TestObject tr tdnested:text name=Result property=description / /td /tr /nested:iterate /nested:notEmpty ActionForm public class ProdSelectionForm extends ActionForm { Collection arlResults=null; //can be arrayalist /** * @return Returns the arlResults. */ public Collection getResults() { return arlResults; } /** * @param arlResultsThe arlResultsto set. */ public void setResults(Collection arlResults) { this.arlResults= arlResults; } /** * * toString representation of object * @return An instance of StringBuffer with Struts Action Form properties * */ public String toString() { StringBuffer sbTemp = new StringBuffer(); sbTemp.append({); sbTemp.append(arlResults= ); sbTemp.append(arlResults); sbTemp.append(}); return sbTemp.toString(); }//end of toString }//end Actionform TestObject Java Bean import java.io.Serializable; public class TestObject implements Serializable String description =null; int numProducts =0; /** * @return Returns the description. */ public String getDescription() { return description; } /** * @param description The description to set. */ public void setDescription(String description) { this.description
Re: Indexed Properties
If you might be able to provide a sample I would be very greatful. As it stands I have come up with the following : changing the JSP to : logic:notEmpty name=ProdSelectionForm property=results logic:iterate name=ProdSelectionForm property=results id=Result tr tdhtml:text name=Result property=description indexed=true / /td /tr /logic:iterate /logic:notEmpty Result seemed more natural as it is a single element of the results. All I want to be able to do is pull 3 things out of an object, display them in a scope of request, and allow the user to update the list and submit the form and have the changes be picked up - who would have thought that would be so incredibly complex ? *Note* The part that leads me to believe it's a misunderstanding of the tags involved is that I can get a single textfield to work perfectly, with all the requirements (other than it being an object with multiple properties). On 11/21/06, Raghuveer [EMAIL PROTECTED] wrote: hi Adam, I understand description,numProducts are properties in User defined Object/java bean in results(getResults(),setResults(..)) Collection in your actionForm. For this kind of requirments there will not be any change in actionform even though ,complixety increases in nesting.. Solution is to use Nested Tags. Nested tags are used for nesting a object inside the other. In your requirment results is a nested property in your actionform. results collection has a collection of objects. I have used Nested tags for most complex requirments and succeeded. Nested Tags is the real power of Struts... Regards Raghu -Original Message- From: Adam K [mailto:[EMAIL PROTECTED] Sent: Saturday, November 18, 2006 2:55 AM To: Struts Users Mailing List Subject: Re: Indexed Properties Thanks for the suggestion I'll keep trying things and see what I can get from it. On 11/17/06, Hubert Rabago [EMAIL PROTECTED] wrote: Lots of people have done it. Search the archives [1]. Search for indexed and lazyList. I've done it with both ActionForm and DynaActionForm. Hubert [1] http://struts.apache.org/mail.html On 11/17/06, Adam K [EMAIL PROTECTED] wrote: I think I have found the problem - or at least a potential cause. Would it be correct in stating that this will not work using ActionForm (what I was using) and that I must instead use DynaActionForm ? Thanks for the time thus far. On 11/17/06, Hubert Rabago [EMAIL PROTECTED] wrote: Adam, Try adding a getResultsPage() that doesn't take params and always returns a valid collection. (Throw in the setResultsPage() that accepts a collection as well.) Hubert On 11/17/06, Adam K [EMAIL PROTECTED] wrote: This has been driving me nuts for the past little bit. I have a page that is populated using indexed properties. The prepopulation works fine, and I get the results as I would expect them, but trying to submit the form I get an index out of bounds exception. I know that it is being caused because the page doesn't have the arrayList to use in the indexed properties. I guess my question boils down to using indexed properties properly. I will start by putting in an explanation of what I have and what I am trying to do: The following is what I am working with : JSP: logic:notEmpty name=ProdSelectionForm property=results logic:iterate name=ProdSelectionForm property=results id=ResultsPage tr tdbean:write name=ResultsPage property=description //td td html:text name=ResultsPage property=numProducts indexed=true / /td /tr /logic:iterate /logic:notEmpty What I am trying to achieve is that a user clicks on a link, they are sent to page, and all of the values are prepopulated. The page is then displayed and the user has the option to modify any of the variables that they want to before resubmitting the page. (When they resubmit the form has a url parameter attached to it). What is happening (or at least what I believe is happening is the following: link is clicked, reset is called action sets the variables, page is displayed, user can modify the page and resubmit, reset is called on the form, the action is called (this is where it dies as there is no longer an ArrayList) to modify. My question is am I going about this in a manner that seems sensible or am I way off base ? I have the values being prepopulated, but when trying to use the values that the user puts in I can't use them in the action, nor can I pull the values from the form without again setting the values in the form. I am hoping it is that I have over looked something, but it's possible that I don't understand something as well. Here is the Action code (This is the entire
RE: Indexed Properties
hi Adam, I understand description,numProducts are properties in User defined Object/java bean in results(getResults(),setResults(..)) Collection in your actionForm. For this kind of requirments there will not be any change in actionform even though ,complixety increases in nesting.. Solution is to use Nested Tags. Nested tags are used for nesting a object inside the other. In your requirment results is a nested property in your actionform. results collection has a collection of objects. I have used Nested tags for most complex requirments and succeeded. Nested Tags is the real power of Struts... Regards Raghu -Original Message- From: Adam K [mailto:[EMAIL PROTECTED] Sent: Saturday, November 18, 2006 2:55 AM To: Struts Users Mailing List Subject: Re: Indexed Properties Thanks for the suggestion I'll keep trying things and see what I can get from it. On 11/17/06, Hubert Rabago [EMAIL PROTECTED] wrote: Lots of people have done it. Search the archives [1]. Search for indexed and lazyList. I've done it with both ActionForm and DynaActionForm. Hubert [1] http://struts.apache.org/mail.html On 11/17/06, Adam K [EMAIL PROTECTED] wrote: I think I have found the problem - or at least a potential cause. Would it be correct in stating that this will not work using ActionForm (what I was using) and that I must instead use DynaActionForm ? Thanks for the time thus far. On 11/17/06, Hubert Rabago [EMAIL PROTECTED] wrote: Adam, Try adding a getResultsPage() that doesn't take params and always returns a valid collection. (Throw in the setResultsPage() that accepts a collection as well.) Hubert On 11/17/06, Adam K [EMAIL PROTECTED] wrote: This has been driving me nuts for the past little bit. I have a page that is populated using indexed properties. The prepopulation works fine, and I get the results as I would expect them, but trying to submit the form I get an index out of bounds exception. I know that it is being caused because the page doesn't have the arrayList to use in the indexed properties. I guess my question boils down to using indexed properties properly. I will start by putting in an explanation of what I have and what I am trying to do: The following is what I am working with : JSP: logic:notEmpty name=ProdSelectionForm property=results logic:iterate name=ProdSelectionForm property=results id=ResultsPage tr tdbean:write name=ResultsPage property=description //td td html:text name=ResultsPage property=numProducts indexed=true / /td /tr /logic:iterate /logic:notEmpty What I am trying to achieve is that a user clicks on a link, they are sent to page, and all of the values are prepopulated. The page is then displayed and the user has the option to modify any of the variables that they want to before resubmitting the page. (When they resubmit the form has a url parameter attached to it). What is happening (or at least what I believe is happening is the following: link is clicked, reset is called action sets the variables, page is displayed, user can modify the page and resubmit, reset is called on the form, the action is called (this is where it dies as there is no longer an ArrayList) to modify. My question is am I going about this in a manner that seems sensible or am I way off base ? I have the values being prepopulated, but when trying to use the values that the user puts in I can't use them in the action, nor can I pull the values from the form without again setting the values in the form. I am hoping it is that I have over looked something, but it's possible that I don't understand something as well. Here is the Action code (This is the entire execute method) : HttpSession session = request.getSession(); ProdSelectionForm prodSelection = (ProdSelectionForm) form; User user ; user = (User)session.getAttribute(User); Order order = new Order(); ArrayList products = new ArrayList(); ArrayList pageRes = new ArrayList(); ArrayList results = new ArrayList(); String action = (request.getParameter(Dest) == null ? populate : request.getParameter(Dest) ); order = user.getCurrOrder(user); if(action.equals(populate)) { prodSelection.setResults(order.getProducts()); } if(action.equals(Delete)) { ArrayList p = new ArrayList(); p = prodSelection.getResults(); int count = 0; while (count p.size()) { Product t
RE: Indexed Properties with nested Tags
Hi Adam, Use the sample code as requested by you. You can ask me any help with nested Tags and from advanced struts JSP nested:notEmpty name=ProdSelectionForm property=results nested:iterate name=ProdSelectionForm property=results id=Result type=com.test.javabeans.TestObject tr tdnested:text name=Result property=description / /td /tr /nested:iterate /nested:notEmpty ActionForm public class ProdSelectionForm extends ActionForm { Collection arlResults=null; //can be arrayalist /** * @return Returns the arlResults. */ public Collection getResults() { return arlResults; } /** * @param arlResultsThe arlResultsto set. */ public void setResults(Collection arlResults) { this.arlResults= arlResults; } /** * * toString representation of object * @return An instance of StringBuffer with Struts Action Form properties * */ public String toString() { StringBuffer sbTemp = new StringBuffer(); sbTemp.append({); sbTemp.append(arlResults= ); sbTemp.append(arlResults); sbTemp.append(}); return sbTemp.toString(); }//end of toString }//end Actionform TestObject Java Bean import java.io.Serializable; public class TestObject implements Serializable String description =null; int numProducts =0; /** * @return Returns the description. */ public String getDescription() { return description; } /** * @param description The description to set. */ public void setDescription(String description) { this.description = description; } /** * @return Returns the numProducts. */ public int getNumProducts() { return numProducts; } /** * @param numProducts The numProducts to set. */ public void setNumProducts(int numProducts) { this.numProducts = numProducts; } }//end object Action Class (loading the page) ProdSelectionForm prodSelectionForm= (ProdSelectionForm) form; com.test.javabeans.TestObject obj1=new com.test.javabeans.TestObject (); obj1.setDescription(desc1); obj1.setNumProducts (1); com.test.javabeans.TestObject obj2=new com.test.javabeans.TestObject (); obj1.setDescription(desc2); obj1.setNumProducts (2); ArrayList arlResults=new ArrayList (); arlResults.add(obj1); arlResults.add(obj2); prodSelectionForm.setResults(arlResults); Action Class (Submitting the page) When you submit the page just print the actionform you wouyld see the updated results of description ,numproducts in action ProdSelectionForm prodSelectionForm= (ProdSelectionForm) form; System.out.println(prodSelectionForm=+prodSelectionForm); Regards Raghu -Original Message- From: Adam K [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 22, 2006 3:06 AM To: [EMAIL PROTECTED] Cc: Struts Users Mailing List Subject: Re: Indexed Properties If you might be able to provide a sample I would be very greatful. As it stands I have come up with the following : changing the JSP to : logic:notEmpty name=ProdSelectionForm property=results logic:iterate name=ProdSelectionForm property=results id=Result tr tdhtml:text name=Result property=description indexed=true / /td /tr /logic:iterate /logic:notEmpty Result seemed more natural as it is a single element of the results. All I want to be able to do is pull 3 things out of an object, display them in a scope of request, and allow the user to update the list and submit the form and have the changes be picked up - who would have thought that would be so incredibly complex ? *Note* The part that leads me to believe it's a misunderstanding of the tags involved is that I can get a single textfield to work perfectly, with all the requirements (other than it being an object with multiple properties). On 11/21/06, Raghuveer [EMAIL PROTECTED] wrote: hi Adam, I understand description,numProducts are properties in User defined Object/java bean in results(getResults(),setResults(..)) Collection in your actionForm. For this kind of requirments there will not be any change in actionform even though ,complixety increases in nesting.. Solution is to use Nested Tags. Nested tags are used for nesting a object inside the other. In your requirment results is a nested property in your actionform. results collection has a collection of objects. I have used Nested tags for most complex requirments and succeeded. Nested Tags is the real power of Struts... Regards Raghu -Original Message- From: Adam K [mailto:[EMAIL PROTECTED] Sent: Saturday, November 18, 2006 2:55 AM To: Struts Users Mailing List Subject: Re: Indexed Properties Thanks for the suggestion I'll keep trying things and see what I can get from it. On 11/17/06, Hubert Rabago [EMAIL PROTECTED] wrote: Lots of people have done it. Search the archives [1]. Search for indexed and lazyList. I've done it with both ActionForm
Indexed Properties
This has been driving me nuts for the past little bit. I have a page that is populated using indexed properties. The prepopulation works fine, and I get the results as I would expect them, but trying to submit the form I get an index out of bounds exception. I know that it is being caused because the page doesn't have the arrayList to use in the indexed properties. I guess my question boils down to using indexed properties properly. I will start by putting in an explanation of what I have and what I am trying to do: The following is what I am working with : JSP: logic:notEmpty name=ProdSelectionForm property=results logic:iterate name=ProdSelectionForm property=results id=ResultsPage tr tdbean:write name=ResultsPage property=description //td td html:text name=ResultsPage property=numProducts indexed=true / /td /tr /logic:iterate /logic:notEmpty What I am trying to achieve is that a user clicks on a link, they are sent to page, and all of the values are prepopulated. The page is then displayed and the user has the option to modify any of the variables that they want to before resubmitting the page. (When they resubmit the form has a url parameter attached to it). What is happening (or at least what I believe is happening is the following: link is clicked, reset is called action sets the variables, page is displayed, user can modify the page and resubmit, reset is called on the form, the action is called (this is where it dies as there is no longer an ArrayList) to modify. My question is am I going about this in a manner that seems sensible or am I way off base ? I have the values being prepopulated, but when trying to use the values that the user puts in I can't use them in the action, nor can I pull the values from the form without again setting the values in the form. I am hoping it is that I have over looked something, but it's possible that I don't understand something as well. Here is the Action code (This is the entire execute method) : HttpSession session = request.getSession(); ProdSelectionForm prodSelection = (ProdSelectionForm) form; User user ; user = (User)session.getAttribute(User); Order order = new Order(); ArrayList products = new ArrayList(); ArrayList pageRes = new ArrayList(); ArrayList results = new ArrayList(); String action = (request.getParameter(Dest) == null ? populate : request.getParameter(Dest) ); order = user.getCurrOrder(user); if(action.equals(populate)) { prodSelection.setResults(order.getProducts()); } if(action.equals(Delete)) { ArrayList p = new ArrayList(); p = prodSelection.getResults(); int count = 0; while (count p.size()) { Product t = (Product) p.get(count); t.setDescription( +t.getNumProducts() + +pageRes.size() +); p.set(count, t); count++; } t.setDescription( +t.getNumProducts() + +p.size() +); p.set(0, t); user.setOrder(p , user); prodSelection.setResults(p); prodSelection.setTest(prodSelection.getTest()+ + + p.size()); return mapping.findForward(success); } return mapping.findForward(success); Form code: (In the form code is an ArrayList called results. This arraylist contains a bunch of Product ) public Product getResultsPage(int index) { if(this.results == null) { this.results = new ArrayList(); } while(index = this.results.size()) { this.results.add(new Product()); } return (Product) results.get(index); } public void setResultsPage(int index, Product p) { if(this.results == null) { this.results = new ArrayList(); } while(index = this.results.size()) { this.results.add(new Product()); } results.set(index, p); //return (Product) results.get(index); } public void setResults(ArrayList results) { this.results=results; } public ArrayList getResults() { return this.results; } Products is an object that stores various things about a product with numProducts, and description being two of those things. Within Products is both getter and setter methods for the numProducts as well as description. Thanks so much for any help you may be able to provide.
RE: Indexed Properties
Hi to all i have two questions... First question... is possible to remove spring dependecies in struts2 or spring stuff (jars, applicationContext.xml and ContextLoadListener) are neccesary to run struts2 Second question or advise... i want to give a try to ajax, i want some parts of me site to be updated without reloading the whole page, for example. I need some advise where to start, struts2 ajax support, etc... well thats all, thanks for helping me. Regards, Juan Espinosa - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Indexed Properties
Adam, Try adding a getResultsPage() that doesn't take params and always returns a valid collection. (Throw in the setResultsPage() that accepts a collection as well.) Hubert On 11/17/06, Adam K [EMAIL PROTECTED] wrote: This has been driving me nuts for the past little bit. I have a page that is populated using indexed properties. The prepopulation works fine, and I get the results as I would expect them, but trying to submit the form I get an index out of bounds exception. I know that it is being caused because the page doesn't have the arrayList to use in the indexed properties. I guess my question boils down to using indexed properties properly. I will start by putting in an explanation of what I have and what I am trying to do: The following is what I am working with : JSP: logic:notEmpty name=ProdSelectionForm property=results logic:iterate name=ProdSelectionForm property=results id=ResultsPage tr tdbean:write name=ResultsPage property=description //td td html:text name=ResultsPage property=numProducts indexed=true / /td /tr /logic:iterate /logic:notEmpty What I am trying to achieve is that a user clicks on a link, they are sent to page, and all of the values are prepopulated. The page is then displayed and the user has the option to modify any of the variables that they want to before resubmitting the page. (When they resubmit the form has a url parameter attached to it). What is happening (or at least what I believe is happening is the following: link is clicked, reset is called action sets the variables, page is displayed, user can modify the page and resubmit, reset is called on the form, the action is called (this is where it dies as there is no longer an ArrayList) to modify. My question is am I going about this in a manner that seems sensible or am I way off base ? I have the values being prepopulated, but when trying to use the values that the user puts in I can't use them in the action, nor can I pull the values from the form without again setting the values in the form. I am hoping it is that I have over looked something, but it's possible that I don't understand something as well. Here is the Action code (This is the entire execute method) : HttpSession session = request.getSession(); ProdSelectionForm prodSelection = (ProdSelectionForm) form; User user ; user = (User)session.getAttribute(User); Order order = new Order(); ArrayList products = new ArrayList(); ArrayList pageRes = new ArrayList(); ArrayList results = new ArrayList(); String action = (request.getParameter(Dest) == null ? populate : request.getParameter(Dest) ); order = user.getCurrOrder(user); if(action.equals(populate)) { prodSelection.setResults(order.getProducts()); } if(action.equals(Delete)) { ArrayList p = new ArrayList(); p = prodSelection.getResults(); int count = 0; while (count p.size()) { Product t = (Product) p.get(count); t.setDescription( +t.getNumProducts() + +pageRes.size() +); p.set(count, t); count++; } t.setDescription( +t.getNumProducts() + +p.size() +); p.set(0, t); user.setOrder(p , user); prodSelection.setResults(p); prodSelection.setTest(prodSelection.getTest()+ + + p.size()); return mapping.findForward(success); } return mapping.findForward(success); Form code: (In the form code is an ArrayList called results. This arraylist contains a bunch of Product ) public Product getResultsPage(int index) { if(this.results == null) { this.results = new ArrayList(); } while(index = this.results.size()) { this.results.add(new Product()); } return (Product) results.get(index); } public void setResultsPage(int index, Product p) { if(this.results == null) { this.results = new ArrayList(); } while(index = this.results.size()) { this.results.add(new Product()); } results.set(index, p); //return (Product) results.get(index); } public void setResults(ArrayList results) { this.results=results; } public ArrayList getResults() { return this.results; } Products is an object that stores various things about a product with numProducts, and description being two of those things. Within Products is both getter and setter methods for the numProducts as well as description. Thanks so much for any help you may be able to provide. - To unsubscribe, e-mail: [EMAIL
Re: Indexed Properties
I think I have found the problem - or at least a potential cause. Would it be correct in stating that this will not work using ActionForm (what I was using) and that I must instead use DynaActionForm ? Thanks for the time thus far. On 11/17/06, Hubert Rabago [EMAIL PROTECTED] wrote: Adam, Try adding a getResultsPage() that doesn't take params and always returns a valid collection. (Throw in the setResultsPage() that accepts a collection as well.) Hubert On 11/17/06, Adam K [EMAIL PROTECTED] wrote: This has been driving me nuts for the past little bit. I have a page that is populated using indexed properties. The prepopulation works fine, and I get the results as I would expect them, but trying to submit the form I get an index out of bounds exception. I know that it is being caused because the page doesn't have the arrayList to use in the indexed properties. I guess my question boils down to using indexed properties properly. I will start by putting in an explanation of what I have and what I am trying to do: The following is what I am working with : JSP: logic:notEmpty name=ProdSelectionForm property=results logic:iterate name=ProdSelectionForm property=results id=ResultsPage tr tdbean:write name=ResultsPage property=description //td td html:text name=ResultsPage property=numProducts indexed=true / /td /tr /logic:iterate /logic:notEmpty What I am trying to achieve is that a user clicks on a link, they are sent to page, and all of the values are prepopulated. The page is then displayed and the user has the option to modify any of the variables that they want to before resubmitting the page. (When they resubmit the form has a url parameter attached to it). What is happening (or at least what I believe is happening is the following: link is clicked, reset is called action sets the variables, page is displayed, user can modify the page and resubmit, reset is called on the form, the action is called (this is where it dies as there is no longer an ArrayList) to modify. My question is am I going about this in a manner that seems sensible or am I way off base ? I have the values being prepopulated, but when trying to use the values that the user puts in I can't use them in the action, nor can I pull the values from the form without again setting the values in the form. I am hoping it is that I have over looked something, but it's possible that I don't understand something as well. Here is the Action code (This is the entire execute method) : HttpSession session = request.getSession(); ProdSelectionForm prodSelection = (ProdSelectionForm) form; User user ; user = (User)session.getAttribute(User); Order order = new Order(); ArrayList products = new ArrayList(); ArrayList pageRes = new ArrayList(); ArrayList results = new ArrayList(); String action = (request.getParameter(Dest) == null ? populate : request.getParameter(Dest) ); order = user.getCurrOrder(user); if(action.equals(populate)) { prodSelection.setResults(order.getProducts()); } if(action.equals(Delete)) { ArrayList p = new ArrayList(); p = prodSelection.getResults(); int count = 0; while (count p.size()) { Product t = (Product) p.get(count); t.setDescription( +t.getNumProducts() + +pageRes.size() +); p.set(count, t); count++; } t.setDescription( +t.getNumProducts() + +p.size() +); p.set(0, t); user.setOrder(p , user); prodSelection.setResults(p); prodSelection.setTest(prodSelection.getTest()+ + + p.size ()); return mapping.findForward(success); } return mapping.findForward(success); Form code: (In the form code is an ArrayList called results. This arraylist contains a bunch of Product ) public Product getResultsPage(int index) { if(this.results == null) { this.results = new ArrayList(); } while(index = this.results.size()) { this.results.add(new Product()); } return (Product) results.get(index); } public void setResultsPage(int index, Product p) { if(this.results == null) { this.results = new ArrayList(); } while(index = this.results.size()) { this.results.add(new Product()); } results.set(index, p); //return (Product) results.get(index); } public void setResults(ArrayList results) { this.results=results; } public ArrayList getResults() { return this.results
Re: Indexed Properties
Lots of people have done it. Search the archives [1]. Search for indexed and lazyList. I've done it with both ActionForm and DynaActionForm. Hubert [1] http://struts.apache.org/mail.html On 11/17/06, Adam K [EMAIL PROTECTED] wrote: I think I have found the problem - or at least a potential cause. Would it be correct in stating that this will not work using ActionForm (what I was using) and that I must instead use DynaActionForm ? Thanks for the time thus far. On 11/17/06, Hubert Rabago [EMAIL PROTECTED] wrote: Adam, Try adding a getResultsPage() that doesn't take params and always returns a valid collection. (Throw in the setResultsPage() that accepts a collection as well.) Hubert On 11/17/06, Adam K [EMAIL PROTECTED] wrote: This has been driving me nuts for the past little bit. I have a page that is populated using indexed properties. The prepopulation works fine, and I get the results as I would expect them, but trying to submit the form I get an index out of bounds exception. I know that it is being caused because the page doesn't have the arrayList to use in the indexed properties. I guess my question boils down to using indexed properties properly. I will start by putting in an explanation of what I have and what I am trying to do: The following is what I am working with : JSP: logic:notEmpty name=ProdSelectionForm property=results logic:iterate name=ProdSelectionForm property=results id=ResultsPage tr tdbean:write name=ResultsPage property=description //td td html:text name=ResultsPage property=numProducts indexed=true / /td /tr /logic:iterate /logic:notEmpty What I am trying to achieve is that a user clicks on a link, they are sent to page, and all of the values are prepopulated. The page is then displayed and the user has the option to modify any of the variables that they want to before resubmitting the page. (When they resubmit the form has a url parameter attached to it). What is happening (or at least what I believe is happening is the following: link is clicked, reset is called action sets the variables, page is displayed, user can modify the page and resubmit, reset is called on the form, the action is called (this is where it dies as there is no longer an ArrayList) to modify. My question is am I going about this in a manner that seems sensible or am I way off base ? I have the values being prepopulated, but when trying to use the values that the user puts in I can't use them in the action, nor can I pull the values from the form without again setting the values in the form. I am hoping it is that I have over looked something, but it's possible that I don't understand something as well. Here is the Action code (This is the entire execute method) : HttpSession session = request.getSession(); ProdSelectionForm prodSelection = (ProdSelectionForm) form; User user ; user = (User)session.getAttribute(User); Order order = new Order(); ArrayList products = new ArrayList(); ArrayList pageRes = new ArrayList(); ArrayList results = new ArrayList(); String action = (request.getParameter(Dest) == null ? populate : request.getParameter(Dest) ); order = user.getCurrOrder(user); if(action.equals(populate)) { prodSelection.setResults(order.getProducts()); } if(action.equals(Delete)) { ArrayList p = new ArrayList(); p = prodSelection.getResults(); int count = 0; while (count p.size()) { Product t = (Product) p.get(count); t.setDescription( +t.getNumProducts() + +pageRes.size() +); p.set(count, t); count++; } t.setDescription( +t.getNumProducts() + +p.size() +); p.set(0, t); user.setOrder(p , user); prodSelection.setResults(p); prodSelection.setTest(prodSelection.getTest()+ + + p.size ()); return mapping.findForward(success); } return mapping.findForward(success); Form code: (In the form code is an ArrayList called results. This arraylist contains a bunch of Product ) public Product getResultsPage(int index) { if(this.results == null) { this.results = new ArrayList(); } while(index = this.results.size()) { this.results.add(new Product()); } return (Product) results.get(index); } public void setResultsPage(int index, Product p) { if(this.results == null) { this.results = new ArrayList
Re: Indexed Properties
Thanks for the suggestion I'll keep trying things and see what I can get from it. On 11/17/06, Hubert Rabago [EMAIL PROTECTED] wrote: Lots of people have done it. Search the archives [1]. Search for indexed and lazyList. I've done it with both ActionForm and DynaActionForm. Hubert [1] http://struts.apache.org/mail.html On 11/17/06, Adam K [EMAIL PROTECTED] wrote: I think I have found the problem - or at least a potential cause. Would it be correct in stating that this will not work using ActionForm (what I was using) and that I must instead use DynaActionForm ? Thanks for the time thus far. On 11/17/06, Hubert Rabago [EMAIL PROTECTED] wrote: Adam, Try adding a getResultsPage() that doesn't take params and always returns a valid collection. (Throw in the setResultsPage() that accepts a collection as well.) Hubert On 11/17/06, Adam K [EMAIL PROTECTED] wrote: This has been driving me nuts for the past little bit. I have a page that is populated using indexed properties. The prepopulation works fine, and I get the results as I would expect them, but trying to submit the form I get an index out of bounds exception. I know that it is being caused because the page doesn't have the arrayList to use in the indexed properties. I guess my question boils down to using indexed properties properly. I will start by putting in an explanation of what I have and what I am trying to do: The following is what I am working with : JSP: logic:notEmpty name=ProdSelectionForm property=results logic:iterate name=ProdSelectionForm property=results id=ResultsPage tr tdbean:write name=ResultsPage property=description //td td html:text name=ResultsPage property=numProducts indexed=true / /td /tr /logic:iterate /logic:notEmpty What I am trying to achieve is that a user clicks on a link, they are sent to page, and all of the values are prepopulated. The page is then displayed and the user has the option to modify any of the variables that they want to before resubmitting the page. (When they resubmit the form has a url parameter attached to it). What is happening (or at least what I believe is happening is the following: link is clicked, reset is called action sets the variables, page is displayed, user can modify the page and resubmit, reset is called on the form, the action is called (this is where it dies as there is no longer an ArrayList) to modify. My question is am I going about this in a manner that seems sensible or am I way off base ? I have the values being prepopulated, but when trying to use the values that the user puts in I can't use them in the action, nor can I pull the values from the form without again setting the values in the form. I am hoping it is that I have over looked something, but it's possible that I don't understand something as well. Here is the Action code (This is the entire execute method) : HttpSession session = request.getSession(); ProdSelectionForm prodSelection = (ProdSelectionForm) form; User user ; user = (User)session.getAttribute(User); Order order = new Order(); ArrayList products = new ArrayList(); ArrayList pageRes = new ArrayList(); ArrayList results = new ArrayList(); String action = (request.getParameter(Dest) == null ? populate : request.getParameter(Dest) ); order = user.getCurrOrder(user); if(action.equals(populate)) { prodSelection.setResults(order.getProducts()); } if(action.equals(Delete)) { ArrayList p = new ArrayList(); p = prodSelection.getResults(); int count = 0; while (count p.size()) { Product t = (Product) p.get(count); t.setDescription( +t.getNumProducts() + +pageRes.size() +); p.set(count, t); count++; } t.setDescription( +t.getNumProducts() + +p.size() +); p.set(0, t); user.setOrder(p , user); prodSelection.setResults(p); prodSelection.setTest(prodSelection.getTest()+ + + p.size ()); return mapping.findForward(success); } return mapping.findForward(success); Form code: (In the form code is an ArrayList called results. This arraylist contains a bunch of Product ) public Product getResultsPage(int index) { if(this.results == null) { this.results = new ArrayList(); } while(index = this.results.size
multi level indexed properties
Hi all, I need to display and submit a form with 3 levels of indexed properties. The 3 indexed properties are not constant in size. I have a form with a MyObject1[] array with getters and setters for indexed properties. MyObject1 object has a List of MyObject2 objects and MyObject2 has a List of MyObject3 objects. I would like to display these recursives objects with input fields and submit them. But I really don't know how to do it for the indexed properties of level 2 and 3 and how to get the corresponding values. Does someone have an idea? Thanks Sebastien
Re: DynaActionForm indexed properties
On 11/3/06, Niall Pemberton [EMAIL PROTECTED] wrote: On 11/2/06, Puneet Lakhina [EMAIL PROTECTED] wrote: Hi, This is the first time I am trying to use indexed properties with DynaActionForm. Now the number of fields that I will have is not certain. So does that mean I cant use DynaActionForm. And i don't have normal strings in my list. I have a custom object. so what i have currently is something like this form-bean name=dynaForm type=org.apache.struts.action.DynaActionForm form-property name=number type=mypackage.Number[] / /form-bean I cant specify any size because I don't know the size before hand. So this has no problems loading the page, but on submit it throws an ArrayIndexOutOfBoundsException. LazyDynaBeans automatically grows Lists and arrays to the right size: http://struts.apache.org/1.x/userGuide/building_controller.html#lazy_action_form_classes Thanks seems like the exact thing I wanted. But I'm stuck on struts 1.1 at my workplace and based on this http://www.niallp.pwp.blueyonder.co.uk/lazyactionform.html LazyActionform has been added to struts 1.2.6 Is it possible to plug this thing into 1.1?has anybody done that? Thanks Niall -- Puneet - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Puneet
Re: DynaActionForm indexed properties
On 11/3/06, Puneet Lakhina [EMAIL PROTECTED] wrote: On 11/3/06, Niall Pemberton [EMAIL PROTECTED] wrote: On 11/2/06, Puneet Lakhina [EMAIL PROTECTED] wrote: Hi, This is the first time I am trying to use indexed properties with DynaActionForm. Now the number of fields that I will have is not certain. So does that mean I cant use DynaActionForm. And i don't have normal strings in my list. I have a custom object. so what i have currently is something like this form-bean name=dynaForm type=org.apache.struts.action.DynaActionForm form-property name=number type=mypackage.Number[] / /form-bean I cant specify any size because I don't know the size before hand. So this has no problems loading the page, but on submit it throws an ArrayIndexOutOfBoundsException. LazyDynaBeans automatically grows Lists and arrays to the right size: http://struts.apache.org/1.x/userGuide/building_controller.html#lazy_action_form_classes Thanks seems like the exact thing I wanted. But I'm stuck on struts 1.1 at my workplace and based on this http://www.niallp.pwp.blueyonder.co.uk/lazyactionform.html LazyActionform has been added to struts 1.2.6 Is it possible to plug this thing into 1.1?has anybody done that? Thanks I haven't heard of anyone doing it, but you should be able to. LazyDynaBean was added to Commons BeanUtils 1.7.0 and Struts 1.1 depends on a version prior to that. If you can upgrade to BeanUtils 1.7.0 then you have most of the functionality. You could use them as a property in your ActionForm - or replicate the Struts LazyValidatorForm (theres not too much to it), If you can't upgrade to BeanUtils 1.7.0 then you could just grab the source code for the two lazy classes you need (LazyDynaBean and LazyDynaClass) and they should work OK with BeanUtils 1.6.1 - which is the version that Ships with Struts 1.1 You can grab the source download from here for Commons BeanUtils: http://jakarta.apache.org/site/downloads/downloads_commons-beanutils.cgi Niall Niall -- Puneet - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
DynaActionForm indexed properties
Hi, This is the first time I am trying to use indexed properties with DynaActionForm. Now the number of fields that I will have is not certain. So does that mean I cant use DynaActionForm. And i don't have normal strings in my list. I have a custom object. so what i have currently is something like this form-bean name=dynaForm type=org.apache.struts.action.DynaActionForm form-property name=number type=mypackage.Number[] / /form-bean I cant specify any size because I don't know the size before hand. So this has no problems loading the page, but on submit it throws an ArrayIndexOutOfBoundsException. -- Puneet
Re: DynaActionForm indexed properties
If you are using basic arrays you need to create an array for the item before the JSP is displayed. You might want to use a java.util.List instead, you don't need to pre-allocate when using Dyna forms. HTH, -ed On 11/2/06, Puneet Lakhina [EMAIL PROTECTED] wrote: Hi, This is the first time I am trying to use indexed properties with DynaActionForm. Now the number of fields that I will have is not certain. So does that mean I cant use DynaActionForm. And i don't have normal strings in my list. I have a custom object. so what i have currently is something like this form-bean name=dynaForm type=org.apache.struts.action.DynaActionForm form-property name=number type=mypackage.Number[] / /form-bean I cant specify any size because I don't know the size before hand. So this has no problems loading the page, but on submit it throws an ArrayIndexOutOfBoundsException. -- Puneet - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: DynaActionForm indexed properties
On 11/2/06, Puneet Lakhina [EMAIL PROTECTED] wrote: Hi, This is the first time I am trying to use indexed properties with DynaActionForm. Now the number of fields that I will have is not certain. So does that mean I cant use DynaActionForm. And i don't have normal strings in my list. I have a custom object. so what i have currently is something like this form-bean name=dynaForm type=org.apache.struts.action.DynaActionForm form-property name=number type=mypackage.Number[] / /form-bean I cant specify any size because I don't know the size before hand. So this has no problems loading the page, but on submit it throws an ArrayIndexOutOfBoundsException. LazyDynaBeans automatically grows Lists and arrays to the right size: http://struts.apache.org/1.x/userGuide/building_controller.html#lazy_action_form_classes Niall -- Puneet - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Indexed Properties
Hi, I have some objects in an Array List which I want to fetch using indexed properties. So basically in my array list I have objects of type Product, which has properties like name,number etc. with appropriate getter and setter methods. What I am unable to figure out is the following. logic:iterate name=list id=foo indexId=ctr html:text property=newProducts.name indexed=true / /logic:iterate The indexed attribute mentioned in the html text. Does it make newProducts indexed or does it make name indexed. I mean what do i do to get input type=text name=newProducts[0].name / and so on... I know I could you use scriptlets, but I was thinking if there was a cleaner solution to the whole thing. Thanks -- Puneet
Re: Indexed Properties
The trick is normally to name the id used in the logic:iterate to the same name as the property for your list of product in your ActionForm (i.e. newProducts in your example): logic:iterate id=newProducts property=newProducts html:text name=newProducts property=name indexed=true / /logic:iterate Which should then produce the html you're expecting: input type=text name=newProducts[0].name / Niall On 10/23/06, Puneet Lakhina [EMAIL PROTECTED] wrote: Hi, I have some objects in an Array List which I want to fetch using indexed properties. So basically in my array list I have objects of type Product, which has properties like name,number etc. with appropriate getter and setter methods. What I am unable to figure out is the following. logic:iterate name=list id=foo indexId=ctr html:text property=newProducts.name indexed=true / /logic:iterate The indexed attribute mentioned in the html text. Does it make newProducts indexed or does it make name indexed. I mean what do i do to get input type=text name=newProducts[0].name / and so on... I know I could you use scriptlets, but I was thinking if there was a cleaner solution to the whole thing. Thanks -- Puneet - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Indexed Properties in Struts
Hi I'm using Indexed Properties with Struts and am attempting to over-ride the getter method of a List while trying to retrieve data. I have an example where I use the bean:write tag to retrieve contents of a List jsp:useBean id=bean class=org.apache.struts.webapp.exercise.StringBean/ bean:write name=bean property=stringIndexed[1]/ And this code effectively calls the Getter function shown below public Object getStringIndexed(int index) { return strAry.get(index); } And correct values are retrieved. However, when I try to use a similar concept using the html:text tag, html:text property='%= rooms[+rn.intValue()+].childAge[+can.intValue()+] %'/ The getter function public Object getChildAge(int index) does not get control Has anyone encountered similar problems or does anyone know the reason for this ? Help will be highly appreciated Thanks Barun Kumar Yadav ¬Sapient Bangalore Work 91.804.104.7490 Mobile 91.989.197.4493 YIM meet_you_23
Re: Indexed Properties in Struts
Hi Yadav, have a look at below link u'll find something of ur intrest ... http://www.developer.com/java/ejb/article.php/2233591 http://www.developer.com/java/ejb/article.php/10931_3321521_1 Thanks Regards, Aftab Vhora Barun Kumar Yadav wrote: Hi I'm using Indexed Properties with Struts and am attempting to over-ride the getter method of a List while trying to retrieve data. I have an example where I use the bean:write tag to retrieve contents of a List jsp:useBean id=bean class=org.apache.struts.webapp.exercise.StringBean/ bean:write name=bean property=stringIndexed[1]/ And this code effectively calls the Getter function shown below public Object getStringIndexed(int index) { return strAry.get(index); } And correct values are retrieved. However, when I try to use a similar concept using the html:text tag, html:text property='%= rooms[+rn.intValue()+].childAge[+can.intValue()+] %'/ The getter function public Object getChildAge(int index) does not get control Has anyone encountered similar problems or does anyone know the reason for this ? Help will be highly appreciated Thanks Barun Kumar Yadav ¬Sapient Bangalore Work 91.804.104.7490 Mobile 91.989.197.4493 YIM meet_you_23
DynaForm and Indexed properties
Hi All, I'm already familiar with the basic process of using DynaForm with String properties (to capture the HTTP request params) and then copying the DynaForm values to a business object. form-bean name=TestForm type=forms.TestForm form-property name=firstName type=java.lang.String initial=/ form-property name=lastName type=java.lang.String initial=/ form-property name=dob type=java.lang.String initial=/ /form-bean Now I want to use indexed properties (eg multi-row edit screen). So my DynaForm looks something like: form-bean name=TestForm2 type=forms.TestForm form-property name=testForm type=java.util.ArrayList/ /form-bean The problem is what type of Object to use for the formList? I can't use an existing business object because: a) seems to defeat the purpose of the form acting as a firewall to the model b) the objects properties are strongly typed, and this causes problems with data conversion and validator. Ideally, what I want is to reuse my existing TestForm in the ArrayList of TestForm2. Can Struts manage this or do I need to create ValidatorForms (ordinary java classes with getters/setters) to use in this case? Thanks, Paul ** This message is intended for the addressee named and may contain privileged information or confidential information or both. If you are not the intended recipient please delete it and notify the sender. ** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Indexed Properties in validation Framework help?
HI friends, i have form which need indexed properties technique...(by net surfing i came to know) i need a full length tutorial on this topic ,or some code snipats help me please ur's Mallik -- View this message in context: http://www.nabble.com/Indexed-Properties-in-validation-Framework-help--tf2329886.html#a6481541 Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Indexed Properties. Maintaining Order
Hi, I have a no. of fields in a form arranged in a table of rows. I am using indexed properties for these fields. The number of these fields isn't known to me at the time of page loading for which I have used some DHTML to properly add the fields. And all the values are getting submitted. Now my problem is that the order is getting jumbled up. My table is like this No. Date Description 1. date[0]description[0] 2. date[1]description[1] But after submitting, the order gets jumbled up. i.e. i get something like this No. Date Description 1. date[0]description[1] 2. date[1]description[0] This I have figured is because of the following setter methods public void setDate(int index,String value) { datesList.add(value); } public void setDescription(int index,String value) { descriptionsList.add(value); } So basically the order in which the setter methods are called is random. i.e. setDate(0,value) - setDescription(1,value) and so on. Does this problem mean we have no way of maintaining order when using lists? What I have thought of is instead of using Indexed Properties I will use map backed properties. But if somebody can offer me some sort of solution that doesn't require change from Lists to Map it would be great. -- Puneet
Re: Indexed Properties. Maintaining Order
As you found out there is no way of knowing the order the browser/client will submit request parameters, so if you want to use indexed properties in this way you need to grow the list to accomodate the size of the indexed property being set. So you could do something like the following: public void setDate(int index,String value) { while (datesList.size() = index) { datesList.add(null); } datesList.set(index, value); } This is what LazyDynaBean / LazyDynaForm does: http://struts.apache.org/1.x/userGuide/building_controller.html#lazy_action_form_classes Theres also this page on the wiki: http://wiki.apache.org/struts/StrutsCatalogLazyList Niall On 9/21/06, Puneet Lakhina [EMAIL PROTECTED] wrote: Hi, I have a no. of fields in a form arranged in a table of rows. I am using indexed properties for these fields. The number of these fields isn't known to me at the time of page loading for which I have used some DHTML to properly add the fields. And all the values are getting submitted. Now my problem is that the order is getting jumbled up. My table is like this No. Date Description 1. date[0]description[0] 2. date[1]description[1] But after submitting, the order gets jumbled up. i.e. i get something like this No. Date Description 1. date[0]description[1] 2. date[1]description[0] This I have figured is because of the following setter methods public void setDate(int index,String value) { datesList.add(value); } public void setDescription(int index,String value) { descriptionsList.add(value); } So basically the order in which the setter methods are called is random. i.e. setDate(0,value) - setDescription(1,value) and so on. Does this problem mean we have no way of maintaining order when using lists? What I have thought of is instead of using Indexed Properties I will use map backed properties. But if somebody can offer me some sort of solution that doesn't require change from Lists to Map it would be great. -- Puneet - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Indexed Properties. Maintaining Order
A List is an ordered collection so it doesnt make sense that the order changes. Also, depending on which Map implementation you use ordering may not be guaranteed. I frequently use indexed properties with List and have not experienced this problem. You may need to check the generated html source and follow through the request cycle. Your method signatures for your setters dont seem appropriate in the context of managing indexed properties on a list of objects (at least to me). Perhaps you are managing your indexed properties in a way that would better suit a Map implementation, but I cant tell from the provided code. From: Puneet Lakhina [mailto:[EMAIL PROTECTED] Sent: Thu 21/09/2006 7:43 PM To: Struts Users Mailing List Subject: Indexed Properties. Maintaining Order Hi, I have a no. of fields in a form arranged in a table of rows. I am using indexed properties for these fields. The number of these fields isn't known to me at the time of page loading for which I have used some DHTML to properly add the fields. And all the values are getting submitted. Now my problem is that the order is getting jumbled up. My table is like this No. Date Description 1. date[0]description[0] 2. date[1]description[1] But after submitting, the order gets jumbled up. i.e. i get something like this No. Date Description 1. date[0]description[1] 2. date[1]description[0] This I have figured is because of the following setter methods public void setDate(int index,String value) { datesList.add(value); } public void setDescription(int index,String value) { descriptionsList.add(value); } So basically the order in which the setter methods are called is random. i.e. setDate(0,value) - setDescription(1,value) and so on. Does this problem mean we have no way of maintaining order when using lists? What I have thought of is instead of using Indexed Properties I will use map backed properties. But if somebody can offer me some sort of solution that doesn't require change from Lists to Map it would be great. -- Puneet ** This message is intended for the addressee named and may contain privileged information or confidential information or both. If you are not the intended recipient please delete it and notify the sender. ** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Indexed Properties. Maintaining Order
On 9/21/06, Strachan, Paul [EMAIL PROTECTED] wrote: A List is an ordered collection so it doesnt make sense that the order changes. Also, depending on which Map implementation you use ordering may not be guaranteed. I would basically have the index in case of indexed properties as my key. SO the question of ordering doest come publiv void setDate(String key, String value) { map.put(key,value); } This way I would always have the correct values. I frequently use indexed properties with List and have not experienced this problem. You may need to check the generated html source and follow through the request cycle. Your method signatures for your setters dont seem appropriate in the context of managing indexed properties on a list of objects (at least to me). Could you please give an example of how you manage lists with indexed properties, that would really help. Thanks -- Puneet
Re: Indexed Properties. Maintaining Order
On 9/21/06, Niall Pemberton [EMAIL PROTECTED] wrote: As you found out there is no way of knowing the order the browser/client will submit request parameters, so if you want to use indexed properties in this way you need to grow the list to accomodate the size of the indexed property being set. So you could do something like the following: public void setDate(int index,String value) { while (datesList.size() = index) { datesList.add(null); } datesList.set(index, value); } I kinda did this before posting as a temp fix. But I though this was like a too inefficinet solution. But Im glad it isnt all that bad a thing :-). Thanks a lot. -- Puneet
RE: Indexed Properties. Maintaining Order
Hi Puneet, When I re-read your original mail I notice you use DHTML to add rows, so my approach/thoughts may not be appropriate for you. I use DynaForms with ArrayLists of objects. In the form I use the logic:iterate with indexed=true on the html tags. If I need to dynamically add another row I do a submit (no validate) and simply add an empty object into my List and forward back to the page. On 9/22/06, Puneet Lakhina [mailto:[EMAIL PROTECTED] wrote: Could you please give an example of how you manage lists with indexed properties, that would really help. Thanks -- Puneet ** This message is intended for the addressee named and may contain privileged information or confidential information or both. If you are not the intended recipient please delete it and notify the sender. ** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
exception java.lang.IllegalArgumentException: No bean specified while using indexed properties
Hi all I am getting following exception java.lang.IllegalArgumentException: No bean specified while using indexed properties in struts. MyForm Bean is public class ReportItemForm extends ActionForm { FormItem [] formItem=null; public void setItem(int index, FormItem formItem){ this.formItem[index] = formItem;} public FormItem getItem(int index){ if(formItem==null ||(formItem.length)==0) return new FormItem(); return formItem[index]; } and FormItem bean is specified like this public class FormItem { String formitem; int order; public int getOrder() {return order;}/*** @param i*/public void setOrder(int i) { order = i;}/** * @return*/public String getFormitem() { return formitem; }/*** @param string*/public void setFormitem(String string) { formitem = string;} i have set this array of FormItem i.e formItem() properly and the data is dispalyed correctly on the page like this html-el:hidden property=item[${count}].formItem /html-el:text styleId=order property=item[${count}].order size=1 / but when i submitting this form i am getting following Exception java.lang.IllegalArgumentException: No bean specified can anybody help me. any help will be greatly appriciated. thanks Krishan. - Get your own web address for just $1.99/1st yr. We'll help. Yahoo! Small Business.
Re: exception java.lang.IllegalArgumentException: No bean specified while using indexed properties
On 8/25/06, krishan rathi [EMAIL PROTECTED] wrote: Hi all I am getting following exception java.lang.IllegalArgumentException: No bean specified while using indexed properties in struts. MyForm Bean is public class ReportItemForm extends ActionForm { FormItem [] formItem=null; public void setItem(int index, FormItem formItem){ this.formItem[index] = formItem;} public FormItem getItem(int index){ if(formItem==null ||(formItem.length)==0) return new FormItem(); return formItem[index]; } and FormItem bean is specified like this public class FormItem { String formitem; int order; public int getOrder() {return order;}/*** @param i*/public void setOrder(int i) { order = i;}/*** @return*/public String getFormitem() { return formitem;}/*** @param string*/public void setFormitem(String string) { formitem = string;} i have set this array of FormItem i.eformItem() properly and the data is dispalyed correctly on the page like this html-el:hidden property=item[${count}].formItem / property name should be formitem and not formItem. html-el:text styleId=order property=item[${count}].order size=1 / but when i submitting this form i am getting following Exception java.lang.IllegalArgumentException: No bean specified can anybody help me. any help will be greatly appriciated. thanks Krishan. - Get your own web address for just $1.99/1st yr. We'll help. Yahoo! Small Business. -- Puneet
Getiing java.lang.IllegalArgumentException: No bean specified while using indexed properties in struts
Hi all i am getting following exception java.lang.IllegalArgumentException: No bean specified while using indexed properties in struts. MyForm Bean is public class ReportItemForm extends ActionForm { FormItem [] formItem=null; public void setItem(int index, FormItem formItem){ this.formItem[index] = formItem; } public FormItem getItem(int index){ if(formItem==null ||(formItem.length)==0) return new FormItem(); return formItem[index]; } } and FormItem bean is specified like this public class FormItem { String formitem; int order; public int getOrder() { return order; } /** * @param i */ public void setOrder(int i) { order = i; } /** * @return */ public String getFormitem() { return formitem; } /** * @param string */ public void setFormitem(String string) { formitem = string; } i have set this array of FormItem i.e formItem() properly and the data is dispalyed correctly on the page like this html-el:hidden property=item[${count}].formItem / html-el:text styleId=order property=item[${count}].order size=1 / but when i submitting this form i am getting following Exception java.lang.IllegalArgumentException: No bean specified can anybody help me. any help will be greatly appriciated. thanks Krishan. - Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail.
Struts - dynaforms and indexed properties
Hello I have a struts dynaform set up that takes an array of expense beans as a parameter When I submit 1 expense bean all works well but when I submit more than 1 expense bean the system returns a BeanUtils.populate error I am initializing my bean in the action. Any suggestions out there? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: 25 July 2006 16:44 To: [EMAIL PROTECTED] Subject: WELCOME to user@struts.apache.org Hi! This is the ezmlm program. I'm managing the user@struts.apache.org mailing list. I'm working for my owner, who can be reached at [EMAIL PROTECTED] Acknowledgment: I have added the address [EMAIL PROTECTED] to the user mailing list. Welcome to [EMAIL PROTECTED] Please save this message so that you know the address you are subscribed under, in case you later want to unsubscribe or change your subscription address. --- Administrative commands for the user list --- I can handle administrative requests automatically. Please do not send them to the list address! Instead, send your message to the correct command address: To subscribe to the list, send a message to: [EMAIL PROTECTED] To remove your address from the list, send a message to: [EMAIL PROTECTED] Send mail to the following for info and FAQ for this list: [EMAIL PROTECTED] [EMAIL PROTECTED] Similar addresses exist for the digest list: [EMAIL PROTECTED] [EMAIL PROTECTED] To get messages 123 through 145 (a maximum of 100 per request), mail: [EMAIL PROTECTED] To get an index with subject and author for messages 123-456 , mail: [EMAIL PROTECTED] They are always returned as sets of 100, max 2000 per request, so you'll actually get 100-499. To receive all messages with the same subject as message 12345, send an empty message to: [EMAIL PROTECTED] The messages do not really need to be empty, but I will ignore their content. Only the ADDRESS you send to is important. You can start a subscription for an alternate address, for example [EMAIL PROTECTED], just add a hyphen and your address (with '=' instead of '@') after the command word: [EMAIL PROTECTED] To stop subscription for this address, mail: [EMAIL PROTECTED] In both cases, I'll send a confirmation message to that address. When you receive it, simply reply to it to complete your subscription. If despite following these instructions, you do not get the desired results, please contact my owner at [EMAIL PROTECTED] Please be patient, my owner is a lot slower than I am ;-) --- Enclosed is a copy of the request I received. Return-Path: [EMAIL PROTECTED] Received: (qmail 3041 invoked by uid 99); 25 Jul 2006 15:43:47 - Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Jul 2006 08:43:47 -0700 X-ASF-Spam-Status: No, hits=1.8 required=10.0 tests=DNS_FROM_RFC_ABUSE,HTML_MESSAGE,MISSING_SUBJECT X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: local policy) Received: from [192.223.158.56] (HELO gw-col004.proxy.uk.fid-intl.com) (192.223.158.56) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Jul 2006 08:43:44 -0700 Received: from mail82.uk.fid-intl.com (mail82.uk.fid-intl.com [10.160.72.94]) by gw-col004.proxy.uk.fid-intl.com (8.13.6/8.13.6) with ESMTP id k6PFhNZb000974 for [EMAIL PROTECTED] ruts.apache.org; Tue, 25 Jul 2006 16:43:23 +0100 (BST) Received: from ukhil718nts.uk.fid-intl.com (ukhil718nts.uk.fid-intl.com [10.160.142.52]) by mail82.uk.fid-intl.com (8.11.7p1+Sun/8.11.7) with ESMTP id k6PFhNj23006 for [EMAIL PROTECTED] ruts.apache.org; Tue, 25 Jul 2006 16:43:23 +0100 (BST) Received: by ukhil718nts.uk.fid-intl.com with Internet Mail Service (5.5.2653.19) id PC0Y7ZAV; Tue, 25 Jul 2006 16:47:29 +0100 Message-ID: [EMAIL PROTECTED] From: Gallagher, Damien [EMAIL PROTECTED] To: '[EMAIL PROTECTED] truts.apache.org' [EMAIL PROTECTED] ruts.apache.org Subject: Date: Tue, 25 Jul 2006 16:43:23 +0100 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: multipart/alternative; boundary=_=_NextPart_001_01C6B001.0EA26A3E X-Virus-Checked: Checked by ClamAV on apache.org This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --_=_NextPart_001_01C6B001.0EA26A3E Content-Type: text/plain Regards, Damien. Damien Gallagher, Associate Software Engineer Fidelity Investments | FISC Development Ireland Phone Internal: 8737.5017 Phone External: +353.(0)91745017 Mail: [EMAIL PROTECTED] FISC Ireland Ltd., registered in Ireland no. 245656 | Registered office : Hardwicke House, Upper Hatch Street, Dublin 2. Any comments or statements made are not necessarily those of Fidelity Investments, its subsidiaries or affiliates. --_=_NextPart_001_01C6B001.0EA26A3E Content-Type: text/html Content-Transfer-Encoding: quoted-printable
having problem Using Indexed properties with Multi select inside logic iterate
Hi i am trying to use a multi select box in logic iterate in this way logic-el:iterate indexId=ctr id=admindepartment name=admindepartments html-el:select property=bookMapped(${ctr}) multiple=true size=2 html-el:options name=bean property=dbBookType/ /html-el:select /logic-el:iterate in the form bean i have following code. private Map selectedBooks; public Object getBookMapped(String index) { return selectedBooks.get(key); } public void setBookMapped(String index,Object value) { selectedBooks.put(key,value); } now in each multiple select box i am selecting multiple books but in the resulting map selectedBooks i am getting one value for each multiple selection then i had also tried using public void setBookMapped(String index,Object[] value) { selectedBooks.put(key,value); } but which is throwing an illegelargumenttype exception. please help. thanks in advance. krishan. krishan Rathi
having problem Using Indexed properties with Multi select inside logic iterate
Hi i am trying to use a multi select box in logic iterate in this way logic-el:iterate indexId=ctr id=admindepartment name=admindepartments html-el:select property=bookMapped(${ctr}) multiple=true size=2 html-el:options name=bean property=dbBookType/ /html-el:select /logic-el:iterate in the form bean i have following code. private Map selectedBooks; public Object getBookMapped(String index) { return selectedBooks.get(key); } public void setBookMapped(String index,Object value) { selectedBooks.put(key,value); } now in each multiple select box i am selecting multiple books but in the resulting map selectedBooks i am getting one value for each multiple selection then i had also tried using public void setBookMapped(String index,Object[] value) { selectedBooks.put(key,value); } but which is throwing an illegelargumenttype exception. Can anybody suggest how should i use indexed properties to tackle a group of multi select boxes. please help. thanks in advance. krishan. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: newbie question on indexed properties and validation
Thanks, this is very much appreciated. Is this something that is going to make it into a Struts Base release? -Original Message- From: Niall Pemberton [mailto:[EMAIL PROTECTED] Sent: Thursday, June 22, 2006 11:15 AM To: Struts Users Mailing List Subject: Re: newbie question on indexed properties and validation Importance: High You can do this: http://www.niallp.pwp.blueyonder.co.uk/strutsvalidatorextends.html Niall On 6/15/06, Givler, Eric [EMAIL PROTECTED] wrote: I was following this article (MS Powerpoint presentation by James Turner) here: http://www.strutskickstart.com/IndexedPropertiesandValidation.ppt When, I tried to cobble this all into a working example, if I left out multiple values (in a four record grid), I'd get one struts validation error back from validator. Is this the normal behavior when the properties are indexed? My ultimate goal would be to either show the message: LastName is required for record # {0} (and use the index here) OR: use the new ErrorStyle tag and highlight any field in error and provide the single error at the top. Can anyone point me to a working example of a multi record entry screen that has this type of behavior, or even decent articles on multi-record edits with validation/error handling (using validator or otherwise)? Thanks! Eric Givler Department of Environmental Protection/PA - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: newbie question on indexed properties and validation
You can do this: http://www.niallp.pwp.blueyonder.co.uk/strutsvalidatorextends.html Niall On 6/15/06, Givler, Eric [EMAIL PROTECTED] wrote: I was following this article (MS Powerpoint presentation by James Turner) here: http://www.strutskickstart.com/IndexedPropertiesandValidation.ppt When, I tried to cobble this all into a working example, if I left out multiple values (in a four record grid), I'd get one struts validation error back from validator. Is this the normal behavior when the properties are indexed? My ultimate goal would be to either show the message: LastName is required for record # {0} (and use the index here) OR: use the new ErrorStyle tag and highlight any field in error and provide the single error at the top. Can anyone point me to a working example of a multi record entry screen that has this type of behavior, or even decent articles on multi-record edits with validation/error handling (using validator or otherwise)? Thanks! Eric Givler Department of Environmental Protection/PA - 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: newbie question on indexed properties and validation
I can provide a zip of the workspace I was doing for this if that would help. I just can't seem to get the multiple errors. Can the html:text tag determine that a row's value is wrong in a multi-record form bean and color it? How would it know if it's only getting back one error as opposed to a number of them? Also, JDeveloper (10.1.2.1) refuses to recognize the errorStyle tag, though if I open the struts-html.tld file that is in WEB-INF, it appears directly under the tag class that JDeveloper says does not support it. -Original Message- From: Givler, Eric [mailto:[EMAIL PROTECTED] Sent: Thursday, June 15, 2006 9:44 AM To: Struts Users Mailing List Subject: newbie question on indexed properties and validation I was following this article (MS Powerpoint presentation by James Turner) here: http://www.strutskickstart.com/IndexedPropertiesandValidation.ppt When, I tried to cobble this all into a working example, if I left out multiple values (in a four record grid), I'd get one struts validation error back from validator. Is this the normal behavior when the properties are indexed? My ultimate goal would be to either show the message: LastName is required for record # {0} (and use the index here) OR: use the new ErrorStyle tag and highlight any field in error and provide the single error at the top. Can anyone point me to a working example of a multi record entry screen that has this type of behavior, or even decent articles on multi-record edits with validation/error handling (using validator or otherwise)? Thanks! Eric Givler Department of Environmental Protection/PA - 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]