• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

get a bean to populate itself

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).
 
Ranch Hand
Posts: 59
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
More of a genera Java question than a JSP one... so moved to a more appropriate locale.
 
David J Smith
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:)
 
reply
    Bookmark Topic Watch Topic
  • New Topic