2 Replies Latest reply on Apr 26, 2008 7:22 PM by T Rixom

    creating a custom function in faces-config

    T Rixom Newbie

      Hi All,


      I am trying to the following custom function to work.


      function in class AsList.java:


      package functions;
      ...
      public static List asList(Collection c) {
      ...
      }
      



      faces-config.xml:


      <?xml version='1.0' encoding='UTF-8'?>
      <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">
      ...
      
           <facelet-taglib>  
                <namespace>http://mycompany/jsf</namespace>
                <function>
                     <function-name>asList</function-name>
                     <function-class>
                     nl.wkm.orionglobe.web.entity.system.AsList
                     </function-class>
                     <function-signature>
                          java.util.List asList(java.util.Collection)
                     </function-signature>
                </function>
           </facelet-taglib>
      ...
      </faces-config>
      
      



      declaration in xhtml:


      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
           ...
           xmlns:tw="http://mycompany/jsf">
      



      call to function in xhtml:


      ...
      var="role" value="#{tw:asList(user.roles)}"
      ...
      



      but I keep getting this error:


      /system/UserList.include @125,64 value="#{tw:asList(user.roles)}" Function 'tw:asList' not found
      



      Any tips?


      Thanks,


      T.

        • 1. Re: creating a custom function in faces-config
          Tom Goring Apprentice

          For me nothing in faces-config.xml about the taglib....


          web.xml



             <!-- JSF -->
              <context-param>
                    <param-name>facelets.LIBRARIES</param-name>
                    <param-value>/WEB-INF/jnet-ui.taglib.xml</param-value>
               </context-param>
          




          jnet-ui.tablib.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>
              <namespace>http://jnet.ltd.uk/taglib</namespace>
              
                  <function-name>fieldMaxSize</function-name>
                  <function-class>jnet.faces.component.el.ELFunctions</function-class>
                  <function-signature>int fieldMaxSize(java.lang.String)</function-signature>
              </function>
          


          • 2. Re: creating a custom function in faces-config
            T Rixom Newbie

            Thanks! Works like a charm.


            Was using the faces-config incorrect?


            Regards,


            T.