?
Solved

copy from one bean to other bean

Posted on 2014-01-10
7
Medium Priority
?
450 Views
Last Modified: 2014-02-07
Hi,

I am going through below link on how to copy from one bean to other bean
http://www.avajava.com/tutorials/lessons/how-do-i-copy-properties-from-one-bean-to-another.html?page=1


I have nto clearly understood how author is copy pasting.

I also did not see usage of ToStringBuilder method.

What is the practical use of ToStringBuilder method.

I also wonder why there is dependency bewteen
BeanUtils on the Commons lang and commons util jars

please advise
Any links resources ideas highly appreciated. Thanks in advance
0
Comment
Question by:gudii9
[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
  • 4
  • 3
7 Comments
 
LVL 35

Accepted Solution

by:
girionis earned 2000 total points
ID: 39773636
These classes are part of the Apache Jakarta Commons, in order to find out how they copy data from one bean to another you better look at the source code. I guess they use reflection to find the properties of one bean, and use the mutator methods of the second bean to set the values.
0
 
LVL 7

Author Comment

by:gudii9
ID: 39783985
reflection to find the properties of one bean

How to use the reflection and mutation to find the properties of beans. please advise
0
 
LVL 35

Expert Comment

by:girionis
ID: 39789381
I think the best place to start is the java tutorial on reflection.
0
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
LVL 7

Author Comment

by:gudii9
ID: 39816253
I am referring the link(http://docs.oracle.com/javase/tutorial/reflect/class/index.html)

They said as below which is not clear to me.
Every object is either a reference or primitive type
all of the wrapper classes for primitive types such as java.lang.Double, the interface java.io.Serializable, and the enum javax.swing.SortOrder.


How object can be primitive type?
also how serializable and SortOrder are primitive types.
please advise
0
 
LVL 35

Expert Comment

by:girionis
ID: 39817841
It says the wrappers for the primitive types, not the primitive types. Read it again, it does not say the primitive types are objects.
0
 
LVL 7

Author Comment

by:gudii9
ID: 39818740
sounds good.

Every object is either a reference or primitive type


But above statement does not say wrapper. I wonder why. please advise
0
 
LVL 7

Author Comment

by:gudii9
ID: 39824948
I have not understood the gist of this example. what exactly author is trying to do.

     public FromBean(String name, String aProp, String bProp) {
            this.name = name;
            this.aProp = aProp;
            this.bProp = bProp;
      }

      public String getAProp() {
            return aProp;
      }

      public void setAProp(String prop) {
            aProp = prop;
      }


why there is no this for  setter methods (aProp = prop;)similar to constructor (this.name = name;)

why FromBean and ToBean has common properties like name, bProp

Is no argument constructor is mandotory for a bean even when there is argument constructor.
please advise
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Suggested Courses

801 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