File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doubt in ActionForms

 
Kalyana Sundaram
Ranch Hand
Posts: 94
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its understable that the ActionForms are meant for collectng the data enetered by the users in the view component which is usually a JSP. In this scenario, how do a ActionForm could have a property which is a user defined JavaBeans like Employee, Comments

class MyActionForm extends ActionForm {

private String id;
private Employee employee;

getters()
setters(xxx)
}

My doubt is how do the framework populates the input data into such properties and makes it available to the Action

Thanks in Advance
 
Vani Bandargal
Ranch Hand
Posts: 82
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let Say you have a User Defined Bean Employee like this

class Employee
{
private String firstName;
private String lastname;

public String getFirstName() {
return firstName;
}

public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}

Then in your MyActionForm you can have something like this:
class MyActionForm extends ActionForm {

private String id;
private Employee employee;

getters()
setters(xxx)
}

private Employee getEmployee()
{
return employee;
}

private void setEmployee(Employee employee)
{
this.employee=employee;
}


If you are using Struts tags in Jsp, name attribute will take care of these kinds of nested bean properties
<html:text property="firstName" name="employee" />


Let me know if you are able to see results
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic