Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts2 form problem

 
hani Ibrahim
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Please Help how to separate the bean from action class in struts2 pease.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic