I'm trying to learn struts so I am experimenting on some simple web programs. I have a table that displays list of users and in the last row of each column I made 3 submit buttons that allows the user to VIEW, EDIT and DELETE each row. Also I also name the three button with property ManageUser.
What I want is for me to have a reference on what button was click. I did make a form bean with ManageUser as private variable so I can get the value if its VIEW, EDIT or DELETE.
But when I try to extract the value from the javabean in the action class to which this form bean is map, no value can be retrieved and Myform.getManageUser() returns null.
Here's my struts config xml.
I have done a form bean with html text field and password and it works fine. I'm just experimenting if I could do it with buttons.. Can I do it this way? Thanks.
Sean Clark ---> I love this place!!!
Me ------> I definitely love this place!!!
The reason the property is null is that you have specified the wrong property name in your <html:submit> tag. It should be manageUser, not ManageUser.
Here are a couple of more suggestions:
Move the <html:form> stanza so that it is inside the <logic:iterate> stanza. That way you will have a separate form for each row. When one of the buttons in a row is pressed, only the data for that row will be submitted.
Remove the line
It isn't going to work. The result of this would be that the User id of the last user is always the one in the request, not the user of the row for which a submit button was pressed. Replace it with:
And add a userId property to your ActionForm bean.
You might also want to consider using a LookupDispatchAction. [ July 18, 2007: Message edited by: Merrill Higginson ]