Bonjour,
Je tente de créer un composant JSF (pour le moment très proche d'un Hello World), mais cela ne fonctionne pas. Je dois donc oublier une étape importante.
Je créer un jar avec mon composant :
- un fichier tld dans META-INF
<taglib>
<tlib-version>1.0</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>itframework</short-name>
<uri>http://www.mycompany.fr/jsf</uri>
<tag>
<name>ticker</name>
<tag-class>fr.mycompany.TickerTag</tag-class>
</tag>
</taglib>- un fichier faces-config.xml dans META-INF
<?xml version="1.0" encoding="UTF-8"?>
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
xmlnssi="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"
version="1.2">
<component>
<component-type>ticker</component-type>
<component-class>fr.mycompany.UITicker</component-class>
</component>
</faces-config>- TickerTag
public class TickerTag extends UIComponentELTag {
@Override
public String getComponentType() {
return "ticker";
}
}- UITicker : public class UITicker extends UIOutput
Donc à priori, j'ai bien le fichier tld pour définir de nouveaux tags. Ma class TickerTag qui, avec la méthode getComponentType renvoit la même valeur que celle définie dans le fichier faces-config.xml. Ceci doit me permettre de faire le lien avec la classe UITicker
Dans mon war, je défini une portlet, et dans le fichier form.xhtml, j'ai ceci :
- Import de la taglib
<ui:composition 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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:itf="http://www.mycompany.fr/jsf">- Utilisation du tag
<itf:ticker>
<f:verbatim>Hello JSF Component</f:verbatim>
</itf:ticker>
Et, je n'ai aucune erreur, le tag n'est pas remplacé lors de la création de la page. Je suppose que mon fichier tld n'est pas pris en compte, mais je ne vois pas ce qui manque.
Quelqu'un pourrait-il m'indiquer ce qu'il manque ?
Merci,
Partager