Hi
 
Another solution to this is to do something like this:
 
 <managed-bean>
        <managed-bean-name>customer</managed-bean-name>
        <managed-bean-class>xx.xx.xx.Customer</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
  <managed-property>
   <property-name>custId</property-name>
   <value>#{param.id}</value>
  </managed-property>
</managed-bean>
 
When your bean is being construted, the request parameter (#{param.id} will be inserted into it.
 
 
Hermod

-----Opprinnelig melding-----
Fra: Frode Oldervoll [mailto:[EMAIL PROTECTED]
Sendt: 2. november 2005 08:08
Til: 'MyFaces Discussion'
Emne: RE: Call managed bean method based on request attribute

Use FacesContext.getCurrentInstance().addMessage

 

-Frode

 


From: Robert Parsons [mailto:[EMAIL PROTECTED]
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 <[EMAIL PROTECTED]>:
  
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
 
 
  

 



* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

This email with attachments is solely for the use of the individual or
entity to whom it is addressed. Please also be aware that the DnB NOR Group
cannot accept any payment orders or other legally binding correspondence with
customers as a part of an email.

This email message has been virus checked by the virus programs used
in the DnB NOR Group.

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

Reply via email to