• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Problem mapping to form bean

 
Ranch Hand
Posts: 426
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

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.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Mark Reyes
Ranch Hand
Posts: 426
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Merill,

Thanks for your patient analysis of my rather "messy" code and giving valuable suggestion on how to execute what I really wanted even if I really didnt directly ask about it

I did tried what you suggest about LookupDispatchAction and found it really useful since I could separate the processing into different ActionForward sequence instead of using if-else statement..



My Struts Config..

Thanks again...
 
And when my army is complete, I will rule the world! But, for now, I'm going to be happy with this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic