Problems with ajax4jsf and view-handler
wachtda Dec 11, 2007 10:44 AMhello together
i enhanced the helloworld example with different components.
now i try to work with the ajax4jsf:poll component!
i added the ajax4jsf component as decribed.
after deploy an start of the project my form-items not got rendered.
(input-fields, buttons)
if i uncomment the view-handler from the faces-config.xml,
the standard elements got rendered but i got a xml parser error,
because it finds not the ajax4jsf namespace!
XML Parsing Error: prefix not bound to a namespace
thanx for help!
greetings daniel
browser-output:
#{messages.tit_hello}
#{messages.name}:
#{messages.age}:
#{messages.email}:
#{messages.comment}:
faces-config.xml
<faces-config version="1.2" 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-facesconfig_1_2.xsd"> <application> <!-- <view-handler>com.sun.facelets.FaceletViewHandler</view-handler> --> <locale-config> <default-locale>de</default-locale> <supported-locale>de</supported-locale> <supported-locale>fr</supported-locale> <supported-locale>it</supported-locale> <supported-locale>en</supported-locale> <supported-locale>es</supported-locale> </locale-config> </application> </faces-config>
web.xml
<?xml version="1.0" ?> <web-app 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" version="2.5"> <!-- Ajax4jsf --> <context-param> <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name> <param-value>com.sun.facelets.FaceletViewHandler</param-value> </context-param> <!-- Seam --> <listener> <listener-class> org.jboss.seam.servlet.SeamListener </listener-class> </listener> <servlet> <servlet-name>Seam Resource Servlet</servlet-name> <servlet-class> org.jboss.seam.servlet.ResourceServlet </servlet-class> </servlet> <servlet-mapping> <servlet-name>Seam Resource Servlet</servlet-name> <url-pattern>/seam/resource/*</url-pattern> </servlet-mapping> <filter> <filter-name>Seam Filter</filter-name> <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class> </filter> <filter-mapping> <filter-name>Seam Filter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <context-param> <param-name>javax.faces.STATE_SAVING_METHOD</param-name> <param-value>server</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> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <!-- Faces Servlet Mapping --> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.seam</url-pattern> </servlet-mapping> </web-app>
hello.xhtml
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:s="http://jboss.com/products/seam/taglib" template="template.xhtml"> <ui:define name="content"> <h2>#{messages.tit_hello}</h2> <h:form> <f:facet name="beforeInvalidField"> <h:graphicImage styleClass="errorImg" value="error.png" /> </f:facet> <f:facet name="afterInvalidField"> <s:message styleClass="errorMsg" /> </f:facet> <f:facet name="aroundInvalidField"> <s:div styleClass="error"/> </f:facet> <s:validateAll> <table> <tr> <td>#{messages.name}:</td> <td> <s:decorate> <h:inputText value="#{person.name}" size="15" required="true" requiredMessage="#{messages.error_input}"/> </s:decorate> </td> </tr> <tr> <td>#{messages.age}:</td> <td> <s:decorate> <h:inputText value="#{person.age}" size="15" required="true" requiredMessage="#{messages.error_input}"/> </s:decorate> </td> </tr> <tr> <td>#{messages.email}:</td> <td> <s:decorate> <h:inputText value="#{person.email}" size="15" required="true" requiredMessage="#{messages.error_input}"/> </s:decorate> </td> </tr> <tr> <td>#{messages.comment}:</td> <td> <s:decorate> <h:inputTextarea value="#{person.comment}"/> </s:decorate> </td> </tr> </table> </s:validateAll> <h:commandButton id="sayHello" action="#{manager.sayHello}" value="#{messages.btn_sayHello}"/> </h:form> </ui:define> </ui:composition>
fans.xhtml
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:s="http://jboss.com/products/seam/taglib" xmlns:a="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich" template="template.xhtml"> <ui:define name="content"> <h2>#{messages.tit_fans}</h2> <p>#{messages.comm_fans}:</p> <a:region> <h:form> <a:poll id="poll" interval="500" enabled="true" reRender="poll,fans"/> </h:form> </a:region> <h:form> <h:dataTable id="fans" value="#{fans}" var="fan" > <h:column> <f:facet name="header">#{messages.name}</f:facet> #{fan.name} </h:column> <h:column> <f:facet name="header">#{messages.age}</f:facet> #{fan.age} </h:column> <h:column> <f:facet name="header">#{messages.email}</f:facet> #{fan.email} </h:column> <h:column> <f:facet name="header">#{messages.comment}</f:facet> #{fan.comment} </h:column> <h:column> <h:commandButton value="#{messages.btn_delete}" action="#{manager.delete}"/> </h:column> <h:column> <a href="person.seam?pid=#{fan.id}">#{messages.btn_edit}</a> </h:column> </h:dataTable> <center> <s:button id="cancel" value="#{messages.btn_back}" view="/hello.xhtml"/> </center> </h:form> </ui:define> </ui:composition>