FAQ
I was wondering what's the best way of handling the following:

- A managed bean need to be "filled" with data from a database using DAO methods; is
it best just to pass the managed bean as parameter og should one use another VO bean
and populate the managed bean from the VO bean?

- when moving to a page, some fields need to be filled with existing values, is this
best done in the action method that "calls" the new page and value binding against a
managed bean for that page or is there another better way of doing this?


Regards,

BTJ

--
-----------------------------------------------------------------------------------------------
Bjørn T Johansen

btj@havleik.no
-----------------------------------------------------------------------------------------------
Someone wrote:
"I understand that if you play a Windows CD backwards you hear strange Satanic messages"
To which someone replied:
"It's even worse than that; play it forwards and it installs Windows"
-----------------------------------------------------------------------------------------------

Search Discussions

  • Jesse Alexander (KBSA 21) at May 24, 2005 at 2:43 pm
    Hi Bjørn

    In the project I am actually working on, we decided that our managed beans cover
    one usecase and therfor contain quite some logic and reducing the number of
    "data-transfers" between mangaed beans... The actual business-logic is packed
    within service-objects which are served by a factory and called from the managed beans.
    The service objects will then call the dao-layer or some other backend to do
    persistence-work.

    Whether this is the "best practise"? I do not know, but it works (so far) for our
    project on which 4 people are working full time plus one JSF component developer.

    hth
    Alexander

    -----Original Message-----
    From: Bjørn T Johansen
    Sent: Monday, May 23, 2005 8:52 AM
    To: MyFaces Discussion
    Subject: Best practice?

    I was wondering what's the best way of handling the following:

    - A managed bean need to be "filled" with data from a database using DAO methods; is
    it best just to pass the managed bean as parameter og should one use another VO bean
    and populate the managed bean from the VO bean?

    - when moving to a page, some fields need to be filled with existing values, is this
    best done in the action method that "calls" the new page and value binding against a
    managed bean for that page or is there another better way of doing this?


    Regards,

    BTJ

    --
    -----------------------------------------------------------------------------------------------
    Bjørn T Johansen

    btj@havleik.no
    -----------------------------------------------------------------------------------------------
    Someone wrote:
    "I understand that if you play a Windows CD backwards you hear strange Satanic messages"
    To which someone replied:
    "It's even worse than that; play it forwards and it installs Windows"
    -----------------------------------------------------------------------------------------------
  • Jonas Jacobi at May 24, 2005 at 3:44 pm
    Hi Bjørn,

    For your last question. Depending on what you want to do - if there is
    no action to perform except navigation to a new page it is enough by
    just setting the action attribute to the string representing your
    outcome in the faces navigation case e.g. action="success". For the
    actual binding there are several options; you could pass values on the
    requestScope or sessionScope, and pull them off from there. For most of
    the time I have, personally, been using value bindings pointing to a
    property in my managed bean. This way I can easily manipulate the value
    of the property before any values are pulled in by the "new" page.

    Thanks
    - Jonas

    Jesse Alexander (KBSA 21) wrote:
    Hi Bjørn

    In the project I am actually working on, we decided that our managed beans cover
    one usecase and therfor contain quite some logic and reducing the number of
    "data-transfers" between mangaed beans... The actual business-logic is packed
    within service-objects which are served by a factory and called from the managed beans.
    The service objects will then call the dao-layer or some other backend to do
    persistence-work.

    Whether this is the "best practise"? I do not know, but it works (so far) for our
    project on which 4 people are working full time plus one JSF component developer.

    hth
    Alexander

    -----Original Message-----
    From: Bjørn T Johansen
    Sent: Monday, May 23, 2005 8:52 AM
    To: MyFaces Discussion
    Subject: Best practice?

    I was wondering what's the best way of handling the following:

    - A managed bean need to be "filled" with data from a database using DAO methods; is
    it best just to pass the managed bean as parameter og should one use another VO bean
    and populate the managed bean from the VO bean?

    - when moving to a page, some fields need to be filled with existing values, is this
    best done in the action method that "calls" the new page and value binding against a
    managed bean for that page or is there another better way of doing this?


    Regards,

    BTJ

  • Bjørn T Johansen at May 24, 2005 at 4:20 pm
    Yes, that's the way I am thinking is the best way, so maybe that's the way to go... :)

    BTJ

    Jonas Jacobi wrote:
    Hi Bjørn,

    For your last question. Depending on what you want to do - if there is
    no action to perform except navigation to a new page it is enough by
    just setting the action attribute to the string representing your
    outcome in the faces navigation case e.g. action="success". For the
    actual binding there are several options; you could pass values on the
    requestScope or sessionScope, and pull them off from there. For most of
    the time I have, personally, been using value bindings pointing to a
    property in my managed bean. This way I can easily manipulate the value
    of the property before any values are pulled in by the "new" page.

    Thanks
    - Jonas

    Jesse Alexander (KBSA 21) wrote:
    Hi Bjørn

    In the project I am actually working on, we decided that our managed
    beans cover
    one usecase and therfor contain quite some logic and reducing the
    number of
    "data-transfers" between mangaed beans... The actual business-logic is
    packed within service-objects which are served by a factory and called
    from the managed beans.
    The service objects will then call the dao-layer or some other backend
    to do persistence-work.

    Whether this is the "best practise"? I do not know, but it works (so
    far) for our project on which 4 people are working full time plus one
    JSF component developer.

    hth
    Alexander

    -----Original Message-----
    From: Bjørn T Johansen Sent: Monday, May 23,
    2005 8:52 AM
    To: MyFaces Discussion
    Subject: Best practice?

    I was wondering what's the best way of handling the following:

    - A managed bean need to be "filled" with data from a database using
    DAO methods; is
    it best just to pass the managed bean as parameter og should one use
    another VO bean
    and populate the managed bean from the VO bean?

    - when moving to a page, some fields need to be filled with existing
    values, is this
    best done in the action method that "calls" the new page and value
    binding against a
    managed bean for that page or is there another better way of doing this?


    Regards,

    BTJ

  • Bjørn T Johansen at May 24, 2005 at 4:18 pm
    Yes, that's what I was thinking about... But I am not sure if I should pass the managed
    bean just to my business layer and use VO from BO to DAO or just pass along the managed
    bean further on to the DAO.....

    BTJ

    Jesse Alexander (KBSA 21) wrote:
    Hi Bjørn

    In the project I am actually working on, we decided that our managed beans cover
    one usecase and therfor contain quite some logic and reducing the number of
    "data-transfers" between mangaed beans... The actual business-logic is packed
    within service-objects which are served by a factory and called from the managed beans.
    The service objects will then call the dao-layer or some other backend to do
    persistence-work.

    Whether this is the "best practise"? I do not know, but it works (so far) for our
    project on which 4 people are working full time plus one JSF component developer.

    hth
    Alexander

    -----Original Message-----
    From: Bjørn T Johansen
    Sent: Monday, May 23, 2005 8:52 AM
    To: MyFaces Discussion
    Subject: Best practice?

    I was wondering what's the best way of handling the following:

    - A managed bean need to be "filled" with data from a database using DAO methods; is
    it best just to pass the managed bean as parameter og should one use another VO bean
    and populate the managed bean from the VO bean?

    - when moving to a page, some fields need to be filled with existing values, is this
    best done in the action method that "calls" the new page and value binding against a
    managed bean for that page or is there another better way of doing this?


    Regards,

    BTJ
  • Matthias Wessendorf at May 24, 2005 at 3:03 pm
    Bjørn,

    it is now worth to look at Shale.

    Shale provides an interface that each backing bean *could* implement
    it provides a init() method for initializing stuff like you want.
    (see:
    http://people.apache.org/~craigmcc/shale-core-javadocs/org/apache/shale/ViewController.html
    )

    There is use case app, that shows how to use Shale. In that you see, that
    there is an abstract BaseBackingBean that implements the interface. all your
    backing beans extend that base backing bean. Since JSF uses POJO you are
    free to integrate each framework you like.

    The sample (use case sample) also provides DAO access for backing beans.

    Look at:
    http://wiki.apache.org/struts/StrutsShale

    Shale is a framework by Craig McClanahan (ex JSF EG lead) under the umbrella
    of Apache Struts. It relies only on JSF and not on *legacy* Struts API

    HTH,
    Matthias
    On 5/23/05, Bjørn T Johansen wrote:
    I was wondering what's the best way of handling the following:

    - A managed bean need to be "filled" with data from a database using DAO
    methods; is
    it best just to pass the managed bean as parameter og should one use
    another VO bean
    and populate the managed bean from the VO bean?

    - when moving to a page, some fields need to be filled with existing
    values, is this
    best done in the action method that "calls" the new page and value binding against a
    managed bean for that page or is there another better way of doing this?


    Regards,

    BTJ

    --
    -----------------------------------------------------------------------------------------------
    Bjørn T Johansen

    btj@havleik.no
    -----------------------------------------------------------------------------------------------
    Someone wrote:
    "I understand that if you play a Windows CD backwards you hear strange
    Satanic messages"
    To which someone replied:
    "It's even worse than that; play it forwards and it installs Windows"
    -----------------------------------------------------------------------------------------------
    >


    --
    Matthias Wessendorf
  • Bjørn T Johansen at May 24, 2005 at 4:17 pm
    I have looked at the website before, but I haven't tried it yet... But isn't Shale still
    at it's early development state?

    Matthias Wessendorf wrote:
    Bjørn,

    it is now worth to look at Shale.

    Shale provides an interface that each backing bean *could* implement
    it provides a init() method for initializing stuff like you want.
    (see:
    http://people.apache.org/~craigmcc/shale-core-javadocs/org/apache/shale/ViewController.html)

    There is use case app, that shows how to use Shale. In that you see,
    that there is an abstract BaseBackingBean that implements the interface.
    all your backing beans extend that base backing bean. Since JSF uses
    POJO you are free to integrate each framework you like.

    The sample (use case sample) also provides DAO access for backing beans.

    Look at:
    http://wiki.apache.org/struts/StrutsShale
    <http://wiki.apache.org/struts/StrutsShale>

    Shale is a framework by Craig McClanahan (ex JSF EG lead) under the
    umbrella of Apache Struts. It relies only on JSF and not on *legacy*
    Struts API

    HTH,
    Matthias
    On 5/23/05, Bjørn T Johansen wrote:
    I was wondering what's the best way of handling the following:

    - A managed bean need to be "filled" with data from a database using
    DAO methods; is
    it best just to pass the managed bean as parameter og should one use
    another VO bean
    and populate the managed bean from the VO bean?

    - when moving to a page, some fields need to be filled with existing
    values, is this
    best done in the action method that "calls" the new page and value
    binding against a
    managed bean for that page or is there another better way of doing this?


    Regards,

    BTJ

    --
    -----------------------------------------------------------------------------------------------
    Bjørn T Johansen

    btj@havleik.no >
    -----------------------------------------------------------------------------------------------
    Someone wrote:
    "I understand that if you play a Windows CD backwards you hear strange
    Satanic messages"
    To which someone replied:
    "It's even worse than that; play it forwards and it installs Windows"
    -----------------------------------------------------------------------------------------------

    --
    Matthias Wessendorf
  • Deadman, Hal at May 24, 2005 at 4:21 pm
    I have used it on a project and didn't have any problems with it. I didn't use all the features but the backing bean support and the lifecycle methods worked fine.
    -----Original Message-----
    From: Bjørn T Johansen
    Sent: Tuesday, May 24, 2005 12:17 PM
    To: MyFaces Discussion
    Subject: Re: Best practice?

    I have looked at the website before, but I haven't tried it yet... But
    isn't Shale still
    at it's early development state?

    Matthias Wessendorf wrote:
    Bjørn,

    it is now worth to look at Shale.

    Shale provides an interface that each backing bean *could* implement
    it provides a init() method for initializing stuff like you want.
    (see:
    http://people.apache.org/~craigmcc/shale-core-
    javadocs/org/apache/shale/ViewController.html)
    There is use case app, that shows how to use Shale. In that you see,
    that there is an abstract BaseBackingBean that implements the interface.
    all your backing beans extend that base backing bean. Since JSF uses
    POJO you are free to integrate each framework you like.

    The sample (use case sample) also provides DAO access for backing beans.

    Look at:
    http://wiki.apache.org/struts/StrutsShale
    <http://wiki.apache.org/struts/StrutsShale>

    Shale is a framework by Craig McClanahan (ex JSF EG lead) under the
    umbrella of Apache Struts. It relies only on JSF and not on *legacy*
    Struts API

    HTH,
    Matthias
    On 5/23/05, Bjørn T Johansen wrote:
    I was wondering what's the best way of handling the following:

    - A managed bean need to be "filled" with data from a database using
    DAO methods; is
    it best just to pass the managed bean as parameter og should one use
    another VO bean
    and populate the managed bean from the VO bean?

    - when moving to a page, some fields need to be filled with existing
    values, is this
    best done in the action method that "calls" the new page and value
    binding against a
    managed bean for that page or is there another better way of doing
    this?

    Regards,

    BTJ

    --
    ------------------------------------------------------------------------
    -----------------------
    Bjørn T Johansen

    btj@havleik.no >>
    ------------------------------------------------------------------------
    -----------------------
    Someone wrote:
    "I understand that if you play a Windows CD backwards you hear strange
    Satanic messages"
    To which someone replied:
    "It's even worse than that; play it forwards and it installs Windows"
    ------------------------------------------------------------------------
    -----------------------

    --
    Matthias Wessendorf
  • Jesse Alexander (KBSA 21) at May 24, 2005 at 4:41 pm
    Well we call the the Business-Layer from the managed beans, therefor we have no need to
    pass the MB to the backend...
    Alexander

    -----Original Message-----
    From: Bjørn T Johansen
    Sent: Tuesday, May 24, 2005 6:18 PM
    To: MyFaces Discussion
    Subject: Re: Best practice?

    Yes, that's what I was thinking about... But I am not sure if I should pass the managed
    bean just to my business layer and use VO from BO to DAO or just pass along the managed
    bean further on to the DAO.....

    BTJ

    Jesse Alexander (KBSA 21) wrote:
    Hi Bjørn

    In the project I am actually working on, we decided that our managed beans cover
    one usecase and therfor contain quite some logic and reducing the number of
    "data-transfers" between mangaed beans... The actual business-logic is packed
    within service-objects which are served by a factory and called from the managed beans.
    The service objects will then call the dao-layer or some other backend to do
    persistence-work.

    Whether this is the "best practise"? I do not know, but it works (so far) for our
    project on which 4 people are working full time plus one JSF component developer.

    hth
    Alexander

    -----Original Message-----
    From: Bjørn T Johansen
    Sent: Monday, May 23, 2005 8:52 AM
    To: MyFaces Discussion
    Subject: Best practice?

    I was wondering what's the best way of handling the following:

    - A managed bean need to be "filled" with data from a database using DAO methods; is
    it best just to pass the managed bean as parameter og should one use another VO bean
    and populate the managed bean from the VO bean?

    - when moving to a page, some fields need to be filled with existing values, is this
    best done in the action method that "calls" the new page and value binding against a
    managed bean for that page or is there another better way of doing this?


    Regards,

    BTJ
  • Bjørn T Johansen at May 24, 2005 at 5:03 pm
    But how to you fill the data in the MB from DAO?

    Jesse Alexander (KBSA 21) wrote:
    Well we call the the Business-Layer from the managed beans, therefor we have no need to
    pass the MB to the backend...
    Alexander

    -----Original Message-----
    From: Bjørn T Johansen
    Sent: Tuesday, May 24, 2005 6:18 PM
    To: MyFaces Discussion
    Subject: Re: Best practice?

    Yes, that's what I was thinking about... But I am not sure if I should pass the managed
    bean just to my business layer and use VO from BO to DAO or just pass along the managed
    bean further on to the DAO.....

    BTJ

    Jesse Alexander (KBSA 21) wrote:
    Hi Bjørn

    In the project I am actually working on, we decided that our managed beans cover
    one usecase and therfor contain quite some logic and reducing the number of
    "data-transfers" between mangaed beans... The actual business-logic is packed
    within service-objects which are served by a factory and called from the managed beans.
    The service objects will then call the dao-layer or some other backend to do
    persistence-work.

    Whether this is the "best practise"? I do not know, but it works (so far) for our
    project on which 4 people are working full time plus one JSF component developer.

    hth
    Alexander

    -----Original Message-----
    From: Bjørn T Johansen
    Sent: Monday, May 23, 2005 8:52 AM
    To: MyFaces Discussion
    Subject: Best practice?

    I was wondering what's the best way of handling the following:

    - A managed bean need to be "filled" with data from a database using DAO methods; is
    it best just to pass the managed bean as parameter og should one use another VO bean
    and populate the managed bean from the VO bean?

    - when moving to a page, some fields need to be filled with existing values, is this
    best done in the action method that "calls" the new page and value binding against a
    managed bean for that page or is there another better way of doing this?


    Regards,

    BTJ
  • Jesse Alexander (KBSA 21) at May 24, 2005 at 5:11 pm
    Let's say, that the MB wants to get user-details from a backend-service...

    //The MB will ask for a user-service
    UserService userService = factory.getUserService();
    //and then will call the
    UserDto userDetails = userService.getUserDetails(userId);
    //and receive a VO/DTO containing all the UserDetails...

    in the JSP the details then can be accessed "normally":

    #{myManagedBean.userDetails.lastName}

    and so on...



    -----Original Message-----
    From: Bjørn T Johansen
    Sent: Tuesday, May 24, 2005 7:04 PM
    To: MyFaces Discussion
    Subject: Re: Best practice?

    But how to you fill the data in the MB from DAO?

    Jesse Alexander (KBSA 21) wrote:
    Well we call the the Business-Layer from the managed beans, therefor we have no need to
    pass the MB to the backend...
    Alexander

    -----Original Message-----
    From: Bjørn T Johansen
    Sent: Tuesday, May 24, 2005 6:18 PM
    To: MyFaces Discussion
    Subject: Re: Best practice?

    Yes, that's what I was thinking about... But I am not sure if I should pass the managed
    bean just to my business layer and use VO from BO to DAO or just pass along the managed
    bean further on to the DAO.....

    BTJ

    Jesse Alexander (KBSA 21) wrote:
    Hi Bjørn

    In the project I am actually working on, we decided that our managed beans cover
    one usecase and therfor contain quite some logic and reducing the number of
    "data-transfers" between mangaed beans... The actual business-logic is packed
    within service-objects which are served by a factory and called from the managed beans.
    The service objects will then call the dao-layer or some other backend to do
    persistence-work.

    Whether this is the "best practise"? I do not know, but it works (so far) for our
    project on which 4 people are working full time plus one JSF component developer.

    hth
    Alexander

    -----Original Message-----
    From: Bjørn T Johansen
    Sent: Monday, May 23, 2005 8:52 AM
    To: MyFaces Discussion
    Subject: Best practice?

    I was wondering what's the best way of handling the following:

    - A managed bean need to be "filled" with data from a database using DAO methods; is
    it best just to pass the managed bean as parameter og should one use another VO bean
    and populate the managed bean from the VO bean?

    - when moving to a page, some fields need to be filled with existing values, is this
    best done in the action method that "calls" the new page and value binding against a
    managed bean for that page or is there another better way of doing this?


    Regards,

    BTJ
  • Bjørn T Johansen at May 24, 2005 at 5:51 pm
    Aaah, I see.... :)

    Jesse Alexander (KBSA 21) wrote:
    Let's say, that the MB wants to get user-details from a backend-service...

    //The MB will ask for a user-service
    UserService userService = factory.getUserService();
    //and then will call the
    UserDto userDetails = userService.getUserDetails(userId);
    //and receive a VO/DTO containing all the UserDetails...

    in the JSP the details then can be accessed "normally":

    #{myManagedBean.userDetails.lastName}

    and so on...



    -----Original Message-----
    From: Bjørn T Johansen
    Sent: Tuesday, May 24, 2005 7:04 PM
    To: MyFaces Discussion
    Subject: Re: Best practice?

    But how to you fill the data in the MB from DAO?

    Jesse Alexander (KBSA 21) wrote:
    Well we call the the Business-Layer from the managed beans, therefor we have no need to
    pass the MB to the backend...
    Alexander

    -----Original Message-----
    From: Bjørn T Johansen
    Sent: Tuesday, May 24, 2005 6:18 PM
    To: MyFaces Discussion
    Subject: Re: Best practice?

    Yes, that's what I was thinking about... But I am not sure if I should pass the managed
    bean just to my business layer and use VO from BO to DAO or just pass along the managed
    bean further on to the DAO.....

    BTJ

    Jesse Alexander (KBSA 21) wrote:

    Hi Bjørn

    In the project I am actually working on, we decided that our managed beans cover
    one usecase and therfor contain quite some logic and reducing the number of
    "data-transfers" between mangaed beans... The actual business-logic is packed
    within service-objects which are served by a factory and called from the managed beans.
    The service objects will then call the dao-layer or some other backend to do
    persistence-work.

    Whether this is the "best practise"? I do not know, but it works (so far) for our
    project on which 4 people are working full time plus one JSF component developer.

    hth
    Alexander

    -----Original Message-----
    From: Bjørn T Johansen
    Sent: Monday, May 23, 2005 8:52 AM
    To: MyFaces Discussion
    Subject: Best practice?

    I was wondering what's the best way of handling the following:

    - A managed bean need to be "filled" with data from a database using DAO methods; is
    it best just to pass the managed bean as parameter og should one use another VO bean
    and populate the managed bean from the VO bean?

    - when moving to a page, some fields need to be filled with existing values, is this
    best done in the action method that "calls" the new page and value binding against a
    managed bean for that page or is there another better way of doing this?


    Regards,

    BTJ

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupusers @
categoriesmyfaces
postedMay 23, '05 at 6:52a
activeMay 24, '05 at 5:51p
posts12
users5
websitemyfaces.apache.org

People

Translate

site design / logo © 2019 Grokbase