Seam 1.1.0.GA with IceFaces 1.5.1 - updating existing entity
scotttam Dec 18, 2006 1:39 PMSeam 1.1.0.GA
Icefaces 1.5.1
JBoss-AS 4.0.5.GA
MySQL 5.0.27
I created a basic Seam application following the instructions in the Seam documentation. I have 2 simple tables in a MySQL database for testing. I ran the following commands to create the basic application:
seam setup
seam new-project
seam generate-entities
After importing into Eclipse, deploying and starting the AS, the generated application works as expected. I can see the list of existing entities, create new ones and edit existing ones.
Now, I want to integrate with Icefaces. So, I followed the documentation from the Icefaces site:
http://support.icesoft.com/jive/servlet/KbServlet/download/623-102-847/SeamKBArticle.txt
When I redeploy, the list and creating a new entity works but selecting an existing item for update is not working. When I choose the Select link, it brings me to a page where all the fields are either 0 or empty, acting as if the id for the entity object does not exist.
Here's my web.xml:
<?xml version="1.0" ?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <context-param> <param-name>javax.faces.CONFIG_FILES</param-name> <param-value>/WEB-INF/navigation.xml</param-value> </context-param> <listener> <listener-class>org.jboss.seam.servlet.SeamListener</listener-class> </listener> <listener> <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class> </listener> <context-param> <param-name>javax.faces.STATE_SAVING_METHOD</param-name> <param-value>client</param-value> </context-param> <context-param> <param-name>facelets.DEVELOPMENT</param-name> <param-value>true</param-value> </context-param> <context-param> <param-name>javax.faces.DEFAULT_SUFFIX</param-name> <param-value>.xhtml</param-value> </context-param> <context-param> <param-name>com.icesoft.faces.actionURLSuffix</param-name> <param-value>.seam</param-value> </context-param> <context-param> <param-name>com.icesoft.faces.synchronousUpdate</param-name> <param-value>true</param-value> </context-param> <context-param> <param-name>com.icesoft.faces.doJSFStateManagement</param-name> <param-value>true</param-value> </context-param> <filter> <filter-name>Seam Exception Filter</filter-name> <filter-class>org.jboss.seam.servlet.SeamExceptionFilter</filter-class> </filter> <filter-mapping> <filter-name>Seam Exception Filter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <!-- ICEFACES --> <servlet> <servlet-name>Blocking Servlet</servlet-name> <servlet-class>com.icesoft.faces.webapp.xmlhttp.BlockingServlet</servlet-class> <load-on-startup> 1 </load-on-startup> </servlet> <servlet> <servlet-name>Persistent Faces Servlet</servlet-name> <servlet-class>com.icesoft.faces.webapp.xmlhttp.PersistentFacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Persistent Faces Servlet</servlet-name> <url-pattern>/xmlhttp/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>Persistent Faces Servlet</servlet-name> <url-pattern>/xmlhttp/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>Persistent Faces Servlet</servlet-name> <url-pattern>*.iface</url-pattern> </servlet-mapping> <!-- Blocking Servlet Mapping --> <servlet-mapping> <servlet-name>Blocking Servlet</servlet-name> <url-pattern>/block/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>Persistent Faces Servlet</servlet-name> <url-pattern>*.seam</url-pattern> </servlet-mapping> </web-app>
faces-config.xml
<?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN" "http://java.sun.com/dtd/web-facesconfig_1_1.dtd"> <faces-config> <application> <message-bundle>messages</message-bundle> <view-handler>com.icesoft.faces.facelets.D2DSeamFaceletViewHandler</view-handler> </application> <managed-bean> <managed-bean-name>highlight</managed-bean-name> <managed-bean-class>com.icesoft.faces.context.effects.Highlight</managed-bean-class> <managed-bean-scope>application</managed-bean-scope> </managed-bean> <managed-bean> <managed-bean-name>timeZoneBean</managed-bean-name> <managed-bean-class>com.test.par.TimeZoneBean</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean> <!-- Seam transaction management --> <lifecycle> <phase-listener>org.jboss.seam.jsf.TransactionalSeamPhaseListener</phase-listener> </lifecycle> <!-- No Seam transaction management --> <!-- <lifecycle> <phase-listener>org.jboss.seam.jsf.SeamPhaseListener</phase-listener> </lifecycle> --> </faces-config>
I also updated the build.xml to include the icefaces jars and replacing the facelets jar with the icefaces one:
<?xml version="1.0"?> <project name="myproject" default="deploy" basedir="."> <!-- Give user a chance to override without editing this file or typing -D --> <property file="${basedir}/build.properties" /> <!-- set global properties for this build --> <property name="project.name" value="myproject"/> <property name="dist.dir" value="dist" /> <property name="src.java.dir" value="src" /> <property name="lib.dir" value="lib" /> <property name="ear.dir" value="exploded-archives/${project.name}.ear" /> <property name="jar.dir" value="exploded-archives/${project.name}.jar" /> <property name="war.dir" value="exploded-archives/${project.name}.war" /> <property name="test.dir" value="build/test" /> <property name="embedded-ejb3.dir" value="${basedir}/embedded-ejb/conf" /> <property name="deploy.dir" value="${jboss.home}/server/default/deploy" /> <property name="ear.deploy.dir" value="${deploy.dir}/${project.name}.ear" /> <property name="jar.deploy.dir" value="${ear.deploy.dir}/${project.name}.jar" /> <property name="war.deploy.dir" value="${ear.deploy.dir}/${project.name}.war" /> <property name="testng.jar" value="${basedir}/lib/testng-4.5.1-jdk15.jar" /> <property name="javac.debug" value="true" /> <property name="javac.deprecation" value="false" /> <fileset id="lib" dir="${lib.dir}"> <include name="*.jar" /> </fileset> <path id="build.classpath"> <fileset refid="lib" /> </path> <target name="init" description="Initialize the build"> <mkdir dir="${jar.dir}" /> <mkdir dir="${ear.dir}" /> <mkdir dir="${war.dir}" /> <mkdir dir="${dist.dir}" /> </target> <target name="compile" depends="init" description="Compile the Java source code" unless="eclipse.running"> <javac classpathref="build.classpath" destdir="${jar.dir}" debug="${javac.debug}" deprecation="${javac.deprecation}" nowarn="on"> <src path="${src.java.dir}" /> </javac> </target> <target name="jar" depends="compile" description="Build the distribution .jar file"> <copy todir="${jar.dir}"> <fileset dir="${basedir}/resources"> <include name="seam.properties" /> <include name="import.sql" /> </fileset> </copy> <copy todir="${jar.dir}/META-INF"> <fileset dir="${basedir}/resources/META-INF"> <include name="ejb-jar.xml" /> <include name="persistence.xml" /> </fileset> </copy> </target> <target name="war" depends="compile" description="Build the distribution .war file"> <copy todir="${war.dir}"> <fileset dir="${basedir}/view" /> </copy> <copy todir="${war.dir}/WEB-INF"> <fileset dir="${basedir}/resources/WEB-INF"> <include name="*.*"/> <include name="classes/**/*.*"/> <exclude name="classes/**/*.class"/> </fileset> <filterset> <filter token="jndiPattern" value="${project.name}/#{ejbName}/local" /> <filter token="embeddedEjb" value="false" /> </filterset> </copy> <copy todir="${war.dir}/WEB-INF"> <fileset dir="${basedir}/resources/WEB-INF"> <include name="lib/*.*"/> <include name="classes/**/*.class"/> </fileset> </copy> <copy todir="${war.dir}/WEB-INF/lib"> <fileset dir="${lib.dir}"> <include name="icefaces.jar" /> <include name="icefaces-comps.jar" /> <include name="icefaces-facelets.jar" /> <include name="el-api.jar" /> <include name="el-ri.jar" /> <include name="jboss-seam-debug.jar" /> <include name="jboss-seam-ui.jar" /> </fileset> </copy> <copy todir="${war.dir}/WEB-INF/classes"> <fileset dir="${basedir}/resources"> <include name="messages*.properties"/> </fileset> </copy> </target> <target name="ear" description="Build the EAR"> <copy todir="${ear.dir}"> <fileset dir="${basedir}/resources"> <include name="*jpdl.xml" /> <include name="hibernate.cfg.xml" /> <include name="jbpm.cfg.xml" /> </fileset> <fileset dir="${lib.dir}"> <include name="jboss-seam.jar" /> <include name="jbpm*.jar" /> <include name="el-*.jar" /> </fileset> </copy> <copy todir="${ear.dir}/META-INF"> <fileset dir="${basedir}/resources/META-INF"> <include name="application.xml" /> <include name="jboss-app.xml" /> </fileset> </copy> </target> <target name="archive" depends="jar,war,ear" description="Package the archives"> <jar jarfile="${dist.dir}/${project.name}.jar" basedir="${jar.dir}"/> <jar jarfile="${dist.dir}/${project.name}.war" basedir="${war.dir}"/> <jar jarfile="${dist.dir}/${project.name}.ear"> <fileset dir="${ear.dir}"/> <fileset dir="${dist.dir}"> <include name="${project.name}.jar"/> <include name="${project.name}.war"/> </fileset> </jar> </target> <target name="datasource"> <fail unless="jboss.home">jboss.home not set</fail> <copy todir="${deploy.dir}"> <fileset dir="${basedir}/resources"> <include name="${project.name}-ds.xml" /> </fileset> </copy> </target> <target name="explode" depends="jar,war,ear,datasource" description="Deploy the exploded archive"> <fail unless="jboss.home">jboss.home not set</fail> <mkdir dir="${jar.deploy.dir}"/> <mkdir dir="${war.deploy.dir}"/> <copy todir="${jar.deploy.dir}"> <fileset dir="${jar.dir}"/> </copy> <copy todir="${war.deploy.dir}"> <fileset dir="${war.dir}"/> </copy> <copy todir="${ear.deploy.dir}"> <fileset dir="${ear.dir}"/> </copy> </target> <target name="unexplode" description="Undeploy the exploded archive"> <delete failonerror="no"> <fileset dir="${ear.deploy.dir}"> <exclude name="**/*.jar"/> </fileset> </delete> <delete file="${deploy.dir}/${project.name}-ds.xml" failonerror="no"/> <delete dir="${ear.deploy.dir}" failonerror="no"/> </target> <target name="restart" depends="explode" description="Restart the exploded archive"> <touch file="${ear.deploy.dir}/META-INF/application.xml"/> </target> <target name="deploy" depends="archive,datasource" description="Deploy to JBoss AS"> <fail unless="jboss.home">jboss.home not set</fail> <copy todir="${deploy.dir}" file="${dist.dir}/${project.name}.ear" /> </target> <target name="undeploy" description="Undeploy the example from JBoss"> <delete file="${deploy.dir}/${project.name}.ear" /> <delete file="${deploy.dir}/${project.name}-ds.xml" /> </target> <target name="clean" description="Cleans up the build directory"> <delete dir="${dist.dir}" /> <delete dir="${test.dir}" /> <delete dir="${ear.dir}" /> <delete dir="${war.dir}" /> <delete> <fileset dir="${jar.dir}"> <exclude name="**/*.class" if="eclipse.running"/> </fileset> </delete> </target> <target name="test" depends="jar,war,ear" description="Run the tests"> <taskdef resource="testngtasks" classpath="${testng.jar}" /> <copy todir="${test.dir}"> <fileset dir="${basedir}/resources" /> <fileset dir="${jar.dir}" /> </copy> <copy todir="${test.dir}/WEB-INF"> <fileset dir="${war.dir}/WEB-INF"> <exclude name="**/*.jar" /> </fileset> </copy> <copy todir="${test.dir}" flatten="true"> <fileset dir="${src.java.dir}"> <include name="**/*Test.xml" /> </fileset> </copy> <testng outputdir="${basedir}/testng-report"> <classpath path="${test.dir}" /> <classpath path="${embedded-ejb3.dir}" /> <classpath refid="build.classpath" /> <xmlfileset dir="${test.dir}" includes="*Test.xml" /> </testng> </target> </project>
Any ideas?