Bonjour,
J’essaie de migrer une application entre les deux versions cité plus haut.
Je rencontre un problème mais je ne trouve pas de solution sur google.
La partie qui ne marche pas est un chargement de tag via code java.
Dépendance maven + implémentation identique sur mon serveur (Tomcat 7) :
Web.xml :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 <dependency> <groupId>com.sun.faces</groupId> <artifactId>jsf-api</artifactId> <version>${jsf.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.sun.faces</groupId> <artifactId>jsf-impl</artifactId> <version>${jsf.version}</version> <scope>provided</scope> </dependency>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 <context-param> <param-name>javax.faces.FACELETS_LIBRARIES</param-name> <param-value>/META-INF/ndi.taglib.xml</param-value> </context-param>
La tag-lib :
La classe xCompositeLibrary :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 <?xml version="1.0" encoding="UTF-8"?> <facelet-taglib 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-facelettaglibrary_2_2.xsd" version="2.2"> <library-class>com.x.fwk.web.jsfutils.XCompositeLibrary</library-class> </facelet-taglib>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 public class XCompositeLibrary implements TagLibrary { ........ public XCompositeLibrary() { TagLibrary loJvsLibrary = new XLibrary(); // composite library TagLibrary loJvsCompositeLibrary = new CompositeComponentTagLibrary(this.NAMESPACE, "common/components"); mcLibraries = new TagLibrary[] {loJvsLibrary, loJvsCompositeLibrary}; LOG.info("Chargement XCompositeLibrary OK"')"); } .......... }
La classe XLibrary :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 public class XLibrary extends AbstractTagLibrary { publicXLibrary() { super(NAMESPACE); try { addComponent(.....); // handlers addTagHandler(...); // converters addConverter(....); // add the functions from JsfFunctions Method[] lcMethods = JsfFunctions.class.getMethods(); for (int lnI = 0; lnI < lcMethods.length; lnI++) { if (Modifier.isStatic(lcMethods[lnI].getModifiers())) { addFunction(lcMethods[lnI].getName(), lcMethods[lnI]); } } LOG.info("X components library successfully loaded"); } catch (Exception loE) { LOG.error("Problem during loading of Xcomponents library : " + loE, loE); } } }
Ceci permet ensuite d'utiliser des tag qui appel les fonctions de la classe "JsfFunctions".
Par exemple dans une page xhtml :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 <ui:composition .... xmlns:custom="http://java.sun.com/jsf/X"/> #{cc.attrs.showLabels == 'true' ? custom:concat('label: "', cc.getLabel(state), '",') : ''}
Ce bout de code fonctionne en 2.1.28 par contre j'ai le message d'erreur suivant en 2.2.x :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2javax.el.ELException: Function 'custom:concat' not found
Une piste ? des idées ?
Partager