Problem with redirecting in pages.xml
haefti Apr 29, 2008 3:49 PMHi!
I have a problem with redirecting using pages.xml.
I have a classic
CRUD application with a list view where you can pick an item to edit (in a second view) and another button to create a new one.
The edit view shows the details of a chosen item and you have a button to save the updates or to cancel. Both buttons are supposed to lead back to the list view.
The relevant part of my pages.xml looks like this:
<page view-id="/authorList.xhtml"> <navigation> <rule if-outcome="create"> <redirect view-id="/authorEdit.xhtml"/> </rule> </navigation> </page> <page view-id="/authorList.xhtml"> <navigation> <rule if-outcome="edit"> <redirect view-id="/authorEdit.xhtml"/> </rule> </navigation> </page> <page view-id="/authorEdit.xhtml"> <navigation> <rule if-outcome="save"> <redirect view-id="/authorList.xhtml"/> </rule> </navigation> </page> <page view-id="/authorEdit.xhtml"> <navigation> <rule if-outcome="cancel"> <redirect view-id="/authorList.xhtml"/> </rule> </navigation> </page>
As you can see if a method returns create
or edit
in the list view the client should be redirected to the edit view.
If a method returns save
or cancel
in the edit view the client should be redirected to the list view.
Due to handling pretty similar data (assets) I have a abstract super class for my session beans (AssetManager) which contains the action methods for creating, editing, etc. The actual assets (Author, Picture, etc.) are managed by session beans called AuthorManager, PictureManager, etc. which inherit from AssetManager.
Here are the relevant methods of the super class:
@Begin(join = true) public String createAsset() { // some working code to create a new object return "create"; } @Begin(join = true) public String editAsset() { String returnValue; if (selectedAsset != null) { returnValue = "edit"; } else { returnValue = null; } return returnValue; } @Begin(join = true) public String findAsset() { String returnValue; if (assetId != null) { // some working code to get an asset from the database returnValue = "edit"; } else { returnValue = null; } return returnValue; } @End public String saveAsset() { // some working code to save an asset to the database return "save"; } @End public String cancel() { return "cancel"; }
My problem is that it does not work with create
and with save
(even though the entries in the pages.xml seem to me to be absolutely the same like the working ones). The methods returning these strings are invoked (I can see this in the log) but the same view is rendered even though no exception is thrown.
The whole application does work if I return directly the name of the desired views as strings (so it is not a bug in the business logic) but I would like to handle all my navigation in the pages.xml so hopefully there is a soution for my problem.
BTW, is there any overview over the allowed tags and attributes in the pages.xml? (The manual has only examples and gathering the information from the schema file is a bit annoying.)
Thanks!