[Ajax4JSF] facelet+jsf-comp/ClientValidators,不工作
afadgaeg
2008-08-05
初学jsf
tomcat下jsf(ri-1.2),facelets,tomahawk,运行良好 增加jsf-comp/ClientValidators,a4j/richfaces 用jsf-comp-facelets-deployment-0.2.1整合 整个工程四个文件如下: 清单一:web.xml <?xml version="1.0" encoding="UTF-8"?> <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"> <session-config> <session-timeout>30</session-timeout> </session-config> <welcome-file-list> <welcome-file>index.xhtml</welcome-file> </welcome-file-list> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.xhtml</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>/faces/*</url-pattern> </servlet-mapping> <context-param> <param-name>javax.faces.STATE_SAVING_METHOD</param-name> <param-value>client</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>org.richfaces.SKIN</param-name> <param-value>blueSky</param-value> </context-param> <context-param> <param-name>org.ajax4jsf.xmlparser.ORDER</param-name> <param-value>NEKO</param-value> </context-param> <context-param> <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name> <param-value> net.sf.jsfcomp.facelets.deploy.FaceletsViewHandler </param-value> </context-param> <filter> <display-name>RichFaces Filter</display-name> <filter-name>richfaces</filter-name> <filter-class>org.ajax4jsf.Filter</filter-class> </filter> <filter-mapping> <filter-name>richfaces</filter-name> <servlet-name>Faces Servlet</servlet-name> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> <dispatcher>INCLUDE</dispatcher> </filter-mapping> <filter> <filter-name>MyFacesExtensionsFilter</filter-name> <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class> </filter> <filter-mapping> <filter-name>MyFacesExtensionsFilter</filter-name> <servlet-name>Faces Servlet</servlet-name> </filter-mapping> <filter> <filter-name>ExtensionsFilter</filter-name> <filter-class> org.apache.myfaces.component.html.util.ExtensionsFilter </filter-class> <init-param> <param-name>uploadMaxFileSize</param-name> <param-value>10m</param-value> </init-param> <init-param> <param-name>uploadThresholdSize</param-name> <param-value>100k</param-value> </init-param> </filter> <filter-mapping> <filter-name>ExtensionsFilter</filter-name> <servlet-name>Faces Servlet</servlet-name> </filter-mapping> </web-app> 清单二: faces-config.xml <?xml version="1.0" encoding="UTF-8"?> <faces-config 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" version="1.2"> <application> <locale-config> <default-locale>zh</default-locale> </locale-config> <view-handler>com.sun.facelets.FaceletViewHandler</view-handler> </application> <managed-bean> <managed-bean-name>user</managed-bean-name> <managed-bean-class>jsf.bean.UserBean</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean> <navigation-rule> <navigation-case> <from-outcome>login</from-outcome> <to-view-id>/welcome.xhtml</to-view-id> </navigation-case> </navigation-rule> </faces-config> 清单三:index.xhtml <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="https://ajax4jsf.dev.java.net/ajax" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:t="http://myfaces.apache.org/tomahawk" xmlns:cv="http://sourceforge.net/projects/jsf-comp/clientvalidators"> <head> <title>欢迎</title> </head> <body> <f:view> <h3>欢迎</h3> <h:form> <h:outputLabel value="姓名" for="user"/> <h:inputText id="user" value="#{user.name}"> <cv:requiredFieldValidator componentToValidate="user" errorMessage="请输入姓名"/> <t:validateEmail/> </h:inputText> <h:message for="user"/> <h:commandButton value="提交" action="login" onClick="return validate();"/> </h:form> </f:view> </body> </html> 清单四:welcome.xhtml <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="https://ajax4jsf.dev.java.net/ajax" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:t="http://myfaces.apache.org/tomahawk" xmlns:cv="http://sourceforge.net/projects/jsf-comp/clientvalidators"> <head> <title>欢迎</title> </head> <body> <f:view> <h:outputText value="#{user.name}"/>欢迎<h3>欢迎使用JavaServer Faces</h3> </f:view> </body> </html> ide netbeans部署成功 浏览器javascript开启 服务器端验证工作 client side validator不工作 查看页面源文件无js生成 江湖救ji |
|
confuse
2008-08-06
这个问题是你没有把客户端验证的标签注册进facelet环境中,
facelets.LIBRARIES
/WEB-INF/clientsidevalidators.taglib.xml
不注册facelet根本不认识啥叫cv:requiredFieldValidator,具体配置请参照以下链接,搜索facelet就能找到和你的问题一样的描述信息,下面就是解答
http://www.jroller.com/cagataycivici/entry/jsf_client_side_validators
|
|
afadgaeg
2008-08-13
冒昧的说一句:jsf-comp/ClientValidators这个组件有很大问题,一个页面有两个form就有问题了,其实client端验证并没有特别大的好处,如果非要用,可以使用 shale validator组件,这个还能用,我就用它 ^_^
=================== 谢谢,我在用shale了。 这个问题是你没有把客户端验证的标签注册进facelet环境中, facelets.LIBRARIES /WEB-INF/clientsidevalidators.taglib.xml 不注册facelet根本不认识啥叫cv:requiredFieldValidator,具体配置请参照以下链接,搜索facelet就能找到和你的问题一样的描述信息,下面就是解答 http://www.jroller.com/cagataycivici/entry/jsf_client_side_validators ================== jsf-comp-facelets-deployment-0.2.1.jar就是注册用的 问题还是没解决 转过去用shale的了 谢谢 |
|
terryzhou
2008-08-15
mgh001 写道
冒昧的说一句:jsf-comp/ClientValidators这个组件有很大问题,一个页面有两个form就有问题了,其实client端验证并没有特别大的好处,如果非要用,可以使用 shale validator组件,这个还能用,我就用它 ^_^
|
|
afadgaeg
2008-08-16
我暂时不需要 谢谢
|
|
afadgaeg
2008-08-21
谢谢,我又用hibernate那玩意了,自从看到hibernate的模型验证,觉得还是模型验证的方式更适合我。尤其是我想在客户端做得眩一点,呵呵。谢谢各位同仁。
|
相关讨论
相关资源推荐
- JSF-api-1.2_14-sources.jar
- 2021-04-06
- 侯捷——STL源码剖析 笔记
- 侯捷-《STL源码剖析》的一些可能的错误
- 侯老师--STL源码剖析--书中的疑问二 (转)
- baseJSF:WildFly - JavaEE + CDI + JPA + JSF
- JSF开发包:commons-beanutils.jar+commons-collections.jar+commons-digester.jar+jsf-api.jar+jsf-impl.jar+jstl.jar+standard.jar
- facelet-xhtml.zip_JSF_facelet_jsf with ejb3
- JSF-AV-rules.rar_JSF AV rule_JSF-AV_JSF-AV-rules_航空C++编程规范
- WEB-INF/web.xml泄露漏洞及其利用