changing the mode of a page

Hi,
I am using JSF 2.0.
I am doing a standard create / read / update / delete for various entities e.g. tennis balls, toasters and cars.
I would like to use the one page for the create, read, update and delete for each entity and just change the mode of it based on the use case.

I'm assuming that you have a separate detail edit page for each entity type. It can get really complicated if you attempt to dynamically create an editor from a one-size-fits-all page. And I have code to prove it (it's a generic database editor app, incidentally).

I normally have "begin" methods that lay the groundwork and are invoked by the referring page's action method, so the "from" page (which is typically a tabular view) will invoke "beginAdd" or "beginEdit" and that will be where the intialization is done and where I set my processing mode indicator. I use the common practice of putting a delete button on the Edit view, so there's no separate "delete" mode. For Display (read) mode, I typically just use an alternative view definition using display-only controls, since it generally looks better.

You can do everything you want with only 1 or 2 view definitions (depending on whether you have a separate Display view). I return the captions for the buttons based on the add/edit mode indicator, as well as show/hide controls (obviously "delete" doesn't need to be there if you're still adding it). The actual storage commit action I normally simply name "doSave" and it invokes add or update logic depending on mode. The Delete button is an immediate button with a confirmation JavaScript ("Are you sure?") popup attached to it.

Because this stuff is so generic, I often machine-generate the prototypes straight from my domain model definitions, then hand-tweak as needed.

Customer surveys are for companies who didn't pay proper attention to begin with.