Sheila's Blog

Software Development

Sheila's Blog header image 2

Configuring Icefaces and JBoss Seam Excel

August 20th, 2009 by Sheila

As in Configuring Icefaces and Seam PDF, when you want to render excel pages in an application that already uses seam and icefaces, you need to use the default view handler for rendering the excel files.  So you need to follow some of the same steps…  Separate out the pages so that some are icefaces pages only, the other pages are non-icefaces and do the Excel rendering.   Replace icefaces.jar with just-ice.jar and configure the application to delegate pages that contain to the standard facelets view handler.

Steps:
1.    Update to icefaces 1.8.1 and jboss-seam 2.2.0.GA and test the application still functions correctly.
2.    Replace icefaces.jar with just-ice.jar (from the icefaces jars) and redeploy the application.  Fix any errors.
3.    Add in the excel functionality.  Add jboss-seam-excel-2.2.0.GA.jar and jxl.jar to your ear file.
4.    In components.xml add the excel and document namespacesxmlns:excel="http://jboss.com/products/seam/excel" xmlns:document="http://jboss.com/products/seam/document" http://jboss.com/products/seam/document http://jboss.com/products/seam/document-2.2.xsd http://jboss.com/products/seam/excel http://jboss.com/products/seam/excel-2.2.xsd

5.    In faces-config.xml you add both view handlers <application> <view-handler>com.sun.facelets.FaceletViewHandler</view-handler> </application> <application> <view-handler>com.icesoft.faces.facelets.D2DSeamFaceletViewHandler</view-handler> <message-bundle> JSFoverride </message-bundle> </application>

6.    Configure the document servlet in web.xml <servlet> <servlet-name>Document Store Servlet</servlet-name> <servlet-class>org.jboss.seam.document.DocumentStoreServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>Document Store Servlet</servlet-name> <url-pattern>*.csv</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>Document Store Servlet</servlet-name> <url-pattern>*.xls</url-pattern> </servlet-mapping>

and add a new mapping for jsf pages to be handled by the Faces Servlet <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.jsf</url-pattern> </servlet-mapping>
Your application should now be configured to render excels.  To test this you can copy some of the .xhtml pages from the seam \examples\excel to test that the rendering works.  Take ExcelTest.java and people.xhtml.  Create a normal index page and add a link to people.jsf. <ice:outputLink value="./docs/people.jsf">2nd Excel Test/>

In people.xhtml I had to edit the value to excelTest.people instead of people <e:worksheet name="People" value="#{excelTest.people}" var="person">

Now redeploy your application and try accessing people.jsf

Tags:   · No Comments

Leave a Comment

0 responses so far ↓

There are no comments yet...Kick things off by filling out the form below.