Yes,
it can all be handled through the request scope. (BTW, if you need
something more than request scope but less than session scope, use the handy
<t:saveState> tag that MyFaces gives you to "carry along" the bean for as
many pages as you need to. Then you can simply declare it with request
scope.)
The
steps you outlined are correct, except that the action bean, after it reads from
the database, will do the following:
getEmployeeBean().setName(result.name);
getEmployeeBean().setAddress(result.address);
...
or the
equivalent. The employee bean will already be instantiated by JSF at that
point; the action bean just needs to fill it in. Then, once the action
bean returns and navigation takes it to the next page, the bean will have all
the values it needs for the JSP to refer to.
-
Brendan
-----Original Message-----On 8/24/05, David Haynes <[EMAIL PROTECTED]> wrote:
From: Rick Reumann [mailto:[EMAIL PROTECTED]
Sent: Wednesday, August 24, 2005 1:43 PM
To: MyFaces Discussion
Subject: Re: confusion on best practices in regard to a VO in BackingBeanRick
So, if you have already created an instance of employeeBackingBean (and
it is defined as having a session scope), it should be available for all
subsequent pages in the session.
Correct. But I wouldn't think I'd need to have to give my backing bean session scope in order to accomplish this. Using Struts as an example, if I'm in my Action responsible for "getting an Employee" from the backend and I then shove it request scope, the Employee is now available on the resulting page that I forward to. I'm still a bit stumped how this is accomplished with JSF without using Session scoped backing beans. To reiterate the flow ...
"employees.jsp" - user clicks on edit employee link (passing in employee id)
backing bean "getEmployeeAction" method called returning an employee object from backend. (For simplicity lets just assume Employee object is in this EmployeeBackingBean).
navigation rule has us now forward to the "employeeForm.jsp" which should be autopopulated with the Employee information we returned in our backing bean. Can all of this be done with Request scope? I would think it should since it's pretty basic CRUD UI flow in applications.
--

