<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Sheila&#039;s Blog &#187; seam</title>
	<atom:link href="http://sheilapollard.com/category/seam/feed/" rel="self" type="application/rss+xml" />
	<link>http://sheilapollard.com</link>
	<description>Software Development</description>
	<lastBuildDate>Wed, 24 Mar 2010 17:19:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Configuring Seam and Spring Batch</title>
		<link>http://sheilapollard.com/2010/02/04/configuring-seam-and-spring-batch/?utm_campaign=feed&utm_medium=feed&utm_source=blog</link>
		<comments>http://sheilapollard.com/2010/02/04/configuring-seam-and-spring-batch/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 11:26:41 +0000</pubDate>
		<dc:creator>Sheila</dc:creator>
				<category><![CDATA[seam]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[spring batch]]></category>

		<guid isPermaLink="false">http://sheilapollard.com/?p=529</guid>
		<description><![CDATA[Seam provides jbpm for handling workflows, but doesn&#8217;t have anything dedicated so far to the issue of batch processing.  While jbpm will handle complex business conditional steps, some steps are repetitive rather than complex and are better suited to a batch framework, like Spring Batch.  In order to use Spring Batch with Seam, [...]]]></description>
			<content:encoded><![CDATA[<p>Seam provides jbpm for handling workflows, but doesn&#8217;t have anything dedicated so far to the issue of batch processing.  While jbpm will handle complex business conditional steps, some steps are repetitive rather than complex and are better suited to a batch framework, like Spring Batch.  In order to use Spring Batch with Seam, you will first need to follow the steps to configure Seam to start up the Spring container and make the required Spring beans accessible as Seam components.</p>
<p>These steps describe adding a very simplistic batch job and calling it from a Seam class.  As a simple batch example, the database tables usually used by Spring batch will be held in memory and not persisted to a database.</p>
<p>The first step in the batch process is to upload a csv file and extract the list of people contained in it.  The test file is:
<code>title,firstname,surname,dateOfBirth,country
Mr,John,Smith,1949,United States
Ms,Jane,Smith,03/09/1994,England
Mr,David,Moore,13/04/1972,France
Mr,Robert,Fisher,26/06/1946,Brazil</code></p>
<p>You need to add the following jar files to your ear file (in addition to the ones here.</p>
<blockquote><p>
spring/org.springframework.batch.core-2.0.0.RELEASE.jar<br />
spring/org.springframework.batch.infrastructure-2.0.0.RELEASE.jar<br />
spring/aopalliance-1.0.jar<br />
spring/org.springframework.aop-3.0.0.RELEASE.jar<br />
spring/org.springframework.jdbc-3.0.0.RELEASE.jar<br />
spring/org.springframework.transaction-3.0.0.RELEASE.jar
</p></blockquote>
<p>You should create a new folder to hold the configuration files for your batch jobs on the class path, eg. WEB-INF/classes/exampleJob.xml.  You can import these files into your applicationContext.xml.
<code>&lt;import resource="classpath:/jobs/exampleJob.xml" /&gt;</code></p>
<p>Rather than persisting information about the batch job to a database, you can define an in-memory data source to hold the information in applicationContext.xml.  You need a job repository and a transaction manager defined.
<code>&lt;bean id="jobRepository" class="org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean"&gt;
      &lt;property name="transactionManager" ref="transactionManager"/&gt;
  &lt;/bean&gt;

  &lt;bean id="transactionManager" class="org.springframework.batch.support.transaction.ResourcelessTransactionManager"/&gt;</code></p>
<p>The exampleJob.xml contains the configuration for the batch job itself:
<code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:seam="http://jboss.com/products/seam/spring-seam"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:batch="http://www.springframework.org/schema/batch"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
    http://jboss.com/products/seam/spring-seam http://jboss.com/products/seam/spring-seam-2.2.xsd
    http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.0.xsd"&gt;

  &lt;bean id="exampleJob"
    class="com.example.ExampleJob"&gt;
    &lt;seam:component/&gt;
  &lt;/bean&gt;
  
  &lt;bean id="jobLauncher"
    class="org.springframework.batch.core.launch.support.SimpleJobLauncher"&gt;
    &lt;property name="jobRepository" ref="jobRepository" /&gt;
    &lt;seam:component/&gt;
  &lt;/bean&gt;
  
  &lt;batch:job id="personUpload"&gt;
    &lt;batch:step id="personload"&gt;
      &lt;batch:tasklet&gt;
        &lt;batch:chunk reader="personItemReader" writer="exampleWriter" commit-interval="5"/&gt;
      &lt;/batch:tasklet&gt;
    &lt;/batch:step&gt;
  &lt;/batch:job&gt;

  &lt;bean id="personItemReader" class="org.springframework.batch.item.file.FlatFileItemReader"&gt;
    &lt;property name="resource" value="file://C:/workspaces/test/v3_crime/testdata/watchlist/uploadwatchlist1.csv" /&gt;
    &lt;property name="lineMapper"&gt;
      &lt;bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper"&gt;
        &lt;property name="lineTokenizer"&gt;
          &lt;bean class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer"&gt;
            &lt;property name="names" value="title,firstname,surname,dateOfBirth,country" /&gt;
          &lt;/bean&gt;
        &lt;/property&gt;  
        &lt;property name="fieldSetMapper"&gt;
          &lt;bean class="com.example.ExampleFieldSetMapper" /&gt;
        &lt;/property&gt;
      &lt;/bean&gt;
    &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="exampleWriter" class="com.example.ExampleWriter" /&gt;
  
&lt;/beans&gt;</code><br />
In this file we define the exampleJob bean which is a java class called ExampleJob.  This is a spring class that is wrapped as a seam component.  We also define a job launcher that uses the job repository already defined in applicationContext.xml.  </p>
<p>The batch job called personUpload contains the step personload which defines a reader and writer for the data.  To read the csv file we use Spring Batch&#8217;s FlatFileItemReader and tell it the names of the fields that are contained in the file.  It uses the ExampleFieldSetMapper class to do the mapping.  We also define an exampleWriter bean that will be used to display the data uploaded in the logs.</p>
<p>The ExampleJob.java class simply launches the batch job.
<code>public class ExampleJob {

    @Autowired
    private JobLauncher jobLauncher;

    @Autowired
    private Job job;

    public void launchJob() throws Exception {
        jobLauncher.run(job, new JobParameters());
    }
}</code></p>
<p>The ExampleFieldSetMapper.java takes the data read in from each line in the csv file and stores it as an UploadedPerson (a simple class containing the properties and getters/setters required).
<code>public class ExampleFieldSetMapper implements FieldSetMapper&lt;UploadedPerson&gt; {

    public UploadedPerson mapFieldSet(FieldSet fs) {
        if(fs == null){
            return null;
        }
        
        UploadedPerson person = new UploadedPerson();
        person.setTitle(fs.readString("title"));
        person.setFirstname(fs.readString("firstname"));
        person.setSurname(fs.readString("surname"));
        person.setDateOfBirth(fs.readString("dateOfBirth"));
        person.setCountry(fs.readString("country"));
        return person;
    }

}</code></p>
<p>ExampleWriter.java just logs the list of UploadedPerson objects to the log files:
<code>public class ExampleWriter implements ItemWriter&lt;Object&gt; {

    UploadWatchlistService  watchlistService;
    
    private static final Log log = LogFactory.getLog(ExampleWriter.class);
    
    /**
     * @see ItemWriter#write(Object)
     */
    public void write(List&lt;? extends Object&gt; data) throws Exception {
        log.info(data);
    }

}</code></p>
<p>Now in the seam component that calls the job we inject the ExampleJob and
<code>@In(create=true)
private ExampleJob exampleJob;
...
try {
  exampleJob.launchJob();
} catch (Exception e) {
  log.info("There was an error: " + e);
}</code></p>
<br /><a href="http://sheilapollard.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL3NoZWlsYXBvbGxhcmQuY29tLz9wPTUyOSNjb21tZW50cw==" title=\"Comments on &quot;Configuring Seam and Spring Batch&quot;\"><img src="http://sheilapollard.com/wp-content/plugins/feed-comments-number/image.php?529" alt="Comments" /></a> <img src="http://sheilapollard.com/wp-content/plugins/feed-statistics.php?view=1&post_id=529" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://sheilapollard.com/2010/02/04/configuring-seam-and-spring-batch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configuring seam to integrate spring</title>
		<link>http://sheilapollard.com/2010/01/05/configuring-seam-to-integrate-spring/?utm_campaign=feed&utm_medium=feed&utm_source=blog</link>
		<comments>http://sheilapollard.com/2010/01/05/configuring-seam-to-integrate-spring/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 16:27:26 +0000</pubDate>
		<dc:creator>Sheila</dc:creator>
				<category><![CDATA[seam]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://sheilapollard.com/?p=517</guid>
		<description><![CDATA[There are advantages and disadvantages to choosing Spring or Seam for developing an application.  The third option is to use both of them and leverage the best of both frameworks.  If Spring and Seam are integrated then they can pass components to each other to use depending on which framework can construct that [...]]]></description>
			<content:encoded><![CDATA[<p>There are advantages and disadvantages to choosing Spring or Seam for developing an application.  The third option is to use both of them and leverage the best of both frameworks.  If Spring and Seam are integrated then they can pass components to each other to use depending on which framework can construct that component in the best possible way.  The instructions below are based on Seam 2.2.0.GA and Spring 3.0.0.</p>
<p>In order to integrate Spring into Seam, you need the ability to start up both of the containers and allow them access to each others components.  To assist with this Seam provides a special ContextLoader in the jboss-seam-ioc jar file, so that Seam can read the Spring configuration files and start up the Spring container.  To configure this you need to edit Seam&#8217;s components.xml and add the following namespace and schema entry:
<code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;components ...
xmlns:spring="http://jboss.com/products/seam/spring"
...
http://jboss.com/products/seam/spring http://jboss.com/products/seam/spring-2.2.xsd</code></p>
<p>Further down the file within the components section you instruct Seam to bootstrap the Spring container, assuming by default that there is a WEB-INF/applicationContext.xml containing the Spring configuration.
<code>&lt;spring:context-loader/&gt;</code></p>
<p>You then add a basic applicationContext.xml
<code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:seam="http://jboss.com/products/seam/spring-seam"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
    http://jboss.com/products/seam/spring-seam http://jboss.com/products/seam/spring-seam-2.2.xsd"&gt;
    
&lt;/beans&gt;</code></p>
<p>Any additional spring configuration will be added to this file.</p>
<p>For this code to work, you need to add the following jar files to your ear file.  The jboss-seam-ioc.jar contains the classes that allow you to integrate Spring and the other jars are required for the Spring configuration files.</p>
<blockquote><p>
jboss-seam-ioc-2.2.0.GA.jar<br />
org.springframework.asm-3.0.0.RELEASE.jar<br />
org.springframework.beans-3.0.0.RELEASE.jar<br />
org.springframework.core-3.0.0.RELEASE.jar<br />
org.springframework.context-3.0.0.RELEASE.jar<br />
org.springframework.expression-3.0.0.RELEASE.jar<br />
org.springframework.web-3.0.0.RELEASE.jar
</p></blockquote>
<p>You can now add a spring bean into your applicationContext.xml
<code>&lt;bean id="exampleSpringBean"
    class="com.example.exampleSpringBean"&gt;
    &lt;property name="testString" value="This is a test" /&gt;
    &lt;seam:component/&gt;
  &lt;/bean&gt;</code></p>
<p>You will obviously need to create a corresponding class for this bean.  The seam:component tag marks this bean as a SpringComponent which is registered for use as a Seam component by the Seam container.</p>
<p>You can now inject the bean into another class as a seam component.
<code>@In(create=true)
private ExampleSpringBean exampleSpringBean;

...

String value = exampleSpringBean.getTestString();</code></p>
<p>This is a very simple example with basic configuration that doesn&#8217;t take into account any of the issues you may need to watch out for when mixing Spring and Seam.</p>
<br /><a href="http://sheilapollard.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL3NoZWlsYXBvbGxhcmQuY29tLz9wPTUxNyNjb21tZW50cw==" title=\"Comments on &quot;Configuring seam to integrate spring&quot;\"><img src="http://sheilapollard.com/wp-content/plugins/feed-comments-number/image.php?517" alt="Comments" /></a> <img src="http://sheilapollard.com/wp-content/plugins/feed-statistics.php?view=1&post_id=517" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://sheilapollard.com/2010/01/05/configuring-seam-to-integrate-spring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configuring Icefaces and JBoss Seam Excel</title>
		<link>http://sheilapollard.com/2009/08/20/configuring-icefaces-and-jboss-seam-excel/?utm_campaign=feed&utm_medium=feed&utm_source=blog</link>
		<comments>http://sheilapollard.com/2009/08/20/configuring-icefaces-and-jboss-seam-excel/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 10:14:42 +0000</pubDate>
		<dc:creator>Sheila</dc:creator>
				<category><![CDATA[icefaces]]></category>
		<category><![CDATA[seam]]></category>

		<guid isPermaLink="false">http://sheilapollard.com/?p=463</guid>
		<description><![CDATA[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&#8230;  Separate out the pages so that some are icefaces [...]]]></description>
			<content:encoded><![CDATA[<p>As in <a href="http://sheilapollard.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL3NoZWlsYXBvbGxhcmQuY29tLzIwMDkvMDgvMTcvY29uZmlndXJpbmctaWNlZmFjZXMtYW5kLXNlYW0tcGRmLz91dG1fY2FtcGFpZ249ZmVlZCZ1dG1fbWVkaXVtPWZlZWQmdXRtX3NvdXJjZT1ibG9n">Configuring Icefaces and Seam PDF</a>, 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&#8230;  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
<code&gt;&lt;e:workbook/&gt;&lt;/code> to the standard facelets view handler.</p>
<p>Steps:<br />
1.    Update to icefaces 1.8.1 and jboss-seam 2.2.0.GA and test the application still functions correctly.<br />
2.    Replace icefaces.jar with just-ice.jar (from the icefaces jars) and redeploy the application.  Fix any errors.<br />
3.    Add in the excel functionality.  Add jboss-seam-excel-2.2.0.GA.jar and jxl.jar to your ear file.<br />
4.    In components.xml add the excel and document namespaces<code>xmlns: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</code></p>
<p>5.    In faces-config.xml you add both view handlers
<code>&lt;application&gt;
  &lt;view-handler&gt;com.sun.facelets.FaceletViewHandler&lt;/view-handler&gt;
&lt;/application&gt;

&lt;application&gt;
  &lt;view-handler&gt;com.icesoft.faces.facelets.D2DSeamFaceletViewHandler&lt;/view-handler&gt;
  &lt;message-bundle&gt;
    JSFoverride
  &lt;/message-bundle&gt;
&lt;/application&gt;</code></p>
<p>6.    Configure the document servlet in web.xml
<code>&lt;servlet&gt;
  &lt;servlet-name&gt;Document Store Servlet&lt;/servlet-name&gt;
  &lt;servlet-class&gt;org.jboss.seam.document.DocumentStoreServlet&lt;/servlet-class&gt;
&lt;/servlet&gt;

&lt;servlet-mapping&gt;
  &lt;servlet-name&gt;Document Store Servlet&lt;/servlet-name&gt;
  &lt;url-pattern&gt;*.csv&lt;/url-pattern&gt;
&lt;/servlet-mapping&gt;
&lt;servlet-mapping&gt;
  &lt;servlet-name&gt;Document Store Servlet&lt;/servlet-name&gt;
  &lt;url-pattern&gt;*.xls&lt;/url-pattern&gt;
&lt;/servlet-mapping&gt;</code></p>
<p>and add a new mapping for jsf pages to be handled by the Faces Servlet
<code>&lt;servlet-mapping&gt;
  &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
  &lt;url-pattern&gt;*.jsf&lt;/url-pattern&gt;
&lt;/servlet-mapping&gt;</code><br />
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.
<code>&lt;ice:outputLink value="./docs/people.jsf"&gt;2nd Excel Test/&gt;</code></p>
<p>In people.xhtml I had to edit the value to excelTest.people instead of people
<code>&lt;e:worksheet name="People" value="#{excelTest.people}" var="person"&gt;</code></p>
<p>Now redeploy your application and try accessing people.jsf</p>
<br /><a href="http://sheilapollard.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL3NoZWlsYXBvbGxhcmQuY29tLz9wPTQ2MyNjb21tZW50cw==" title=\"Comments on &quot;Configuring Icefaces and JBoss Seam Excel&quot;\"><img src="http://sheilapollard.com/wp-content/plugins/feed-comments-number/image.php?463" alt="Comments" /></a> <img src="http://sheilapollard.com/wp-content/plugins/feed-statistics.php?view=1&post_id=463" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://sheilapollard.com/2009/08/20/configuring-icefaces-and-jboss-seam-excel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configuring Icefaces and Seam PDF</title>
		<link>http://sheilapollard.com/2009/08/17/configuring-icefaces-and-seam-pdf/?utm_campaign=feed&utm_medium=feed&utm_source=blog</link>
		<comments>http://sheilapollard.com/2009/08/17/configuring-icefaces-and-seam-pdf/#comments</comments>
		<pubDate>Mon, 17 Aug 2009 13:33:44 +0000</pubDate>
		<dc:creator>Sheila</dc:creator>
				<category><![CDATA[icefaces]]></category>
		<category><![CDATA[seam]]></category>

		<guid isPermaLink="false">http://sheilapollard.wordpress.com/?p=455</guid>
		<description><![CDATA[Unfortunately seam-pdf doesn&#8217;t play nice with ICEfaces.  Specifically, the D2DFaceletViewHandler doesn&#8217;t do pdf/email rendering.  The workaround for this is to separate the application into ICEFaces (ice: tags) and Non-ICEFaces (h: tags) pages which are the ones that trigger a pdf or email render.  You can replace icefaces.jar with just-ice.jar, which contains renderers [...]]]></description>
			<content:encoded><![CDATA[<p>Unfortunately seam-pdf doesn&#8217;t play nice with ICEfaces.  Specifically, the D2DFaceletViewHandler doesn&#8217;t do pdf/email rendering.  The workaround for this is to separate the application into ICEFaces (ice: tags) and Non-ICEFaces (h: tags) pages which are the ones that trigger a pdf or email render.  You can replace icefaces.jar with just-ice.jar, which contains renderers for ICEFaces components only.  Then configure the application to delegate any pages that consist of a
<p:document/> to the standard facelets view handler instead of D2DFaceletViewHandler.</p>
<p><strong>Steps:</strong></p>
<p>1.    I updated to icefaces 1.8.1 and jboss-seam 2.2.0.GA and tested the application still functioned correctly.<br />
2.    Replace icefaces.jar with just-ice.jar (from the icefaces jars) and redeploy the application.  You may get some errors.  For example I found a number of errors caused because an xhtml page contained more than one
<code&gt;&lt;ice:commandButton&gt;&lt;/code> with ids that weren't unique.<br />
3.    If the application is functioning correctly you can start adding in the pdf functionality.  Add itext.jar, itext-rtf.jar, jboss-seam-pdf.jar, jcommon.jar, and jfreechart.jar to your ear file.<br />
4.    In components.xml add the pdf and framework namespaces<code>xmlns:pdf="http://jboss.com/products/seam/pdf" xmlns:core="http://jboss.com/products/seam/core"
xmlns:framework="http://jboss.com/products/seam/framework"</code>
<code>http://jboss.com/products/seam/framework http://jboss.com/products/seam/framework-2.1.xsd
http://jboss.com/products/seam/pdf http://jboss.com/products/seam/pdf-2.1.xsd</code></p>
<p>Also add the following to configure missing pdfs:
<code>&lt;component name="org.jboss.seam.document.documentStore"&gt;
&lt;property name="useExtensions"&gt;true&lt;/property&gt;
&lt;property name="errorPage"&gt;/pdfMissing.seam&lt;/property&gt;
&lt;/component&gt;</code></p>
<p>5.    In faces-config.xml you add both view handlers<br/>
<code&gt;&lt;application>&lt;view-handler&gt;com.sun.facelets.FaceletViewHandler&lt;/view-handler&gt;
&lt;/application&gt;</code>
<code>&lt;application&gt;
&lt;view-handler&gt;com.icesoft.faces.facelets.D2DSeamFaceletViewHandler&lt;/view-handler&gt;
&lt;message-bundle&gt;
JSFoverride
&lt;/message-bundle&gt;
&lt;/application&gt;</code></p>
<p>6.    Configure the document servlet in web.xml
<code>&lt;servlet&gt;
&lt;servlet-name&gt;Document Store Servlet&lt;/servlet-name&gt;
&lt;servlet-class&gt;org.jboss.seam.document.DocumentStoreServlet&lt;/servlet-class&gt;
&lt;/servlet&gt;</code>
<code>&lt;servlet-mapping&gt;
&lt;servlet-name&gt;Document Store Servlet&lt;/servlet-name&gt;
&lt;url-pattern&gt;*.pdf&lt;/url-pattern&gt;
&lt;/servlet-mapping&gt;</code></p>
<p>and add a new mapping for jsf pages to be handled by the Faces Servlet
<code>&lt;servlet-mapping&gt;
&lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
&lt;url-pattern&gt;*.jsf&lt;/url-pattern&gt;
&lt;/servlet-mapping&gt;</code><br />
Your application should now be configured for icefaces pages, and non-icefaces pages that can render pdfs and emails.  To test this you can copy some of the .xhtml pages from seam's \examples\itext to test that the pdf rendering works.  The index.html lists the examples available.  You will need to take lists.xhtml and Lists.java and add them to your application to test that the PDF Lists link in the index works correctly.  Assuming your application has no errors and the PDF List example generates a pdf successfully, you're ready to use seam pdf in your web application.</p>
<br /><a href="http://sheilapollard.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL3NoZWlsYXBvbGxhcmQud29yZHByZXNzLmNvbS8/cD00NTUjY29tbWVudHM=" title=\"Comments on &quot;Configuring Icefaces and Seam PDF&quot;\"><img src="http://sheilapollard.com/wp-content/plugins/feed-comments-number/image.php?455" alt="Comments" /></a> <img src="http://sheilapollard.com/wp-content/plugins/feed-statistics.php?view=1&post_id=455" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://sheilapollard.com/2009/08/17/configuring-icefaces-and-seam-pdf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debugging Seam applications</title>
		<link>http://sheilapollard.com/2009/04/03/debugging-seam-applications/?utm_campaign=feed&utm_medium=feed&utm_source=blog</link>
		<comments>http://sheilapollard.com/2009/04/03/debugging-seam-applications/#comments</comments>
		<pubDate>Fri, 03 Apr 2009 10:52:18 +0000</pubDate>
		<dc:creator>Sheila</dc:creator>
				<category><![CDATA[seam]]></category>
		<category><![CDATA[debug]]></category>

		<guid isPermaLink="false">http://sheilapollard.wordpress.com/?p=249</guid>
		<description><![CDATA[Seam provides two different pages that can be useful for debugging applications.  The Facelets Debug page which shows page-rendering errors, and the Seam Debug page which shows any uncaught application exceptions.
Enable the Facelets Debug Page:
In web.xml you set Facelets to development mode.
WEB-INF/web.xml
&#60;context-param&#62;
  &#60;param-name&#62;facelets.DEVELOPMENT&#60;/param-name&#62;
  &#60;param-value&#62;true&#60;/param-value&#62;
&#60;/context-param&#62;
The Facelets debug page gives you the line number in [...]]]></description>
			<content:encoded><![CDATA[<p>Seam provides two different pages that can be useful for debugging applications.  The Facelets Debug page which shows page-rendering errors, and the Seam Debug page which shows any uncaught application exceptions.</p>
<p><strong>Enable the Facelets Debug Page:</strong><br />
In web.xml you set Facelets to development mode.<br />
WEB-INF/web.xml
<code>&lt;context-param&gt;
  &lt;param-name&gt;facelets.DEVELOPMENT&lt;/param-name&gt;
  &lt;param-value&gt;true&lt;/param-value&gt;
&lt;/context-param&gt;</code></p>
<p>The Facelets debug page gives you the line number in the .xhtml page where the error occured and access to the JSF component tree.</p>
<p>You can access the facelets debug page at any point by setting a hot key for that page.  To launch a debug popup on a page using CTRL-SHIFT-D, add &lt;ui:debug hotkey=&#8221;d&#8221;/&gt; in the page.</p>
<p><strong>Enable the Seam Debug Page:</strong><br />
You need to <a href="http://sheilapollard.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL3NoZWlsYXBvbGxhcmQuY29tLzIwMDkvMDQvMDIvYWRkaW5nLWZhY2VsZXRzLWFuZC1zZWFtLXVpLXRvLXlvdXItYXBwbGljYXRpb24vP3V0bV9jYW1wYWlnbj1mZWVkJnV0bV9tZWRpdW09ZmVlZCZ1dG1fc291cmNlPWJsb2c=">add Facelets and Seam UI Support</a>, then enable debugging in components.xml</p>
<p>WEB-INF/components.xml
<code>&lt;core:init jndi-pattern="example/#{ejbName}/local" debug=true/&gt;</code>where example is the name of the application.</p>
<p>You can always access the seam debug page by going to the /debug.seam page in your browser.</p>
<br /><a href="http://sheilapollard.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL3NoZWlsYXBvbGxhcmQud29yZHByZXNzLmNvbS8/cD0yNDkjY29tbWVudHM=" title=\"Comments on &quot;Debugging Seam applications&quot;\"><img src="http://sheilapollard.com/wp-content/plugins/feed-comments-number/image.php?249" alt="Comments" /></a> <img src="http://sheilapollard.com/wp-content/plugins/feed-statistics.php?view=1&post_id=249" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://sheilapollard.com/2009/04/03/debugging-seam-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding Facelets and Seam UI to your application</title>
		<link>http://sheilapollard.com/2009/04/02/adding-facelets-and-seam-ui-to-your-application/?utm_campaign=feed&utm_medium=feed&utm_source=blog</link>
		<comments>http://sheilapollard.com/2009/04/02/adding-facelets-and-seam-ui-to-your-application/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 15:38:17 +0000</pubDate>
		<dc:creator>Sheila</dc:creator>
				<category><![CDATA[seam]]></category>
		<category><![CDATA[facelets]]></category>

		<guid isPermaLink="false">http://sheilapollard.wordpress.com/?p=244</guid>
		<description><![CDATA[It&#8217;s generally recommended in seam applications that Facelets be used instead of JSP.  JSP pages are processed by the JSP container at the same time as they&#8217;re processed by the JSF engine which can cause conflicts.  Performance is also improved when the JSP engine isn&#8217;t used.  Facelets is a templating framework that also gives access [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s generally recommended in seam applications that Facelets be used instead of JSP.  JSP pages are processed by the JSP container at the same time as they&#8217;re processed by the JSF engine which can cause conflicts.  Performance is also improved when the JSP engine isn&#8217;t used.  Facelets is a templating framework that also gives access to XHTML tags and extra debugging support.</p>
<p>It&#8217;s also recommended that you add seam&#8217;s UI tags which allow the use of Hibernate&#8217;s validator annotations and provide conversation and business process management along with other extra tags.</p>
<p>To enable these you need to edit your configuration files and add some jar files.</p>
<p><strong>Add required jar files:</strong><br />
WEB-INF/lib:
<code>jsf-facelets.jar
jboss-seam-ui.jar
jboss-seam-debug.jar</code></p>
<p>Add el-api.jar and el-ri.jar to the ear file so they can be used by both your war and jar files.  Make an entry in the application.xml file to make the jars available on the ear classpath.</p>
<p>META-INF/application.xml
<code>&lt;module&gt;
  &lt;java&gt;el-api.jar&lt;/java&gt;
&lt;/module&gt;  
&lt;module&gt;
 &lt;java&gt;el-ri.jar&lt;/java&gt;
&lt;/module&gt;</code></p>
<p><strong>Add a View Handler:</strong><br />
The view handler renders html pages from facelets pages and templates.</p>
<p>WEB-INF/faces-config.xml
<code>&lt;application&gt;
  &lt;view-handler&gt;org.jboss.seam.ui.facelets.SeamFaceletViewHandler&lt;/view-handler&gt;
&lt;/application&gt;</code></p>
<p>Update the web.xml so that the facelets suffix .xhtml will be used for web pages.</p>
<p>WEB-INF/web.xml
<code>&lt;context-param&gt;
  &lt;param-name&gt;javax.faces.DEFAULT_SUFFIX&lt;/param-name&gt;
  &lt;param-value&gt;.xhtml&lt;/param-value&gt;
&lt;/context-param&gt;</code></p>
<p><strong>Add the Filter and Resource Servlet:</strong><br />
The SeamFilter supports JSF redirects, error pages and file uploads.  The resource servlet gives access to images and css files in jboss-seam-ui.jar and gives direct access to seam components from javascript.  You add these to your web.xml.</p>
<p>WEB-INF/web.xml
<code>&lt;servlet&gt;
  &lt;servlet-name&gt;Seam Resource Servlet&lt;/servlet-name&gt;
  &lt;servlet-class&gt;org.jboss.seam.servlet.SeamResourceServlet&lt;/servlet-class&gt;
&lt;/servlet&gt;
&lt;servlet-mapping&gt;
  &lt;servlet-name&gt;Seam Resource Servlet&lt;/servlet-name&gt;
  &lt;url-pattern&gt;/seam/resource/*&lt;/url-pattern&gt;
&lt;/servlet-mapping&gt;

&lt;filter&gt;
  &lt;filter-name&gt;Seam Filter&lt;/filter-name&gt;
  &lt;filter-class&gt;org.jboss.seam.servlet.SeamFilter&lt;/filter-class&gt;
&lt;/filter&gt;

&lt;filter-mapping&gt;
  &lt;filter-name&gt;Seam Filter&lt;/filter-name&gt;
  &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
&lt;/filter-mapping&gt;</code></p>
<p>You can now use .xhtml pages in your application and make use of the seam ui tags.</p>
<br /><a href="http://sheilapollard.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL3NoZWlsYXBvbGxhcmQud29yZHByZXNzLmNvbS8/cD0yNDQjY29tbWVudHM=" title=\"Comments on &quot;Adding Facelets and Seam UI to your application&quot;\"><img src="http://sheilapollard.com/wp-content/plugins/feed-comments-number/image.php?244" alt="Comments" /></a> <img src="http://sheilapollard.com/wp-content/plugins/feed-statistics.php?view=1&post_id=244" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://sheilapollard.com/2009/04/02/adding-facelets-and-seam-ui-to-your-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Beginner&#039;s introduction to Seam</title>
		<link>http://sheilapollard.com/2009/03/13/beginners-introduction-to-seam/?utm_campaign=feed&utm_medium=feed&utm_source=blog</link>
		<comments>http://sheilapollard.com/2009/03/13/beginners-introduction-to-seam/#comments</comments>
		<pubDate>Fri, 13 Mar 2009 09:50:42 +0000</pubDate>
		<dc:creator>Sheila</dc:creator>
				<category><![CDATA[seam]]></category>

		<guid isPermaLink="false">http://sheilapollard.wordpress.com/?p=20</guid>
		<description><![CDATA[A quick summary of what Seam is, and why you might be interested in learning more about it.]]></description>
			<content:encoded><![CDATA[<p>Seam is one of the newer frameworks that has been gaining in popularity recently.  It was created by Gavin King who will already be familiar to Hibernate users.  It&#8217;s based on POJOs (Plain Old Java Objects) known as components and annotations for those components that reduce the need for extensive xml configuration files.  The components are wired together using dependency injection where components declare their dependencies, and Seam looks after getting the the components needed and injecting them for you.</p>
<p>While it&#8217;s still nowhere near as widespread as Spring, it brings some functionality that was missing in Spring, and can complement or replace Spring depending on what features you value in your web application.  From first experiences using the framework I can see many benefits to Seam, but would caution that it&#8217;s not quite so easy to use as some of the documentation might lead you to believe.  It can solve the problems it was designed to fix, but you have to be careful that you not only understand the problems, but also the solutions being applied.  You really need to code your application in a way that allows it to make use of what Seam is able to do well, otherwise you may inadvertantly bypass what you wanted.  If you don&#8217;t really understand the nuances of how Seam is solving typical problems, chances are your code isn&#8217;t going to be able to take advantage of what Seam does offer.  The other disadvantage is that in being able to use the framework in many different ways, a beginner can have trouble figuring out which way is best to implement something for their own particular scenario.  If you have a lot of very experienced developers on your team, these won&#8217;t be such big issues.  But it&#8217;s something to be aware of if you don&#8217;t already have Seam experience on the team.</p>
<p><em>So what problems is Seam supposed to solve?</em><br />
One of Seam&#8217;s purposes is to fill in the gap between using JSF for the web tier which is usually based on stateless simple requests and responses, and EJB3 for the business tier which can deal with transactional resources.  Ordinarily to use these two frameworks together you need to write extra configuration code and backing beans.  Seam annotations allow business components to be used directly by the front end.  You use Entity objects to represent data that is mapped to a relational database table.  JSF web pages can display and capture data using the JSF Expression Language (EL) and map the data directly back to the backend.  You then have handlers that can update the data or perform business logic. There are also some extra seam tags available to use that fix some issues with JSF tags.</p>
<p>Another thing Seam brings to the table is more than just a Session scope or context.  The most interesting one being the Conversation scope.  The extra scopes mean that less data is stored in the session and can be managed in a wiser manner.  More on the conversation scope another time as it&#8217;s a big area to get your head around.</p>
<p>The next solution Seam offers is to help end the LazyInitialization exceptions seen when using Hibernate (which was designed for use in Stateful applications) or other ORM (Object Relational Mapping) solutions with a Stateless framework.  These LazyInitialization exceptions occur because Hibernate is based on using objects containing data that can have other associated objects.  Lazy loading is used to avoid fetching large amounts of data that might not be used when loading a parent object that has other child objects associated with it.   The associated child objects are not loaded unless specifically requested.  But we run into a problem in a Stateless framework as the persistence context is destroyed once the parent is passed to the presentation layer.  If the presentation layer requests a child object, then a lazy loading exception is thrown as the persistence context is no longer available for the second request.  This means that DTOs (Data Transfer Objects) have to be used.  Seam can keep the persistence context open until a page is fully rendered, or longer across a number of pages or a session.  So there should be no lazy loading exceptions and the performance improves when changes are only flushed to the database at the end of a conversation.</p>
<p>These are some of the main reasons why you might choose to use Seam in a project.  There&#8217;s a lot to cover in the Seam framework however, so this only scratches the surface before going into more detail in each area.</p>
<br /><a href="http://sheilapollard.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL3NoZWlsYXBvbGxhcmQud29yZHByZXNzLmNvbS8/cD0yMCNjb21tZW50cw==" title=\"Comments on &quot;Beginner&#039;s introduction to Seam&quot;\"><img src="http://sheilapollard.com/wp-content/plugins/feed-comments-number/image.php?20" alt="Comments" /></a> <img src="http://sheilapollard.com/wp-content/plugins/feed-statistics.php?view=1&post_id=20" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://sheilapollard.com/2009/03/13/beginners-introduction-to-seam/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Passing a parameter to a page fragment in Seam</title>
		<link>http://sheilapollard.com/2009/03/11/passing-a-parameter-to-a-page-fragment-in-seam/?utm_campaign=feed&utm_medium=feed&utm_source=blog</link>
		<comments>http://sheilapollard.com/2009/03/11/passing-a-parameter-to-a-page-fragment-in-seam/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 11:52:33 +0000</pubDate>
		<dc:creator>Sheila</dc:creator>
				<category><![CDATA[seam]]></category>

		<guid isPermaLink="false">http://sheilapollard.wordpress.com/?p=43</guid>
		<description><![CDATA[In the main .xhtml page within the ui:include tag you pass in a ui:param value:
&#60;ui:include src="#{fragmentPage}"&#62;
  &#60;ui:param name="location" value="1" /&#62;
&#60;/ui:include&#62;
In the frament page you can reference the location value in the normal way:
&#60;ice:outputText value="#{manager.getLocation( '#{location}')}" /&#62;
And can use that value to pass to a backing bean method called from the fragment.
 ]]></description>
			<content:encoded><![CDATA[<p>In the main .xhtml page within the ui:include tag you pass in a ui:param value:
<code>&lt;ui:include src="#{fragmentPage}"&gt;
  &lt;ui:param name="location" value="1" /&gt;
&lt;/ui:include&gt;</code></p>
<p>In the frament page you can reference the location value in the normal way:
<code>&lt;ice:outputText value="#{manager.getLocation( '#{location}')}" /&gt;</code></p>
<p>And can use that value to pass to a backing bean method called from the fragment.</p>
<br /><a href="http://sheilapollard.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL3NoZWlsYXBvbGxhcmQud29yZHByZXNzLmNvbS8/cD00MyNjb21tZW50cw==" title=\"Comments on &quot;Passing a parameter to a page fragment in Seam&quot;\"><img src="http://sheilapollard.com/wp-content/plugins/feed-comments-number/image.php?43" alt="Comments" /></a> <img src="http://sheilapollard.com/wp-content/plugins/feed-statistics.php?view=1&post_id=43" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://sheilapollard.com/2009/03/11/passing-a-parameter-to-a-page-fragment-in-seam/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Icefaces link issue in Seam &#8211; missing dataModel</title>
		<link>http://sheilapollard.com/2009/03/09/icefaces-link-issue-in-seam-missing-datamodel/?utm_campaign=feed&utm_medium=feed&utm_source=blog</link>
		<comments>http://sheilapollard.com/2009/03/09/icefaces-link-issue-in-seam-missing-datamodel/#comments</comments>
		<pubDate>Mon, 09 Mar 2009 18:42:50 +0000</pubDate>
		<dc:creator>Sheila</dc:creator>
				<category><![CDATA[icefaces]]></category>
		<category><![CDATA[seam]]></category>

		<guid isPermaLink="false">http://sheilapollard.wordpress.com/?p=17</guid>
		<description><![CDATA[The problem is:
We have a list of objects (we&#8217;ll call them Cars) displayed as results from a search in a seam web application.  This is displayed as rows, iterating through the results to reference thisCar for the current result in each row.  We want to be able to select one of the Cars [...]]]></description>
			<content:encoded><![CDATA[<p>The problem is:<br />
We have a list of objects (we&#8217;ll call them Cars) displayed as results from a search in a seam web application.  This is displayed as rows, iterating through the results to reference thisCar for the current result in each row.  We want to be able to select one of the Cars and open a new window which shows the selected car information, but retains the search results also.  </p>
<p>So the current conversation should be brought through to the new window (to keep the current result set), and then the selected Car should be set (starting a new conversation). The s:link tag maintains the conversation, but currently does not work correctly as it is missing a backing datamodel.  To add that datamodel would require substantial refactoring, adding a lot of extra seam components just to allow the selection to work.</p>
<p>The broken url is http://localhost:8080/app/page.seam?actionMethod=page.xhtml:selectedCar.setCar(thisCar)&amp;cid=3</p>
<p>Without the backing datamodel, the thisCar variable gets passed into the setCar method as null.</p>
<p>A workaround for this is to use a request parameter in the backing bean and a new method that retrieves the list of results and identifies the correct car to select from that.</p>
<p>In the xhtml page use the s:link tag with a parameter set to the current row id:
<code>&lt;s:link id="selectCar" value="#{thisCar.id}" style="color:blue" action="#{selectedCar.setCar()}"&gt;
&lt;f:param name="rowId" value="#{thisCar.id}" /&gt;</code><br />
In the backing bean that row id is a request parameter:
<code>@RequestParameter
private String rowId;</code><br />
Use the rowId to determine the correct car:
<code>public void setCar() {
  int selected = (Integer.parseInt(rowId));&lt;/p&gt;

  Iterator it = results.iterator();
    while (it.hasNext()) {
    Car car= (Car)  it.next();
    if (car.getId() == selected) {
      selectedCar = car;&lt;
  }
}</code><br />
The url is now: http://localhost:8080/app/page.seam?rowId=3&amp;actionMethod=page.xhtml:selectedCar.setCar(selectedCar)&amp;cid=3</p>
<br /><a href="http://sheilapollard.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL3NoZWlsYXBvbGxhcmQud29yZHByZXNzLmNvbS8/cD0xNyNjb21tZW50cw==" title=\"Comments on &quot;Icefaces link issue in Seam &#8211; missing dataModel&quot;\"><img src="http://sheilapollard.com/wp-content/plugins/feed-comments-number/image.php?17" alt="Comments" /></a> <img src="http://sheilapollard.com/wp-content/plugins/feed-statistics.php?view=1&post_id=17" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://sheilapollard.com/2009/03/09/icefaces-link-issue-in-seam-missing-datamodel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
