1

I am using Eclipse / jsf to create my web application. I was trying to solve a problem like This

I included:

<!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">

My code:

<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>

What is missing?.

If Tag is impossible to be used in this case, please show me how to use valueChangeListener property because I already implemented a method:

    public void OnproCodeChangeCheckValid(ValueChangeEvent VChEvnt)
{
    if(!((String)VChEvnt.getNewValue()).equals(null)&&!((String)VChEvnt.getNewValue()).trim().isEmpty())
    {
    nwprofvalid=!estprofileexist((String)VChEvnt.getNewValue());
    }
}

But this method hasn't been invoked by simply saying:

valueChangeListener="#{myBean.OnproCodeChangeCheckValid}" 

Maybe because it needs a param, so how to passe it?. Any ideas?.

Many thanks in advance.

Exception:

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)
Community
  • 1
  • 1
TiyebM
  • 2,684
  • 3
  • 40
  • 66

1 Answers1

5

<f:ajax> was introduced in JSF 2.0. Your problem symptoms suggest that you're using JSF 1.x which lacks the <f:ajax> tag. At least, the presence of com.sun.facelets.* classes in the stack trace confirms that you're using Facelets 1.x which in turn confirms that you're using JSF 1.x. Namely, in JSF 2.x, the Facelets classes were moved to com.sun.faces.facelets.* with here and there some class refactoring (e.g. the FaceletViewHandler doesn't exist anymore).

The stack trace also confirms that you've Ajax4JSF installed. In that case, just use <a4j:ajax> instead of <f:ajax> to solve the problem based on the answer you found.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555