aspose file tools*
The moose likes Beginning Java and the fly likes get a bean to populate itself Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "get a bean to populate itself" Watch "get a bean to populate itself" New topic
Author

get a bean to populate itself

David J Smith
Greenhorn

Joined: Jun 09, 2009
Posts: 24
I have a bean class lets say called UserBean. I also have a class (Utils) that contains a method returning a UserBean let say Utils.getUser. Is it possible to use this method inside a UserBean object to populate itself. I.e to do what line 11 is trying to do below.



Instead of having to write


What I want to do is use UserBean in a jsp but I need to populate that bean with information that I get from the Utils class (in this example data from LDAP).
Danilo Dadonas
Ranch Hand

Joined: Aug 24, 2007
Posts: 59

Hi David. In this case you're trying to clone a bean. You can implement the Cloneable interface, like this:



...and now you can do this:



Dadonas


Dadonas<br /> <br />Don't gain the world and lose your soul.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61417
    
  67

More of a genera Java question than a JSP one... so moved to a more appropriate locale.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
David J Smith
Greenhorn

Joined: Jun 09, 2009
Posts: 24
Thanks for your reply but the problem is, I want it to populate itself, not just create a new object. Reason being, I want the UserBean object to be a session bean in my jsp. So as I see it, I have to declare the <jsp:usebean> and then populate the data in the bean. How can I use the method I have created in my Utils class (which returns a UserBean) to populate this session bean?

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: get a bean to populate itself