Archive for the ‘Rich Faces’ Category

h:commandButton to cancel sending a form (without validation)

Monday, February 8th, 2010

Sometimes the problem with validators is that you can’t send a cancel button from within a form, because the validator stops processing it. In this case it is usefull to set the button on immediate=”true”, but then the problem might be that the view ist not correctly cleared. To force clearing the view, it is important to navigate with an outcome other than null (”").

    <h:commandButton immediate="true"
        actionListener="#{bean.discardEditing}"
        value="#{msg.action_cancel}" />

In the example “bean.discardEditing” does some cleanup and returns a navigation outcome to navigate to the same screen again, e.g. “revertToEdit”.

See also:

a4j:commandLink and a4j:support problem

Wednesday, January 27th, 2010

Avoid to mix those two up. Do NOT nest them to trigger rerendering, like this:

    <a4j:commandLink ajaxSingle="true" actionListener="#{...}">
        <a4j:support event="onclick" reRender="..." />
    </a4j:commandLink>

It will lead to funky behaviour, sometimes sending the link, sometimes not. If you use a4j:commandLink you do not need a4j:support. Do trigger rerendering from within the commandLink.

    <a4j:commandLink ajaxSingle="true" actionListener="#{...}" reRender="..." />

jboss rich faces and eclipse (url-pattern config)

Saturday, July 11th, 2009

After installing the rich face libs the first time, Faces Servlet threw a null pointer exception:

11.07.2009 12:18:55 org.apache.catalina.core.StandardWrapperValve invoke
SCHWERWIEGEND: Servlet.service() for servlet Faces Servlet threw exception
java.lang.NullPointerException
	at java.lang.String.startsWith(String.java:1252)
	at java.lang.String.startsWith(String.java:1281)
	at org.ajax4jsf.webapp.WebXml.getFacesResourceKey(WebXml.java:189)
	at org.ajax4jsf.webapp.WebXml.getFacesResourceKey(WebXml.java:222)
	at org.ajax4jsf.resource.InternetResourceService.serviceResource(InternetResourceService.java:139)
	at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:500)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
	at java.lang.Thread.run(Thread.java:613)

This seems to happen, if you create a new dynamic web project with eclipse ganymede 3.4, because if you add jsf support with two url-mappings (e.g. *.jsf and /pages/*) to the project, eclipse creates the web.xml with the following servlet mapping:

    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
        <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>

This does not work with rf. You must define the url patterns separately:

    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>

This works now well for me.