put transforobject values into javabean

Discussion in 'Java' started by Eirik Eldorsen, Jan 14, 2004.

  1. Does anybody now if it is possible to put the values of a transferobject
    (formerly known as Value Object) into a JavaBean in a simple way.

    I have a method that returns a UserTO object.
    A webpage uses this method. What I want to do is put all the values from
    this object into this JavaBean:
    <jsp:useBean name="user" class="transferobjects.UserTO" />


    Eirik Eldorsen
     
    Eirik Eldorsen, Jan 14, 2004
    #1
    1. Advertising

  2. Eirik Eldorsen

    visionset Guest

    "Eirik Eldorsen" <> wrote in message
    news:bu3ku0$pj5$...
    > Does anybody now if it is possible to put the values of a transferobject
    > (formerly known as Value Object) into a JavaBean in a simple way.
    >
    > I have a method that returns a UserTO object.
    > A webpage uses this method. What I want to do is put all the values from
    > this object into this JavaBean:
    > <jsp:useBean name="user" class="transferobjects.UserTO" />
    >
    >
    > Eirik Eldorsen
    >

    Get yourself the Apache BeanUtils package, under Commons.
    http://jakarta.apache.org/commons/beanutils.html

    Specifically you need to look at the BeanUtils & PropertyUtils classes.

    Based on reflection they are very useful for this kind of thing

    --
    Mike W
     
    visionset, Jan 14, 2004
    #2
    1. Advertising

  3. Thank you! This was exatly what I was looking for. However I have one
    problem now.

    To load the bean for use in a form i do the following:
    <jsp:useBean id="user" class="transferobjects.UserTO" scope="session" />
    PropertyUtils.copyProperties(user, um.getUser(1));

    When the form has been edited, I write this to save the changes:
    <jsp:setProperty name="user" property="*"/>
    um.updateUser((UserTO) session.getValue("user"));

    My problem is that when I try to delete a field in the form, this is'nt
    registered.
    Example: I want to remove my name, and change the field firstname from
    "Eirik" to "".

    Any suggestions?

    "visionset" wrote in message:
    > Get yourself the Apache BeanUtils package, under Commons.
    > http://jakarta.apache.org/commons/beanutils.html
    >
    > Specifically you need to look at the BeanUtils & PropertyUtils classes.
     
    Eirik Eldorsen, Jan 15, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?aHV6eg==?=

    Put array values into a single variable

    =?Utf-8?B?aHV6eg==?=, Dec 6, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    3,197
    =?Utf-8?B?aHV6eg==?=
    Dec 6, 2004
  2. Andrew Thompson

    Missing JavaBean..

    Andrew Thompson, Jul 7, 2003, in forum: Java
    Replies:
    4
    Views:
    437
    Wendy S
    Jul 7, 2003
  3. A Bag Of Memes

    Re: Use one javabean for each table?

    A Bag Of Memes, Jul 24, 2003, in forum: Java
    Replies:
    0
    Views:
    447
    A Bag Of Memes
    Jul 24, 2003
  4. loyed.preetham
    Replies:
    0
    Views:
    452
    loyed.preetham
    Oct 10, 2008
  5. Harry Nash
    Replies:
    9
    Views:
    151
    Jean-Michel
    Mar 1, 2009
Loading...

Share This Page