Meaningless Drivel is fun!*
The moose likes Struts and the fly likes Struts2 form problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2 form problem" Watch "Struts2 form problem" New topic
Author

Struts2 form problem

hani Ibrahim
Ranch Hand

Joined: Sep 06, 2006
Posts: 182
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

Joined: Sep 06, 2006
Posts: 182
Please Help how to separate the bean from action class in struts2 pease.
 
Don't get me started about those stupid light bulbs.
 
subject: Struts2 form problem
 
Similar Threads
Struts2 Internationalization
issue reading fields from form in struts2
Struts2: Cannot submit action after a second validation attempt.
iterate over nested ArrayList in struts2
JAAS with JBOSS and Struts2