Spring Faces Component Library
The Spring Faces module comes with a set of components, which are provided through a tag library. Table 11-1 shows available tags in the Spring Faces component library. The description for each tag is taken from tag library descriptor file in the Spring Web Flow distribution from the following location; spring-faces/src/main/resources/META-INF/spring-faces.tld.
Table 11-1. Spring Faces Component library tag details
Tag Name | Description |
includeStyles | Renders the necessary CSS stylesheet includes for the Spring Faces components. Use of this tag in the head section of a page that contains the Spring Faces components is recommended as a browser performance optimization in keeping with the Yahoo performance guidelines (http://developer.yahoo.com/performance). If this tag is not included, the stylesheet includes will be rendered inline with the first instance of a Spring Faces component that requires them. |
includeScripts | Renders the necessary JavaScript file includes for the Spring Faces components. Use of this tag in the head section of a page that contains the Spring Faces components is recommended as a browser performance optimization in keeping with the Yahoo performance guidelines (http://developer.yahoo.com/performance). If this tag is not included, the script includes will be rendered inline with the first instance of a Spring Faces component that requires theme. |
resource | Renders a resource include that will route through the ResourceServlet. The included resource can be either CSS or JavaScript. The type of include to render will be determined from the resource’s file extension. The ResourceServlet will set the proper response headers for aggressive caching of the resource by the browser and will gzip the resource if the client browser supports it. These optimizations are in line with the Yahoo performance guidelines (http://developer.yahoo.com/performance/) |
resourceGroup | The child “resource” components must all be of the same resource type. This is especially useful when combining modularized CSS files for a site. Reducing the number of HTTP requests when a page loads is one of the Yahoo performance guidelines (http://developer.yahoo.com/performance/). |
clientTextValidator | Applies client-side text validation behavior to a child “inputText” component. |
clientNumberValidator | Applies client-side numeric validation behavior to a child “inputText” component. |
clientCurrencyValidator | Applies client-side currency validation behavior to a child “inputText” component. |
clientDateValidator | Applies client-side date validation behavior to a child “inputText” component. Field will display a popup calendar when entered. |
validateAllOnClick | Fires all client-side validators when a child component’s “onclick” event is fired and suppresses propagation of the event if validation fails. |
commandButton | Renders a gracefully degrading Ajax submit button. This button will submit the parent form using an Ajax request by default. The component is progressively enhanced so that the submit will still function with a full page refresh if JavaScript is unavailable on the client. The processing of the JSF component tree can be customized through use of the “processIds” attribute. By default only the button itself will be processed during the postback lifecycle. The content to render is determined on the server side by using a render action in the flow definition that processes the request. When updating the existing page, the rendered content must be a replacement for an existing identifiable DOM node in the page. The component is capable of driving transitions to another view with an Ajax request. In that case, a client-side redirect to the new view will occur so that browser history and normal back button behavior is still preserved. |
commandLink | Renders a gracefully degrading Ajax link. This link will submit the parent form using an Ajax request by default. The component is progressively enhanced so that the submit will still function with a full page refresh if JavaScript is unavailable on the client. To achieve this, an HTML button will be rendered initially, and replaced with a JavaScript enhanced link. The button is rendered with a special “progressiveLink” CSS class so that its look can be customized as desired. The processing of the JSF component tree can be customized through use of the “processIds” attribute. By default only the button itself will be processed during the postback lifecycle. The content to render is determined on the server side by using a render action in the flow definition that processes the request. When updating the existing page, the rendered content must be a replacement for an existing identifiable DOM node in the page. The component is capable of driving transitions to another view with an Ajax request. In that case, a client-side redirect to the new view will occur so that browser history and normal back button behavior is still preserved. |
ajaxEvent | Creates a JavaScript event listener for one of the child component’s events that will trigger an Ajax submit of the parent form. The installed JavaScript listener will submit the parent form using an Ajax request. This component is purely JavaScript based and should only be used in an environment where the availability of JavaScript on the client is not a concern. The processing of the JSF component tree can be customized through use of the “processIds” attribute. By default only the button itself will be processed during the postback lifecycle. The content to render is determined on the server side by using a “render” action in the flow definition that processes the request. When updating the existing page, the rendered content must be a replacement for an existing identifiable DOM node in the page. The component is capable of driving transitions to another view with an Ajax request. In that case, a client-side redirect to the new view will occur so that browser history and normal back button behavior is still preserved. |
Integration with Other JSF Component Libraries
Theoretically, it is possible to use any third-party JSF component library with Spring Faces. There are many JSF component libraries available in the market; some being open-source and others being commercial. Important thing to remember is that, while doing the integration, configuration in web.xml will change slightly since Spring Web Flow requests are not routed through the standard FacesServlet, rather it will be mapped to the Spring DispatcherServlet instead. As a sampling we have taken JBoss RichFaces to show the integration of Spring Faces with other third-party library.
For integrating JBoss RichFaces (JSF 1.2) to Spring Faces, perform the following steps:
- Filter configuration – You need to configure the filter details in web.xml as shown below.
[xml]<filter>
<display-name>RichFaces Filter</display-name>
<filter-name>richfaces</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
</filter>
<filter-mapping>
<filter-name>richfaces</filter-name>
<servlet-name>Spring Web MVC Dispatcher Servlet</servlet-name>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>[/xml]
- Configure RichFacesAjaxHandler to your FlowController bean – this is for achieving a view having combined use Spring Faces and RichFaces Ajax components.
[xml]<bean id="flowController"
class="org.springframework.webflow.mvc.servlet.FlowController">
<property name="flowExecutor" ref="flowExecutor" />
<property name="ajaxHandler">
<bean
class="org.springframework.faces.richfaces.RichFacesAjaxHandler"/>
</property>
</bean>[/xml]
Page Visitors: 2677
Tomcy John
Latest posts by Tomcy John (see all)
- A Guide to Continuous Improvement for Architects - February 2, 2023
- Cloud-first Architecture Strategy - January 26, 2023
- Architecture Strategy and how to create One - January 24, 2023
This is Great information.. awesome ideas Thanks