Does somebody have an implemented example for a DTO

Discussions

General J2EE: Does somebody have an implemented example for a DTO

  1. Hi together,

    the only thing i want to know is, how the DTO is "send" to the client-side.
         - should i use serializable?
         - do i send the DTO-Object as "Object" or as
           "DTO-Object" itself?
         - where is the DTO Interface "class",
           on the server-side, on the client-side or
           on both-sides?

    That is what i have:
    ------------------------
    ------------------------

       //In the SessionBean
    -----------------------------------------------------------
       ...
       //Method call to send DTO to client-side
       public Object getResourceData()
       {
          dto=new DataTransferObject(); //create DTO
          dto.setGeneralData(x,y); //put Data into DTO
          return dto; //send DTO
       }
       ...
    -----------------------------------------------------------
       //In the SessionBean
    -----------------------------------------------------------
       ...
       //Method call to send DTO to client-side
       private void getDTO()
       {
          //'dtoGet' is the Interface DTO_GET (only getMethods)
          dtoGet = (DTO_GET)ejbObject.getResourceData();
       }
       ...
    -----------------------------------------------------------

    The DTO-Class implements serializable
    The DTO_GET Interface implements serializable too
    The Interface-class is on the client side

    BUT IT DOES NOT WORK, cause i receive a typecast error

    Can somebody help me ????

    thank you :-)

    Threaded Messages (3)

  2. Re: DTO questions[ Go to top ]

    Q: should i use serializable?
    A: Yes. Every object sent over network need to be Serializable.

    Q: do i send the DTO-Object as "Object" or as "DTO-Object" itself?
    A: Doesn't really matter as long as you make a correct cast to "DTO-Object" after receiving the "Object" instance.

    Q: where is the DTO Interface "class", on the server-side, on the client-side or on both-sides?
    A: Both sides.
  3. Thank you[ Go to top ]

    Thanks a lot

    have a nice day :-)
  4. Thank you[ Go to top ]

    Thanks a lot

    have a nice day :-)