• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts FORM

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my struts JSP page - I have text boxes for various ActionForm - User, Order, OrderItem, Address, etc. In my action page - how can I map different ActionForm in execute method ?

JSP :

<html:text property="username" size="24" /> // FOR USER POJO
<html:text property="itemnumber" size="24" /> // FOR ORDER POJO

How do I retrieve values in execute method in actionForm ??

public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception
{

I HAVE DOUBTS HERE !! I HAVE TO SAVE DATA IN USER, ORDER, ORDERITEM, ADDRESS POJO.

UserForm userform = (UserForm) actionForm;

HOW CAN I MAP to Order, OrderItem, Address form ? Please help.




 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am not understand your question clearly. can you post your UserForm ?
 
arul meh
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<html:form action="/postProcess">
Employee Information :<table>
<tr>
<td class="tdLabel">
ID
</td>
<td>
<html:text disabled="true" property="username" size="20" /> // MY PROBLEM
<html:errors property="username" />
</td>
</tr>

Manager Information
<tr>
<td class="tdLabel">
ID
</td>
<td>
<html:text disabled="true" property="username" size="20" /> // MY PROBLEM
<html:errors property="username" />
</td>
</tr>

So, I have two kinds of user information on my form. I need to save it in database. I am not able to decide - what should I name property as ? This form is not working. It is just saving first user information. Please help.

------------------------------------------------------------------------------
When this form is loaded, I have set two forms as before loaing above JSP page :

UserForm employee= new UserForm ();
UserForm manager= new UserForm ();
return mapping.findForward("success");

I am struggling with saving two kinds of User Information on same page. Please help.
 
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why do you have to use 4 different POJO to save to database?

can't you use a FormBean instead and pass the FormBean to your business class?

 
arul meh
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Davie,

I need to save two records for User - manager type and employee record. So, I have username text on the JSP. I am not able to decide - how can I display it for employee type and manager type. Could you explain me more - what you are talking about ?

Thanks.
 
Davie Lin
Ranch Hand
Posts: 294
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

i am not understand your question clearly. can you post your UserForm ?



First things frist, you have not post your UserForm on here yet, so it's really hard to help you if we can't understand what your issue is.

and please use Code tag

Your original question didn't make much sense, how do you have various ActionForms for a single JSP page? Does that mean you have more than one <html:form> tag in your JSP? You can only define one form per action because you're only passing one ActionForm argument to your execute method, please think about that and rephrase your question in order for other people to help you with your issue.

Thanks
 
reply
    Bookmark Topic Watch Topic
  • New Topic