JSF: ResourceHandler logs missing component xhtml for non-composite component - jsf

we have following taglib:
<facelet-taglib version="2.0" 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_0.xsd">
<namespace>http://www.example.com/mytaglib</namespace>
<composite-library-name>common</composite-library-name>
<tag>
<tag-name>selectOneRadio</tag-name>
<component>
<component-type>psa.selectOneRadio</component-type>
<renderer-type>psa.selectOneRadioRenderer</renderer-type>
</component>
<attribute>
<name>styleClass</name>
<type>java.lang.String</type>
</attribute>
<attribute>
<name>itemStyleClass</name>
<type>java.lang.String</type>
</attribute>
</tag>
The tag lib combines composite components in /resources/common (composite-library-name) and java written components.
It all works fine, but when using the selectOneRadio (java) component, we get the following error (but without a "real" error -> the selectOneRadio component also works fine):
08:31:31,202 ERROR [ResourceImpl:98] Resource handler [com.sun.faces.application.resource.ResourceHandlerImpl#1c22bcb0] was unable to create a resource for resourceName=[selectOneRadio.xhtml] libraryName=[common] contentType [application/xhtml+xml]
Its clear, because the selectOneRadio component is a java written component, the selectOneRadio.xhtml does not exist.
Thanks
Dirk

Related

JSF1064 when using tags defined in the taglib.xml

I've created my own custom myfw:repeat tag for our project as described in JSF ui:repeat in ui:repeat with dynamically assigned var-value and defined it in the myfw.taglib.xml:
<?xml version="1.0"?>
<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_0.xsd"
version="2.0" id="myfw">
<namespace>http://company.at/myfw</namespace>
<composite-library-name>myfw</composite-library-name>
<!-- Other tags -->
<tag>
<tag-name>repeat</tag-name>
<component>
<component-type>at.company.myfw.jsf.component.repeat.UIRepeatForFloatingTable</component-type>
</component>
</tag>
</facelet-taglib>
The tag used in the page is working fine but every time the page is viewed the warning message:
13:03:30,577 WARNING [javax.enterprise.resource.webcontainer.jsf.application] (http-/127.0.0.1:8080-2) JSF1064: Unable to find or serve resource, repeat.xhtml, from library, myfw.
shows up in the logs. This is not just the case with the repeat tag, it also happens to every tag defined in the taglib like ui:compositions. So the log is currently spammed by these messages but the page/tags work properly. A current workaround is to change the log-level, but it is not the desired solution. Using EAP 6.2.0.GA with Mojarra 2.1.19.
This is a bug in Mojarra. It's during Development stage too eagerly logging JSF1064 for tagfiles which couldn't be found in <composite-library-name>, while it should still continue to work through <tag> entries registered directly in taglib itself.
This is not your fault. Those warnings aren't logged in Production stage. I reported this issue as JAVASERVERFACES-3696 (update: this was fixed only a few hours later and will be available as per Mojarra 2.3.0-M02).

JSF: Use component with changed Renderer with other Namespace

I wrote an new renderer for a primefaces component, now i want to make have this "new" component available under a new namespace:
I created a new taglib for that:
<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_0.xsd"
version="2.0">
<namespace>http://www.whitebyte.com/commentbox</namespace>
<tag>
<tag-name>tree</tag-name>
<component>
<component-type>org.primefaces.component.Tree</component-type>
<renderer-type>commentbox.CustomTreeRenderer</renderer-type>
</component>
<attribute>
<description><![CDATA[Unique identifier of the component in a namingContainer.]]></description>
<name>id</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Boolean value to specify the rendering of the component, when set to false component will not be rendered.]]></description>
<name>rendered</name>
<required>false</required>
<type>java.lang.Boolean</type>
</attribute>
<attribute>
<description><![CDATA[An el expression referring to a server side UIComponent instance in a backing bean.]]></description>
<name>binding</name>
<required>false</required>
<type>javax.faces.component.UIComponent</type>
</attribute>
<attribute>
<description><![CDATA[Name of the client side widget.]]></description>
<name>widgetVar</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[A TreeNode instance as the backing model.]]></description>
<name>value</name>
<required>false</required>
<type>java.lang.Object</type>
</attribute>
<attribute>
<description><![CDATA[Name of the request-scoped variable that'll be used to refer each treenode data during rendering.]]></description>
<name>var</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Specifies the ajax/client toggleMode. Default is false.]]></description>
<name>dynamic</name>
<required>false</required>
<type>java.lang.Boolean</type>
</attribute>
<attribute>
<description><![CDATA[Specifies caching on dynamically loaded nodes. When set to true expanded nodes will be kept in memory. Default is true.]]></description>
<name>cache</name>
<required>false</required>
<type>java.lang.Boolean</type>
</attribute>
<attribute>
<description><![CDATA[Javascript event to process when a tree node is clicked.]]></description>
<name>onNodeClick</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[TreeNode array to reference the selections.]]></description>
<name>selection</name>
<required>false</required>
<type>java.lang.Object</type>
</attribute>
<attribute>
<description><![CDATA[Style of the main container element of tree.]]></description>
<name>style</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Style class of the main container element of tree.]]></description>
<name>styleClass</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Defines the selectionMode.]]></description>
<name>selectionMode</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Highlights nodes on hover when selection is enabled, set to false to disable highlighting.]]></description>
<name>highlight</name>
<required>false</required>
<type>java.lang.Boolean</type>
</attribute>
<attribute>
<description><![CDATA[Unique key of the data presented by tree nodes.]]></description>
<name>datakey</name>
<required>false</required>
<type>java.lang.Object</type>
</attribute>
<attribute>
<description><![CDATA[When enabled, Displays slide effect during toggling of a node.]]></description>
<name>animate</name>
<required>false</required>
<type>java.lang.Boolean</type>
</attribute>
</tag>
I added the render in faces-config.xml too:
<render-kit>
<renderer>
<component-family>org.primefaces.component</component-family>
<renderer-type>commentbox.CustomTreeRenderer</renderer-type>
<renderer-class>commentbox.CustomTreeRenderer</renderer-class>
</renderer>
</render-kit>
The new component is also seen in eclipse but when i open the page in the browser i get:
javax.faces.FacesException: Cannot find component with identifier "tree" referenced from "j_idt62:j_idt76".
at org.primefaces.util.ComponentUtils.findClientIds(ComponentUtils.java:273)
at org.primefaces.util.AjaxRequestBuilder.addIds(AjaxRequestBuilder.java:102)
at org.primefaces.util.AjaxRequestBuilder.update(AjaxRequestBuilder.java:90)
at org.primefaces.renderkit.CoreRenderer.buildAjaxRequest(CoreRenderer.java:196)
at org.primefaces.component.commandbutton.CommandButtonRenderer.encodeMarkup(CommandButtonRenderer.java:74)
at org.primefaces.component.commandbutton.CommandButtonRenderer.encodeEnd(CommandButtonRenderer.java:49)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:59)
at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:43)
at org.primefaces.component.outputpanel.OutputPanelRenderer.encodeEnd(OutputPanelRenderer.java:46)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:59)
at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:43)
at org.primefaces.component.outputpanel.OutputPanelRenderer.encodeEnd(OutputPanelRenderer.java:46)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:312)
at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:105)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
at com.sun.faces.renderkit.html_basic.CompositeRenderer.encodeChildren(CompositeRenderer.java:78)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
The solution was to create the "whole" component and register that in the taglib like described here:
https://stackoverflow.com/a/10569044/441907
(I didn't register the taglib just put it into META-INF in classes that worked).

ValueChangeListener on custom component leads to PropertyNotFoundException

We have a custom JSF component that renders some buttons and a select box in a specific way. This is done by a class that extends UIInput. This custom component used in the xhtml templates like so:
<xx:fooComponent
value="#{fooBean.someProperty}"
valueChangeListener="#{fooBean.someMethodInBean}"
someOtherProperties="true" />
Now since we changed from JBoss 4.2.2 running JSF 2.0 to JBoss 7.1.1 running with the built-in JSF libs, it complains about someMethodInBean not being a property. Of course it's not a property, it's a method. Who in the world would bind a property to a valueChangeListener?
At first I thought, this had something to do with the method being in a superclass of the referenced bean, but that wasn't the case. Adding this particular method to FooBean did not make any difference.
So my question is, what did they change so that this breaks now and how can I fix it in a migrating-friendly way?
edit
The component is declared as such in our *.taglib.xml:
<!DOCTYPE facelet-taglib PUBLIC
"-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"
"http://java.sun.com/dtd/facelet-taglib_1_0.dtd">
<!-- ... -->
<tag>
<tag-name>fooComponent</tag-name>
<component>
<component-type>myProject.FooComponent</component-type>
</component>
</tag>
... which leads to this declaration in faces-config.xml:
<component>
<component-type>myProject.FooComponent</component-type>
<component-class>com.myproject.somemore.UIFooComponent</component-class>
</component>
... which leads to the class UIFooComponent extends UIInput.
edit 2
Now the taglib xml looks like this:
<facelet-taglib version="2.0"
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_0.xsd">
<tag>
<tag-name>fooComponent</tag-name>
<component>
<component-type>myProject.FooComponent</component-type>
</component>
<attribute>
<name>valueChangeListener</name>
<method-signature>void valueChanged(javax.faces.event.ValueChangeEvent)</method-signature>
</attribute>
</tag>
</facelet-taglib>
Still, he complains about fooBean not having the property someMethodInBean.
edit 3
The stack trace is:
Caused by: javax.el.ELException: /abc/abc.xhtml: The class 'com.myproject.managedbeans.foo.FooBean' does not have the property 'someMethodInBean'.
at com.sun.faces.facelets.compiler.AttributeInstruction.write(AttributeInstruction.java:94)
at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:302)
at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:185)
at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:129)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:125)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
at org.apache.myfaces.tomahawk.application.ResourceViewHandlerWrapper.renderView(ResourceViewHandlerWrapper.java:93)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
... 21 more
This indicates that the tag attribute isn't been declared as a <method-signature> in the component's <tag> declaration in the .taglib.xml file as follows:
<attribute>
<name>valueChangeListener</name>
<method-signature>void valueChange(javax.faces.event.ValueChangeEvent)</method-signature>
</attribute>
Make sure that this is properly been declared as above.
Update: you need to make sure that you've declared the .taglib.xml file conform JSF 2.x Facelets XSD (and thus not a DTD as it was in legacy Facelets 1.x).
<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_0.xsd"
version="2.0"
>
<!-- Tags here -->
</facelet-taglib>

