I have the following line of code in my action class's perform method: request.setAttribute("test10","This is a test");
In the jsp that the action forwards to I have the following line of code: <% out.println(request.getAttribute( "test10")); %> I get null as the value. What am I missing here? thanks, sriram ----- Original Message ----- From: "Maturo, Larry" <[EMAIL PROTECTED]> To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Thursday, January 31, 2002 10:48 AM Subject: RE: Help with table with edit buttons > Hi Patrick, > > Wow! I had no idea you could put a form within an iterate. > What a neat idea! It sort of puts things inside out to the > way you would normally think about them. Thank you. > > I also found another way of handling the problem. I fake > an array property by having setters that only saves the > index, and then a function to retrieve the index, and then > I use the indexed="true" property in the submit. > > For example: > > In the form bean: > > private int editIndex = -1; > > public final void setEditCmd(int index, String cmd){ > editIndex = index; > } > > > public int getEditIndex() { > return editIndex; > } > > In the jsp: > <logic:iterate id="org" name="<%= Constants.ORG_LIST %>" scope="session" > type="com.athensgroup.projtrack.controller.org.OrganizationForm"> > <tr> > <td> > <html:submit indexed="true" property="editCmd" value="Edit" > /> > </td> > <td> > <bean:write name="org" property="mnemonic" > filter="true"/> > </td> > <td> > <bean:write name="org" property="fullName" > filter="true"/> > </td> > <td> > <bean:write name="org" property="type" > filter="true"/> > </td> > <td> > <bean:write name="org" property="parentOrgName" > filter="true"/></td> > </tr> > </logic:iterate> > > In the action class to set up the form: > request.getSession().setAttribute(Constants.ORG_LIST,orgList); > > In the action class to handle the submit: > OForm aForm = (OForm) form; > int index = aForm.getEditIndex(); > ArrayList orgList = (ArrayList) > request.getSession().getAttribute(Constants.ORG_LIST); > item = (OrganizationForm) orgList.get(index); > id = item.getId(); > > -- Larry > > -----Original Message----- > From: Patrick Refondini [mailto:[EMAIL PROTECTED]] > Sent: Thursday, January 31, 2002 4:29 AM > To: Struts Users Mailing List > Subject: Re: Help with table with edit buttons > > > Hi, > facing a similar issue I addressed it by having a form per record > instead of a form for the whole table. > Then everything becomes easier :) hereafter a code sample to illustrate. > > <logic:iterate id="taskForm" indexId="taskFormIndex" > name='<%=TaskAction.TASK_FORM_LIST%>' scope="session"> > <html:form action="/taskView2"> > <tr> > <td> > <html:hidden name="taskForm" property="index"> > <bean:write name="taskFormIndex" /> > </html:hidden> > > <html:hidden name="taskForm" property="id"> > <bean:write name="taskForm" property="id"/> > </html:hidden> > > <html:submit property="edit"> > <bean:message key="button.edit"/> > </html:submit> > > <html:submit property="delete"> > <bean:message key="button.delete"/> > </html:submit> > > <html:submit property="assign"> > <bean:message key="button.assign"/> > </html:submit> > </td> > <td> > <bean:write name="taskForm" property="name"/> > </td> > <td> > <bean:write name="taskForm" property="projectId"/> > </td> > </tr> > </html:form> > </logic:iterate> > > Each taskForm property represents : > 1. Data corresponding to a database task record > taskForm.id property holds the primary key value of a task record. > 2. Data useful for view control > taskForm.index property holds the index of the taskForm object in the > iterated Collection an ArrayList in this particular case. > Useful for editing the selected object without querying the database. > > I hope it might help, Patrick > > > > Maturo, Larry wrote: > > >Hi David, > > > >I have tried endless variations of the hidden variable > >in each row trick you suggested. It seems like it should > >be very simple, but each time I run into the problem of > >the variable I pass in to "value" does not get evaluated, > >instead it comes through in the html as the literal I > >pass in to it. Below is an example of what I have > >tried doing. As you can see, I have put two variations > >of the variable I am trying to use in the table to make > >sure that part is working, and it is. Can I ask you how > >you got this to work? > > > >Thank you in advance for any help. > > > >-- Larry Maturo > > [EMAIL PROTECTED] > > > ><logic:iterate id="org" name="<%= Constants.ORG_LIST %>" scope="session" > >type="com.athensgroup.projtrack.controller.org.OrganizationForm"> > > <bean:define name="org" property="id" id="orgId" /> > > <tr> > > <td> > > <html:submit property="id" value="Edit" /> > > </td> > > <td><bean:write name="org" property="mnemonic" > >filter="true"/></td> > > <td><bean:write name="org" property="fullName" > >filter="true"/></td> > > <td><bean:write name="org" property="type" filter="true"/></td> > > <td><bean:write name="org" property="id" filter="true"/></td> > > <td><bean:write property="orgId" filter="true"/></td> > > <td> > > <bean:write name="org" property="parentOrgName" > >filter="true"/> > > <html:hidden property="theOrgId" value="orgId" /> > > </td> > > </tr> > ></logic:iterate> > > > >-----Original Message----- > >From: David M. Karr [mailto:[EMAIL PROTECTED]] > >Sent: Saturday, January 26, 2002 1:00 PM > >To: [EMAIL PROTECTED] > >Subject: Re: Help with table with edit buttons > > > > > >>>>>>"Larry" == Larry Maturo <Maturo> writes: > >>>>>> > > > > Larry> I have a table that displays information on a number of > > Larry> items. Each table entry has an edit button, so that you > > Larry> can edit the information on that item. I use an iterate > > Larry> tag to populate the table. My problem is that I don't > > Larry> know how to save something indicating which edit button > > Larry> they pressed. > > > > Larry> My best guess was to use an onclick handler to set a > > Larry> hidden variable. My problem is that while I know how > > Larry> to create the hidden variable (using the struts hidden > > Larry> tag) I don't know how to set it in the onclick handler. > > > >One approach is not to try to determine which edit button was pressed, but > >to > >use a hidden field in a form in each table row to encode the OID of the > >object > >in that row. Each form row submits to the same action. > > > > > > -- > To unsubscribe, e-mail: > <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: > <mailto:[EMAIL PROTECTED]> > > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>