Check out this link from the wiki: http://wiki.apache.org/struts/StrutsCatalogLazyList, the section on Indexed properties. In order for it to work, you have to set the id attribute to the same as the indexed property.
Kjersti On 24/02/06, Hans-Peter Petek <[EMAIL PROTECTED]> wrote: > > Hello, > > i am really confused now - there can be only a small mistake ... :-(( > If i have no getter and setter for right, the app is running, but after > submitting the form, the right-object is null (of course) > if i set the getter and setter for right, i get: > [Servlet-Fehler]-[BeanUtils.populate]: java.lang.NullPointerException > > In this example, > <logic:iterate id="right" name="authRightForm" property="objectNames"> > right and objectName must be the same, or not? objectNames is the > ArrayList > (or Array) of my right-objects, but with which property is id mapping? > because i get in the request the names right[xx].a, right[yy].a, ... > > Because in my form-bean i only have a list of objects (e.g. ObjectNames), > this is an arraylist. > But when i use objectName as property and also objectName as id (which > maps > to my objectNames Arraylist in the form), i get Error 500: > ServletException > in 'layout_inside.jsp': ServletException in 'authright-body.jsp': Cannot > create iterator for this collection (after the 29th entry on the webpage > ...?!?!?!!?) > > In you example, do i have to have a property called right in my > actionform, > if yes, what type? > > thanks a lot for help > Hans > > _____ > > Von: Brian Holzer [mailto:[EMAIL PROTECTED] > Gesendet: Donnerstag, 23. Februar 2006 21:53 > An: struts-user@jakarta.apache.org > Betreff: Fwd: AW: logic:iterate > > > Hey Hans, > I'll give this another try. I think you are right and you don't need > the > nested tags for this situation. First off, it says in the docs that an > Array will work with this tag, but I've only used ArrayLists. I don't > forsee any differences in how the tag works with either. First off your > properties (a, b, c) need to be defined as Strings and not Integers. So > I'm > guessing that you have an object definition like so after the above > changes. > > public class ObjectName { > public String a; > public String b; > public String c; > > methods..... > } > > in your ActionForm you have an Array defined which will hold a number of > these ObjectName instances and a getter getObjectNames(). Your jsp should > look like the following: > > <logic:iterate id="right" name="authRightForm" property="objectNames"> > <tr> > <td>LabelForObject: </td> > <td> > <html:radio name="right" property="a" value="0" /> > <html:radio name="right" property="a" value="1" /> > <html:radio name="right" property="a" value="2" /> > </td> > <td> > <html:radio name="right" property="b" value="0" /> > <html:radio name="right" property="b" value="1" /> > <html:radio name="right" property="b" value="2" /> > </td> > <td> > <html:radio name="right" property="c" value="0" /> > <html:radio name="right" property="c" value="1" /> > <html:radio name="right" property="c" value="2" /> > </td> > > </tr> > </logic:iterate> > > Give this a try, I think this is what you are looking for. > > > > ------------------------------------------------------------ > Brian Holzer > IT Analyst > Saskatchewan Government Insurance > email: [EMAIL PROTECTED] > phone: (306) 751-1629 > fax: (306) 569-7683 > > >>> "Hans-Peter Petek" <[EMAIL PROTECTED]> 23/02/2006 9:12:47 am >>> > Hi, > > i don´t think so, because i do not have a "department -> customer" > structure > (1 to many structure). i only have a list of objects, each object has 3 > properties (a, b, c) of type integer (a,b,c can have a value from 0 to 2). > > I want to display a list of these ojects and 3 groups of either 3 > radio-buttons. if the value of a is 2, the last radio-button of the first > group is selected, if the value of c is 0, the first radio-button of the > 3rd > group is selected ... > > OBJECT1 0 1 2 0 1 2 0 1 2 (0,1 and 2 is always a group, i can > select one of the entry, 0 or 1 or 2 in each group -> so i will get for a, > b, and c a value of 0, 1, or 2) > OBJECT2 ... > ... > > To display this is not the problem, this is alread working, my ActionForm > has a property of "rights" which in an Array of my objects. > private Right[] rights; > > The problem is, when i´m submitting the form, i do not get the valus, the > array is either null, or, if i use the modified version (see below) i get > a > [BeanUtils.populate]: java.lang.NullPointerException :-(( > > Can anyone help me in this case? Or does the nested-tag really is required > for that - but i dont think so ... it has to work with iterate too, > doesn´t > it? > > thanks in advance > Hans > > _____ > > Von: Brian Holzer [mailto:[EMAIL PROTECTED] > Gesendet: Donnerstag, 23. Februar 2006 15:15 > An: struts-user@jakarta.apache.org > Betreff: Fwd: logic:iterate > > > Hey Hans, > I think you might want to use the nested tags for what you are trying to > do. Depending on the version of struts you are using, the nested taglib > could be included with the Struts distribution. Here is a link to some > tutorials etc. on the nested tags > http://www.keyboardmonkey.com/next/index.jsp > > > > ------------------------------------------------------------ > Brian Holzer > IT Analyst > Saskatchewan Government Insurance > email: [EMAIL PROTECTED] > phone: (306) 751-1629 > fax: (306) 569-7683 > > >>> "Hans-Peter Petek" < [EMAIL PROTECTED] > 23/02/2006 4:24:12 am >>> > Hi, > > does anyone knows a really good docu (with examples) how to use the > iteration (with indexed tags)? > > Because my indexed iteration is not working, the first time the values are > fine (loading), but after submitting the data, the changes are not mapped > to > the array (or arraylist). > > Here is the problem again, maybe someone knows a good doc or has an idea > ...? > > I have modified the iteration from <logic:iterate id="right" ... to > <logic:iterate id="rightlist_ary" ... because that's my array I want to > have > filled, but after submitting the form I get ... > [BeanUtils.populate]: java.lang.NullPointerException > > any ideas? help would be great, thanks. > > > *** *** *** > > i have a problem with the logic:iterate tag ... i want to show a list of > objects (which habe attributes with values of 0 or 1 or 2) > > I want to show them in a list of radio-elements > > OBJECT 1 0 1 2 0 1 2 0 1 2 > OBJECT 20 1 2 0 1 2 0 1 2 > ... > > where 0,1,2 is a radio-element (one of 0 or 1 or 2 can be choosen). > > > > public class AuthRightForm extends ActionForm { > > private Right[] rightlist_ary; > > get / set ... > > // after loading > rightlist_ary = new Right[10]; > // filling rightlist_ary from DB ... > ... > > > <logic:iterate id="right" name="authRightForm" indexId="idx" > property="rightlist_ary"> > <tr> > <logic:present name="right"> > <logic:notEmpty name="right"> > <td><bean:write name="right"/>, Index = <bean:write name="idx"/> > > <td><html:radio name="right" property="val_owner" value="0" > indexed="true"/></td> > <td><html:radio name="right" property="val_owner" value="1" > indexed="true"/></td> > <td><html:radio name="right" property="val_owner" value="2" > indexed="true"/></td> > > </td> > </logic:notEmpty> > </logic:present> > </tr> > </logic:iterate> > > > The displaying of the values is working, so if Object 1, property 1 has a > value of 2, the 3rd radio-element is selected - this works fine. But, > after > submitting the form, I do not see the changed values (if I change the > radio-buttons). The value of rightlist_ary is always null - so I do not > see > any objects in the list any more. > > The request-object has values like that: > right[3].val_owner -> 1 > right[2].val_owner -> 2 > right[1].val_owner -> 1 > ... > > Does anyone has a solution for that? > > Thanks a lot > HP > > > > > **********DISCLAIMER********** > > This e-mail and any files transmitted with it are confidential and > intended > solely for the use of the individual or entity to whom they are addressed. > If you are not the named addressee, please notify the sender immediately > by > e-mail if you have received this e-mail by mistake and delete this e-mail > from your system. If you are not the intended recipient you are notified > that using, disclosing, copying or distributing the contents of this > information is strictly prohibited. > > **********DISCLAIMER********** > > > > **********DISCLAIMER********** > > This e-mail and any files transmitted with it are confidential and > intended > solely for the use of the individual or entity to whom they are addressed. > If you are not the named addressee, please notify the sender immediately > by > e-mail if you have received this e-mail by mistake and delete this e-mail > from your system. If you are not the intended recipient you are notified > that using, disclosing, copying or distributing the contents of this > information is strictly prohibited. > > **********DISCLAIMER********** > > >