JSF Navigation handler
The JSF navigation handler has some implicit rules that cause the same view to be displayed again after processing a post back. For example if a JSP a.jsp executes an action #{controllerBean.actionMethod} and no explicit navigationrule is matching either the action or an outcome, then the navigation handler will display a.jsp again. This is convenient as no navigation rules have to be coded.
On top of that JSF has a built-in behaviour to keep form input values for a previous post if the view id remains unchanged (which is the case here!). To be more specific: if submitted data is available it is displayed otherwise the values of properties bound to a backing bean are displayed (submitted data is only reset when an explicit navigation rule is executed!) This feature is required for supporting the JSF form validation mechanisms. If any form validator reports a validation error, the ooriginating form will rdisplay the form with the values as they were entered before.
However this can get tricky for some special occasions. Next I will describe such a scenario in which this is causing troubles:
I was trying to implement a simple table for selecting a table row and editing the selected row in a form in a different way than I did it before. Table and form are rendered through the same JSP (see below) such that no navigation rules are required.
This does not behave as expected-> when a row is selected, its data is shown in the form. After returning back to the table and selecting a different row, the form shows the same row data as before BUT NOT the data for the new selection.
listController.select is implemented like shown below
public String select() {
setSelectedEntity((T) getDataModel().getRowData());// this injects the selected object into the form controller
return OUTCOME_SELECT;
}
So considering the above described JSF behaviour a navigation rule must be added in order to get this working
/experimental/listformcontroller.jsp
/experimental/listformcontroller.jsp
JSF Days 08 will be held in Vienna from 12.3.08-14.3.08
JSFDays will take place on March 12th to 14th in the premises of FH Technikum Wien. The conference is hosted by IRIAN Solutions Gmbh.
Among the speakers are Edward J. Burns, Kito Mann, Alexander Jesse.
Swinglabs PDF Renderer
Today I had a chance to test the Sun PDF Renderer (see a previous post). After a first glance I have to say it is damned fast! The Viewer itself loads extremely fast (of course it doesn’t have to load all the plugins like the Adobe Reader) and also loading a document is like nothing!
FacesMessage: show summary only
For displaying only the summary for a FacesMessage instance you have two options
- <h:messages showDetail=”false”/>
- Pass no detail to the FacesMessage constructor
The above options have their problems. Let’s say you don’t know if a FacesMessage will be generated with or without detail information but need to show it if available. You can’t go for option 1, you have to set showDetail=”true”. For this case you have to consider how JSF is displaying FacesMessage instances. Let’s look at the implementation of FacesMessage.getDetail.
public String getDetail() {
if (this.detail == null) {
return (this.summary);
} else {
return (this.detail);
}
}
This means that if you instantiate a FacesMessage with detail set null, JSF will display the summary (i.e you will see the summary text twice). To avoid this instantiate FacesMessage with an empty detail String!
