我正在使用Eclipse / jsf来创建我的Web应用程序。 我试图解决像This
这样的问题我包括:
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<jsp:root 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:jsp="http://java.sun.com/JSP/Page"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<html xmlns="http://www.w3.org/1999/xhtml">
我的代码:
<h:inputText id="cod" value="#{myBean.nwcode}"
size="25" maxlength="30" required="true" requiredMessage="CODE est obligatoire" >
<f:ajax listener="#{myBean.namedChanged}" render="@form"/>
</h:inputText>
缺少什么?。
如果在这种情况下无法使用Tag,请告诉我如何使用valueChangeListener属性,因为我已经实现了一个方法:
public void OnproCodeChangeCheckValid(ValueChangeEvent VChEvnt)
{
if(!((String)VChEvnt.getNewValue()).equals(null)&&!((String)VChEvnt.getNewValue()).trim().isEmpty())
{
nwprofvalid=!estprofileexist((String)VChEvnt.getNewValue());
}
}
但是这个方法并没有被简单地说:
valueChangeListener="#{myBean.OnproCodeChangeCheckValid}"
也许因为它需要一个参数,所以如何通过它? 有什么想法?。
非常感谢提前。
例外:
javax.servlet.ServletException: /ajoutProfile.jspx @57,21 <f:ajax> Tag Library supports namespace: http://java.sun.com/jsf/core, but no tag was defined for name: ajax
javax.faces.webapp.FacesServlet.service(FacesServlet.java:321)
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
com.sun.facelets.tag.TagException: /ajoutProfile.jspx @57,21 <f:ajax> Tag Library supports namespace: http://java.sun.com/jsf/core, but no tag was defined for name: ajax
com.sun.facelets.compiler.CompilationManager.pushTag(CompilationManager.java:193)
com.sun.facelets.compiler.SAXCompiler$CompilationHandler.startElement(SAXCompiler.java:194)
org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
org.apache.xerces.impl.dtd.XMLDTDValidator.emptyElement(Unknown Source)
org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
javax.xml.parsers.SAXParser.parse(Unknown Source)
com.sun.facelets.compiler.SAXCompiler.doCompile(SAXCompiler.java:232)
com.sun.facelets.compiler.Compiler.compile(Compiler.java:105)
com.sun.facelets.impl.DefaultFaceletFactory.createFacelet(DefaultFaceletFactory.java:218)
com.sun.facelets.impl.DefaultFaceletFactory.getFacelet(DefaultFaceletFactory.java:149)
com.sun.facelets.impl.DefaultFaceletFactory.getFacelet(DefaultFaceletFactory.java:100)
com.sun.facelets.FaceletViewHandler.buildView(FaceletViewHandler.java:517)
com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:567)
org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:117)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:135)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:309)
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
com.planetj.servlet.filter.compression.CompressingFilter.doFilter(CompressingFilter.java:271)
答案 0 :(得分:5)
<f:ajax>
在JSF 2.0中引入。您的问题症状表明您正在使用缺少<f:ajax>
标记的JSF 1.x.至少,堆栈跟踪中com.sun.facelets.*
类的存在确认您正在使用Facelets 1.x,这反过来证实您正在使用JSF 1.x.也就是说,在JSF 2.x中,Facelets类已移至com.sun.faces.facelets.*
,此处有一些类重构(例如FaceletViewHandler
不再存在)。
堆栈跟踪还确认您已安装Ajax4JSF。在这种情况下,只需使用<a4j:ajax>
代替<f:ajax>
即可根据您找到的答案解决问题。