JSF define custom namespace for component declaration

when you use a component from extarnal libraries (or custom component) in JSF page you add the xmlns declaration, for example:
xmlns:util="http://java.sun.com/jsf/composite/component/util
I would like to know what I have to do to use a private address in the Namaspace like this below:
xmlns:p="http://primefaces.prime.com.tr/ui"
It is something related to packages? Or it depends from the name of the .JAR that contains the components?
Thank you!
For Facelets this is definied in .taglib.xml file. In case of PrimeFaces it's /META-INF/primefaces-p.taglib.xml:
<?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_0.xsd"
version="2.0">
<namespace>http://primefaces.prime.com.tr/ui</namespace>
...
Note the <namespace>. For JSP this is definied in the .tld file, for PrimeFaces it's the /META-INF/primefaces-p.tld
<?xml version="1.0" encoding="UTF-8"?>
<taglib xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.1">
<tlib-version>1.2</tlib-version>
<short-name>p</short-name>
<uri>http://primefaces.prime.com.tr/ui</uri>
...
Note the <uri>.

Custom Facelets components and attributes defined in taglib

Defining custom components in Facelets is easy and quick but there's one thing I can't figure out.
Is it possible with Facelets to define what attributes my custom component has? I.e: I've created a component which is used in such a way:
<blue:modalWindow id="editFeesWizard" width="500" height="440" title="Wizard">
and is defined in taglib.xml as follows:
<!DOCTYPE facelet-taglib PUBLIC
"-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"
"http://java.sun.com/dtd/facelet-taglib_1_0.dtd">
<facelet-taglib>
<namespace>...</namespace>
<tag>
<tag-name>modalWindow</tag-name>
<source>components/modalWindow.xhtml</source>
</tag>
</facelet-taglib>
Taglib doesn't contain any information on component's attributes (id, width, height, title) and IDE cannot therefore check my syntax nor can it suggest attributes while I'm typing.
I cannot find anything on this subject in Facelets documentation. Thought you could help. Thanks!
It seems there isn't a way. But even if there was, I don't think Eclipse (for example) would be able to handle it and offer autocomplete. That's why you can define a .tld, containing the attributes:
<?xml version="1.0" encoding="utf-8"?>
<taglib
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.1">
......
</taglib>
Just for the sake of autocompletion. Ugly, I know.
I don't know about before, but it is possible now. Just add:
<tag>
<tag-name>mycustomtag</tag-name>
<source>tags/mycustomtag.xhtml</source>
<attribute>
<description>What does this do?!</description>
<name>attribute</name>
</attribute>
</tag>
I'm looking forward to being able to create composite components using JSF 2 and facelets; from what I've read, it seems very quick and easy, and you define what attributes your composite component accepts.

Resources