File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes Help with creating common xhtml code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Help with creating common xhtml code" Watch "Help with creating common xhtml code" New topic

Help with creating common xhtml code

David Warner

Joined: Feb 18, 2011
Posts: 1
Greetings: still pretty new to JSF. I hope this question makes sense. I'm happy to followup if more details are required.

Using JSF 1.2, Facelets, RichFaces 3.3

As an example, take a Car object setup as a backing bean. Within the xhtml code I can reference this bean using normal expressions:
#{car.prop1}, #{car.prop2) ... etc.

Now consider creating a rich:dataTable like:

This table includes a command link for each row that displays a modal panel to allow the details of a single car to be displayed/edited. Like this:

Setup like this the panel xhtml references a specific car's properties like:
#{cars.currentCar.prop1}, #{cars.currentCar.prop2) ... etc.

So I have all of this working in both the single object example and selecting an object from the table.

What I desire is one block of xhtml that I can <ui:include=...> so that the display/edit form is common regardless of how it evoked (i.e. from the table or a single object search). Where I'm getting stuck is on how to construct the code so that it refers to the same bean. In this example both 'car' and 'cars.currentCar' represent the same object, but within different beans.

Did I explain this well? Pretty sure I'm making this harder then it should be, but can't seem to figure out the correct approach.

Really appreciate any thoughts or assistance you can provide.

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

Pass the object as a parameter to the included file. It goes something like this, but I may not have remembered it exactly.

This is the shape of it, although I may have mangled the details.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Help with creating common xhtml code
It's not a secret anymore!