Note that I've defined the beans to be request scope, with the
expectation that your JSP will have <t:saveState
value="#{carListBean}"/>
- Brendan
-----Original Message-----
From: CONNER, BRENDAN (SBCSI)
Sent: Monday, August 29, 2005 4:21 PM
To: 'MyFaces Discussion'
Subject: RE: Concerning DataModel usage plus overhead?
Sounds good. Judging from what I understand about your e-mail, I'd
define something like:
<managed-bean>
<managed-bean-name>carListBean</managed-bean-name>
<managed-bean-class>com.mycompany.CarListBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>carAction</managed-bean-name>
<managed-bean-class>com.mycompany.CarAction</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>carListBean</property-name>
<value>#{carListBean}</value>
</managed-property>
</managed-bean>
(I'm calling your data bean carListBean, rather than carListAction, just
for my own clarity.)
Then, as you point out, you'd have a dataTable entry like
<h:dataTable value="#{carListBean.carModel}" var="car">
<h:column>
<h:commandLink action="{carAction.getCar}">
...
<h:commandLink>
<h:column>
...
</h:dataTable>
Then, in your getCar() method, you'd have something like:
public String getCar() {
Car selectedCar = (Car)
getCarListBean().getCarModel().getRowData();
...
}
Hope that helps.
- Brendan
-----Original Message-----
From: Rick Reumann [mailto:[EMAIL PROTECTED]
Sent: Monday, August 29, 2005 4:02 PM
To: MyFaces Discussion
Subject: Re: Concerning DataModel usage plus overhead?
Actually, the MyFaces master/detail example source code is shedding
some light on some things. Rather than me waste more of your valuable
time, let me fart around with that code and see if I can tweak mine to
use a similar concept. Thanks for your help and patience so far.
On 8/29/05, CONNER, BRENDAN (SBCSI) <[EMAIL PROTECTED]> wrote:
> Can you send a snippet of your faces-config.xml showing your managed
> bean definitions and your navigations, just to make sure I have the
> picture right?
>
> - Brendan
>
> -----Original Message-----
> From: Rick Reumann [mailto:[EMAIL PROTECTED]
> Sent: Monday, August 29, 2005 3:24 PM
> To: MyFaces Discussion
> Subject: Re: Concerning DataModel usage plus overhead?
>
>
> On 8/29/05, CONNER, BRENDAN (SBCSI) <[EMAIL PROTECTED]> wrote:
> >
> > I probably just got confused by your naming convention. Can you
> repeat your
> > question with clearer names?
>
> Sure. Let me change the names and concepts..
>
> First page you come to is a list of cars on "cars.jsp". Cars is
> populated as DataModel from "CarsListAction.java" There is a managed
> bean reference for the name "cars" to "CarsListAction.java.
> CarsListAction has a method "getCars" which returns this DataModel. On
> cars.jsp you have...
>
> <h:dataTable var="car" value="#{carsListAction.cars}" >
>
> Another managed bean: CarAction.java has CRUD methods. In this case
> "getCar" which is supposed to get a "Car" back from the backend based
> on 'carID".
>
> I want to be able to click on car from the list on cars.jsp and hit
> the "getCar' method in my "CarAction.java" bean and forward to a
> carForm.jsp that lets me edit the car. If I use a DataModel with this
> I'm assuming I'll need to get a handle to the DataModel from my
> CarAction.java... but the DataModel was set up in CarsListAction.
>
--
Rick