You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Robert Parsons <ro...@optushome.com.au> on 2005/11/01 12:52:35 UTC
Call managed bean method based on request attribute
Hi,
I'm after some basic design assistance here. If I have a managed bean
that represents some database entity, how can I populate that bean from
the database based on a request parameter?
For example, say I have a managed bean called Customer. The form for
editing the bean is 'editCustomer.faces'. If the page is accessed
directly (without any request parameters) a blank form is dispalyed
which can be used to create a new Person. (which would possibly have an
action for inserting it into the database).
However, if a request like 'editCustomer.faces?id=14' was issued, I want
the Customer bean to load customer number 14 from the database.
What is the best way of achieving this with JavaServer faces? This whole
managed mean is making my old methods of working a little difficult.
Thanks in advance,
Robert.
Re: Call managed bean method based on request attribute
Posted by Robert Parsons <ro...@optushome.com.au>.
Thats so simple! :S I swear i checked FacesContext over and over for a
method. Geeezz i'm blind. Thanks!
Frode Oldervoll wrote:
> Use FacesContext.getCurrentInstance().addMessage
>
>
>
> -Frode
>
>
>
> ------------------------------------------------------------------------
>
> *From:* Robert Parsons [mailto:robertp@optushome.com.au]
> *Sent:* 2. november 2005 07:37
> *To:* MyFaces Discussion
> *Subject:* Re: Call managed bean method based on request attribute
>
>
>
> Thanks!
>
> Just another question if anyone is still around, if I want to add a
> message to the response from a bean method rather than at validation
> time (such as 'save' method), how do that? The only way I can see of
> adding messages is by throwing a ValitatorException :S.
>
> Thanks in advance,
> -Robert.
>
> Mathias Brökelmann wrote:
>
>use FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("id")
>
>
>
>2005/11/1, Robert Parsons <ro...@optushome.com.au> <ma...@optushome.com.au>:
>
>
>
>>Hi,
>>
>>
>>
>>I'm after some basic design assistance here. If I have a managed bean
>>
>>that represents some database entity, how can I populate that bean from
>>
>>the database based on a request parameter?
>>
>>
>>
>>For example, say I have a managed bean called Customer. The form for
>>
>>editing the bean is 'editCustomer.faces'. If the page is accessed
>>
>>directly (without any request parameters) a blank form is dispalyed
>>
>>which can be used to create a new Person. (which would possibly have an
>>
>>action for inserting it into the database).
>>
>>
>>
>>However, if a request like 'editCustomer.faces?id=14' was issued, I want
>>
>>the Customer bean to load customer number 14 from the database.
>>
>>
>>
>>What is the best way of achieving this with JavaServer faces? This whole
>>
>>managed mean is making my old methods of working a little difficult.
>>
>>
>>
>>Thanks in advance,
>>
>>Robert.
>>
>>
>>
>>
>>
>
>
>
>
>--
>
>Mathias
>
>
>
>
>
>
>
>
>
RE: Call managed bean method based on request attribute
Posted by Frode Oldervoll <Fr...@7m.com>.
Use FacesContext.getCurrentInstance().addMessage
-Frode
_____
From: Robert Parsons [mailto:robertp@optushome.com.au]
Sent: 2. november 2005 07:37
To: MyFaces Discussion
Subject: Re: Call managed bean method based on request attribute
Thanks!
Just another question if anyone is still around, if I want to add a message
to the response from a bean method rather than at validation time (such as
'save' method), how do that? The only way I can see of adding messages is by
throwing a ValitatorException :S.
Thanks in advance,
-Robert.
Mathias Brökelmann wrote:
use
FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMa
p().get("id")
2005/11/1, Robert Parsons <ma...@optushome.com.au>
<ro...@optushome.com.au>:
Hi,
I'm after some basic design assistance here. If I have a managed bean
that represents some database entity, how can I populate that bean from
the database based on a request parameter?
For example, say I have a managed bean called Customer. The form for
editing the bean is 'editCustomer.faces'. If the page is accessed
directly (without any request parameters) a blank form is dispalyed
which can be used to create a new Person. (which would possibly have an
action for inserting it into the database).
However, if a request like 'editCustomer.faces?id=14' was issued, I want
the Customer bean to load customer number 14 from the database.
What is the best way of achieving this with JavaServer faces? This whole
managed mean is making my old methods of working a little difficult.
Thanks in advance,
Robert.
--
Mathias
Re: Call managed bean method based on request attribute
Posted by Robert Parsons <ro...@optushome.com.au>.
Thanks!
Just another question if anyone is still around, if I want to add a
message to the response from a bean method rather than at validation
time (such as 'save' method), how do that? The only way I can see of
adding messages is by throwing a ValitatorException :S.
Thanks in advance,
-Robert.
Mathias Brökelmann wrote:
>use FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("id")
>
>2005/11/1, Robert Parsons <ro...@optushome.com.au>:
>
>
>>Hi,
>>
>>I'm after some basic design assistance here. If I have a managed bean
>>that represents some database entity, how can I populate that bean from
>>the database based on a request parameter?
>>
>>For example, say I have a managed bean called Customer. The form for
>>editing the bean is 'editCustomer.faces'. If the page is accessed
>>directly (without any request parameters) a blank form is dispalyed
>>which can be used to create a new Person. (which would possibly have an
>>action for inserting it into the database).
>>
>>However, if a request like 'editCustomer.faces?id=14' was issued, I want
>>the Customer bean to load customer number 14 from the database.
>>
>>What is the best way of achieving this with JavaServer faces? This whole
>>managed mean is making my old methods of working a little difficult.
>>
>>Thanks in advance,
>>Robert.
>>
>>
>>
>
>
>--
>Mathias
>
>
>
>
Re: Call managed bean method based on request attribute
Posted by Mathias Brökelmann <mb...@googlemail.com>.
use FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("id")
2005/11/1, Robert Parsons <ro...@optushome.com.au>:
> Hi,
>
> I'm after some basic design assistance here. If I have a managed bean
> that represents some database entity, how can I populate that bean from
> the database based on a request parameter?
>
> For example, say I have a managed bean called Customer. The form for
> editing the bean is 'editCustomer.faces'. If the page is accessed
> directly (without any request parameters) a blank form is dispalyed
> which can be used to create a new Person. (which would possibly have an
> action for inserting it into the database).
>
> However, if a request like 'editCustomer.faces?id=14' was issued, I want
> the Customer bean to load customer number 14 from the database.
>
> What is the best way of achieving this with JavaServer faces? This whole
> managed mean is making my old methods of working a little difficult.
>
> Thanks in advance,
> Robert.
>
--
Mathias