0 Replies Latest reply on Aug 23, 2006 11:01 PM by cui benqiang

    about custom tags

    cui benqiang Newbie

      i try to add a custom tag by facelets:(down example code from https://facelets.dev.java.net/servlets/ProjectDocumentList?folderID=3635&expandFolder=3635&folderID=0)

      JsfCoreLibrary.java:
      package com.arcmind.jsfquickstart.tags;

      import com.sun.facelets.tag.AbstractTagLibrary;

      import java.lang.reflect.Method;
      import java.lang.reflect.Modifier;


      /**
      * JsfCoreLibrary is an example for IBM developerWorks (c).
      * @author Rick Hightower from ArcMind Inc. http://www.arc-mind.com
      */
      public final class JsfCoreLibrary extends AbstractTagLibrary {
      /** Namespace used to import this library in Facelets pages */
      public static final String NAMESPACE = "http://www.arc-mind.com/jsf/core";

      /** Current instance of library. */
      public static final JsfCoreLibrary INSTANCE = new JsfCoreLibrary();

      /**
      * Creates a new JstlCoreLibrary object.
      *
      */
      public JsfCoreLibrary() {
      super(NAMESPACE);

      this.addTagHandler("setValueBinding", SetValueBindingHandler.class);
      this.addTagHandler("isBoolean", IsBooleanHandler.class);
      this.addTagHandler("isText", IsTextHandler.class);
      this.addTagHandler("isDate", IsDateHandler.class);

      try {
      Method[] methods = JsfFunctions.class.getMethods();

      for (int i = 0; i < methods.length; i++) {
      if (Modifier.isStatic(methods.getModifiers())) {
      this.addFunction(methods
      .getName(), methods);
      }
      }
      } catch (Exception e) {
      throw new RuntimeException(e);
      }
      }
      }


      jsf-core.taglib.xml:
      <?xml version="1.0"?>

      <!DOCTYPE facelet-taglib PUBLIC
      "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"
      "facelet-taglib_1_0.dtd">

      <facelet-taglib>
      <library-class>
      com.arcmind.jsfquickstart.tags.JsfCoreLibrary
      </library-class>
      </facelet-taglib>


      i get this result:

      Error Loading Library: /WEB-INF/facelets/tags/jsf-core.taglib.xml
      java.io.IOException: Error parsing [jndi:/localhost/seam-booking/WEB-INF/facelets/tags/jsf-core.taglib.xml]:
      at com.sun.facelets.compiler.TagLibraryConfig.create(TagLibraryConfig.java:396)
      at com.sun.facelets.FaceletViewHandler.initializeCompiler(FaceletViewHandler.java:310)
      at com.sun.facelets.FaceletViewHandler.initialize(FaceletViewHandler.java:196)
      at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:503)
      at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:352)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:107)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:30)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
      at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
      at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      at java.lang.Thread.run(Thread.java:595)
      Caused by: org.xml.sax.SAXException: Error Handling [jndi:/localhost/seam-booking/WEB-INF/facelets/tags/jsf-core.taglib.xml@10,23] <library-class>
      at com.sun.facelets.compiler.TagLibraryConfig$LibraryHandler.endElement(TagLibraryConfig.java:258)
      at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
      at org.apache.xerces.impl.dtd.XMLDTDValidator.endNamespaceScope(Unknown Source)
      at org.apache.xerces.impl.dtd.XMLDTDValidator.handleEndElement(Unknown Source)
      at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(Unknown Source)
      at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
      at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
      at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
      at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
      at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
      at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
      at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
      at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
      at javax.xml.parsers.SAXParser.parse(Unknown Source)
      at javax.xml.parsers.SAXParser.parse(Unknown Source)
      at com.sun.facelets.compiler.TagLibraryConfig.create(TagLibraryConfig.java:393)
      ... 26 more
      Caused by: java.lang.Exception: com.arcmind.jsfquickstart.tags.JsfCoreLibrary must be an instance of com.sun.facelets.tag.TagLibrary
      at com.sun.facelets.compiler.TagLibraryConfig$LibraryHandler.createClass(TagLibraryConfig.java:280)
      at com.sun.facelets.compiler.TagLibraryConfig$LibraryHandler.processLibraryClass(TagLibraryConfig.java:326)
      at com.sun.facelets.compiler.TagLibraryConfig$LibraryHandler.endElement(TagLibraryConfig.java:166)
      ... 41 more
      2006-08-24 10:58:10,109 ERROR [STDERR] 2006-8-24 10:58:10 com.sun.facelets.compiler.TagLibraryConfig loadImplicit


      thanks!