Skip to main content

EL in Composite Component taglib JSF2.0

8 replies [Last post]
alexoulew
Offline
Joined: 2010-12-29
Points: 0

Hi,

I'm trying to create a custom composite component taglib in my office but i get a strange issue with EL. It seems expressions as #{cc.attrs.[var] } are already resolve as empty.
I try to create my taglib in a jar. In my jar i have my files ordered as following:
|_ /
.....|_ META-INF
..........|_ compo.taglib.xml
..........|_ resources
...............|_ components
....................|_ hello.xhtml

compo.taglib.xml contains:

<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.example.com/jsf/compo</namespace>
<composite-library-name>compo</composite-library-name>
<tag>
<tag-name>hello</tag-name>
<source>./components/hello.xhtml</source>
</tag>
</facelet-taglib>

hello.xhtml contains:

<?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:composite="http://java.sun.com/jsf/composite">

<composite:interface name="hello" displayName="hello">
<composite:attribute name="name" required="true" type="String"/>
</composite:interface>

<composite:implementation >
hello #{cc.attrs.name}!
</composite:implementation>

</html>

My web project contains in WEB-INF lib my taglib as a jar, jsf-impl.jar and jsf-api.jar (from Mojarra) my page is simply that:

<?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:comp="http://www.example.com/jsf/compo" >
<body>
<comp:hello name="John"></comp:hello>
</body>
</html>

At rendering i see "hello !" but not "hello John!". Attributes values seems be lost somewhere.
I made something wrong? Or it's may a bug?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
csfreebird
Offline
Joined: 2008-07-14
Points: 0

I ran into the same problem.Who can help me?It's hard to find out one article that introduces how to develop a composite component with JSF2 and package it into a jar project.

csfreebird
Offline
Joined: 2008-07-14
Points: 0

I find a way to bypass this problem.Don't try to use our namespace for tags,just use the default namespace:
http://java.sun.com/jsf/composite/tag_folder_path

Actually,I encoutnered the same problem when developping the customized composite component in a web application.After deleting the taglib.xml file and use the default namespace,it works.

alexoulew
Offline
Joined: 2010-12-29
Points: 0

Hi,
Thanks for reply!
I try to troubleshoot issue with your advicebut it doesn't work for me. Deleting the taglib.xml makes jar not scanned by app server. I also tried to set the defaut namespace in taglib.xml but tag is still not reconized.
I repported the issue on Javasefaces 's tracker: http://java.net/jira/browse/JAVASERVERFACES-1903
You will see, i found different issue switch the "javax.faces.PROJECT_STAGE" value. In source code i found this code wich throw the exception. Class com.sun.faces.facelets.tag.composite.InterfaceHandler:
private void validateComponent(FacesContext context, UIComponent ccParent) throws TagException {
UIComponent cc = ccParent.getParent();
if (null == cc) {
String clientId = ccParent.getClientId(context);

throw new TagException(tag, MessageUtils.getExceptionMessageString(
MessageUtils.COMPONENT_NOT_FOUND_ERROR_MESSAGE_ID,
clientId + ".getParent()"));
}
[...]
}
I don't understand what really happened. The Exception message i get is "Component Not Found for identifier: j_id1.getParent()" but j_id1 is the UIViewRoot... I think it handles UIViewRoot but not composite:component tag.

I think it's really bad for JSF2 if any enterprise cannot create composite component taglib with custom namespace... As they done with java component implemention. I hope this issue will be correct quickly.

csfreebird
Offline
Joined: 2008-07-14
Points: 0

Hi,
I uploaded my project(one jar project) to http://java.net/jira/browse/JAVASERVERFACES-1903
My project is very simple,easy to understand.

alexoulew
Offline
Joined: 2010-12-29
Points: 0

Hi,
I looked what you do, but i cannot find any way to run a similar sample on tomcat 6.0.29.
I also saw this dependency in your pom.xml

<dependency>

<groupId>com.sun.facelets</groupId>

<artifactId>jsf-facelets</artifactId>

<version>1.1.14</version>

</dependency>

In my project i only use jsf-api and jsf-impl from mojarra in version 2.0.3.FCS. According to the JSF2.0 specification and all documentation i read, it doesn't require anything else. No more facelet jar are required.
Why do you add this dependency?

csfreebird
Offline
Joined: 2008-07-14
Points: 0

Maybe it is not required.You could remove it.If you have maven3 installed,you could recompile my project on your computer.
Did you try to use my jsfex jar in your web application running on tomcat 6?What happened?

alexoulew
Offline
Joined: 2010-12-29
Points: 0

Hi !

I'm sorry to take long time to reply but we're not able to run your project. So, we took few time in order to do it. They were no problem with the dependency.

In my office we study your sample. We concluded your sample run with the default namespace, packaging your sample with maven. We also discovered that packaging your project with our IDE (Rapid Application Developper) makes you sample unusable! EL were not resolve but we were performing another issue... So, we packaged it with an ant task. As with maven, the sample runs after.

We done the same scenario with my initial project. Package it with ant task and use the default namespace make my project to run well. We also tried to with a custom namespace but issue still appears.

I'll update the issue in javaserverfaces tracker with this information. I think now issue is something different: We're just not able to use a custom namespace. With custom namespace el are not resolved and symptoms are still the same.

csfreebird
Offline
Joined: 2008-07-14
Points: 0

Good news! I didn't use any IDE to develop my Java applications,just Emacs(JDEE) and some Linux command lines. :)