1
I’m having problems creating custom components in JSF, it’s actually the first time.
I found some guides on the internet but it hasn’t worked.
Here’s what I did.
I created the custom.taglib.xml
inside the briefcase WEB-INF
and its content is this.
<?xml version="1.0" encoding="UTF-8"?>
<facelet-taglib>
<namespace>http://paradigma.ecred2/facelets</namespace>
<tag>
<tag-name>btnHelp</tag-name>
<source>tags\btn-help.xhtml</source>
</tag>
</facelet-taglib>
Inside the folder resources
, created the file btn-help.xhtml
with the following content.
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:cc="http://xmlns.jcp.org/jsf/composite"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui">
<cc:interface>
<cc:attribute name="hint" />
</cc:interface>
<cc:implementation>
<p>#{cc.attrs.hint}</p>
</cc:implementation>
</html>
And finally inside the page where I want to use this component, it follows the header.
<ui:composition template="/template/common/pagelayout.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:ez="http://xmlns.jcp.org/jsf/composite"
xmlns:sec="http://www.springframework.org/security/facelets/tags"
xmlns:ecred="http://paradigma.ecred2/facelets/tags">
And the call of the component
<ecred:btnHelp hint="Teste"/>
The problem is that the component is not being rendered, and I don’t know what might be going on. The idea is to make components that are simpler for example.
Make a help button that already loads a certain image and the developer just pass the text.
<p:graphicImage url="#{resource['images:help-icon.png']}" title="#{cc.attrs.hint}"/>
Thank you
Great @utluiz, all right? Guy I did here and now recognized when I used that statement
namespace
, but there is no way to put one as I want? And when you use thectrl
+space
it shows the attributes oftag
?– Macario1983
@Macario1983 When I did the implementation, the namespace statement just didn’t work. This is one of the reasons I’ve completely lost track of JSF. When to self-complacement, in my Eclipse works very well.
– utluiz
I have a
ebook
ofJSF
, and I have to read, but in the generate sectionJAR
, he uses thenamespace
own, perhaps for what it is used. As for theauto-completar
, it seems to me that the problem varies according to thenamespace
ofJSF
, using what you suggest in your answer works, but using the new ones fromJSF 2.2
did not give!– Macario1983