File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes doubt in ActionForms Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "doubt in ActionForms" Watch "doubt in ActionForms" New topic
Author

doubt in ActionForms

Kalyana Sundaram
Ranch Hand

Joined: Mar 18, 2005
Posts: 94
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


Only those who will risk going too far can possibly find out how far one can go !!!
Vani Bandargal
Ranch Hand

Joined: Oct 06, 2005
Posts: 82
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: doubt in ActionForms