JSF (MyFaces) implementation notes. Horrible experience: code like this does not rise any exceptions or warnings: 1:<f:facet name="body">
2: <f:verbatim>
3: Companies Page
4: </f:verbatim>
5: <h:form id="companiesListFormID" name="companiesListForm">
6: <h:inputText value="#{companiesListForm.searchCriteria}"/>
7: <h:commandButton action="#{companiesListForm.search}" value="Search"/>
8:
9: </h:form>
10:</f:facet>
11:
but the resulting HTML ommits FORM and places verbatim content after input elements ( which are not enclosed in a form)
To make it working everything within facet should be enclosed into h:panelGroup 1: <f:facet name="body">
2: <h:panelGroup id="body">
3: <f:verbatim>
4: Companies Page
5: </f:verbatim>
6: <h:form id="companiesListFormID" name="companiesListForm">
7: <h:inputText value="#{companiesListForm.searchCriteria}"/>
8: <h:commandButton action="#{companiesListForm.search}" value="Search"/>
9:
10: </h:form>
11: </h:panelGroup>
12:</f:facet>
Same story with x:table - the component did not work till it was enclosed into h:panelGroup Accessing other beans in the JSF context: lets try to access a managed bean that is declared like this:
1: <managed-bean>
2: <managed-bean-name>companiesListForm</managed-bean-name>
3: <managed-bean-class>com.sourcelabs.demo.webapp.web.jsf.CompaniesListForm</managed-bean-class>
4: <managed-bean-scope>session</managed-bean-scope>
5: </managed-bean>
6:
in order to do that in the action method we have to have something like this:
1: FacesContext cxt = FacesContext.getCurrentInstance();
2: ValueBinding vb = cxt.getApplication().createValueBinding( "#{companiesListForm}");
3: CompaniesListForm v = (CompaniesListForm) vb.getValue( cxt ) ;
Why the hell!?, accessing other managed beans is a very common thing, why there is no application method like getManagedBean("name")?!
Well I guess that follows design guidelines of one well known operation system: we have to press button 'Start' to 'Stop' machine :) |