Link to home
Start Free TrialLog in
Avatar of jaggernat
jaggernat

asked on

BeanUtils

hello  experts,

I want to know what is BeanUtils. In my application, i have an Action form bean which collects the data entered by users.
This data from the Action Form bean should be transfered to Value Objects, and value objects should display the data.
Can we acchieve this using BeanUtils?


thanks in advance,
J

Avatar of aozarov
aozarov

Avatar of jaggernat

ASKER

can you give an example?

thanks for the reponse,
J
public class MyBean
{
private String name;
    MyBean(String name)
{
this.name = name;
}

public String getName()
{
return name;
}

public void setName(String name)
{
this.name = name;
}
}

MyBean bean1 = new MyBean();
bean1.setName("this_is_my_name");
MyBean bean2 = new MyBean();
BeanUtils.copyProperties(bean1, bean2);
System.out.println(bean2.getName());; // This should print "this_is_my_name"

Is this what you were looking for?
Forgot to add empty constructor:
Add this to MyBean

public MyBean()
{
// empty constructor
}
what i am looking for:

i have a frontend html form in Struts. When the frontend form(with values) is submitted, the ActionForm is filled with the values which the user filled in the front end form. This informaiton in the Action Form is passed to the value objects and the value objects calls  session beans.

We are using value objects to decouple the Presentation Layer(containing the action form) and the Business Layer (containing session bean).

So for the time being, i want to take the information from the action form bean and pass it to vaue objects and display the values in WSAD console. then my second step would be to invoke the session bean using value objects.

 Do you think the program you gave above would solve my purpose.
I am new to this, so not really sure.

thanks for the prompt response,
J

ASKER CERTIFIED SOLUTION
Avatar of aozarov
aozarov

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Did you try it?