20
Dec
09

column sorting using JSF and Tomahawk


This page describes the process of sorting results generated by a JSF based application.

Installation

		<dependency>
			<groupId>org.apache.myfaces.tomahawk</groupId>
			<artifactId>tomahawk</artifactId>
			<version>1.1.9</version>
		</dependency>  

Configuration

Not 100% sure if the following is needed in web.xml or not. Just here for reference.

<filter>
        <filter-name>MyFacesExtensionsFilter</filter-name>
        <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
    <init-param>
        <param-name>uploadMaxFileSize</param-name>
        <param-value>20m</param-value>
        <description>Set the size limit for uploaded files.
            Format: 10 - 10 bytes
                    10k - 10 KB
                    10m - 10 MB
                    1g - 1 GB
        </description>
    </init-param>
</filter>

<!-- extension mapping for adding <script/>, <link/>, and other resource tags to JSF-pages  -->
<filter-mapping>
    <filter-name>MyFacesExtensionsFilter</filter-name>
    <!-- servlet-name must match the name of your javax.faces.webapp.FacesServlet entry -->
    <servlet-name>Faces Servlet</servlet-name>
</filter-mapping>

<!-- extension mapping for serving page-independent resources (javascript, stylesheets, images, etc.)  -->
<filter-mapping>
    <filter-name>MyFacesExtensionsFilter</filter-name>
    <url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
</filter-mapping>

Programming the JSP

Ensure that you have the following taglib in each JSP.

<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t" %>

Example Page

Notice in the following example the h: tags are converted to t: tomahawk tags. Also observe the highlighted lines below.

<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles"  %>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t" %>

<f:subview id="genre_tile">

    <h3>Genre Table</h3>

    <h:form>
    <p>
    	<t:dataTable styleClass="data_table" value="#{genreBean.allGenre}" var="genre">
    		<t:column sortable="true">
    		    <f:facet name="header">
		        	<h:outputText value="id" />
        		</f:facet> 
    			<h:outputText value="#{genre.id}"/>
    		</t:column>
    		<t:column sortable="true">
    		    <f:facet name="header">
		        	<h:outputText value="Name" />
        		</f:facet> 
    			<t:outputText value="#{genre.name}"/>
    		</t:column>
    	</t:dataTable>
		<h:commandButton value="Submit" action="#{genreBean.process}"/>
    </h:form>    	
    </p>
</f:subview>
Advertisements

1 Response to “column sorting using JSF and Tomahawk”


  1. September 2, 2010 at 6:58 am

    I am trying to use tomahawk t:dataScroller for pagination on my jsf page. Data is rendered properly for the first page but whenever I try to click any button to go to next page, java script error is thrown as below

    form is undefined
    var oldTarget = form.target;

    Any solution to this will be quite helpful.

    I am using tomahawk12-1.1.9 lib with JSF2.0


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 75 other followers

December 2009
S M T W T F S
« Nov   Jan »
 12345
6789101112
13141516171819
20212223242526
2728293031  

Blog Stats

  • 813,810 hits

%d bloggers like this: