Your managed bean is request-scoped, so all data is lost on the next request.

The data the user entered will still be applied to the newly created
managed bean in the next request - so you don't loose this data. This
data comes from the input-fields the user has filled out, and will
naturally be applied to your backing bean.

But the id goes down the gully - cause the user hasn't entered it, and
the bean is recreated from scratch. Bye, bye, Mr. Id.

Go with Andrews suggestion and use a t:savestate to save this value.
How does it work, you'll ask?

Simple:

<f:view>
<t:saveState value="#{mymanagedbean.id}"/>

regards,

Martin

On 8/24/06, Eurig Jones <[EMAIL PROTECTED]> wrote:
Andrew Robinson wrote:
> How about a little code example? Maybe there is something there. My
> coffee hasn't kicked in yet, so maybe just tired.
>

Ok :-)

A Request Bean

public class NewUserBean
{
    private Integer id;
    private String username;

    <...getters and setters...>

    public void createNewUser()
    {
        User user = new User();
        user.setUsername(getUsername());

        // at this point id is NULL;
        int id = whatever.save();
        setId(id);
       // id is now not null
    }
}

..Now on the request page which shows after the createNewUser() action:
I can output #{newUserBean.username} but outputting #{newUserBean.id}
gives me nothing


Hope that made sense :-)



--

http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces

Reply via email to