?
Solved

BeanUtils

Posted on 2005-03-30
9
Medium Priority
?
140 Views
Last Modified: 2011-09-20
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

0
Comment
Question by:jaggernat
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
9 Comments
 
LVL 10

Author Comment

by:jaggernat
ID: 13668507
can you give an example?

thanks for the reponse,
J
0
 
LVL 15

Expert Comment

by:aozarov
ID: 13668541
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?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 15

Expert Comment

by:aozarov
ID: 13668547
Forgot to add empty constructor:
Add this to MyBean

public MyBean()
{
// empty constructor
}
0
 
LVL 10

Author Comment

by:jaggernat
ID: 13668698
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

0
 
LVL 15

Accepted Solution

by:
aozarov earned 2000 total points
ID: 13668723
It will not solve your problem but if you take/copy the concept then it will work as you expect (we actually did the same thing).
If Both ActionForm and you DAO object are beans (have getXXX() setXXX() for its properties [replace XXX with the name of the property]),
which I think they are then calling BeanUtils.copyProperties(your_action_form_variable, your_dao_variable); will do the job you are expecting
and copy the values from the action form to the DAO object.
0
 
LVL 15

Expert Comment

by:aozarov
ID: 13678549
Did you try it?
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month12 days, 17 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question