• 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

Struts2 form problem

 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear all,
im new to struts 2 and it is so nice but there is a problem i still didnt found to it a solution.
the problem is:that i make useBean and UserAction(that will be the controller)So i need to pass parameters from the jsp using the struts2 form to the StrutsAction .If i put the properties inside the Action with their setters and gerters it works.but it doesnt good design.So i separate the properties into Bean .then the controller UserAction recievies null parameters.
Here the code in UserAction that doesnt work:
public String goToWelcome() throws Exception {
System.out.println("Second Success Action");
UserBean userBean=new UserBean();
System.out.println("getUserName="+userBean.getUserName());
System.out.println("getPassword="+userBean.getPassword());
return "goToWelcomePage";
}
but if i put the properies inside the action to be like this:
public String goToWelcome() throws Exception {
System.out.println("Second Success Action");
UserBean userBean=new UserBean();
System.out.println("getUserName="+this.getUserName());
System.out.println("getPassword="+this.getPassword());
return "goToWelcomePage";
}

it will works. please help i need to separate beans from controller as a best practice.
 
hani Ibrahim
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please Help how to separate the bean from action class in struts2 pease.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic