Product Logos BridgeIt Services Banner
Facelets and custom tag  XML
Forum Index -> General Help Go to Page: 1, 2 Next 
Author Message
Bjorn121

Joined: 28/Apr/2008 00:00:00
Messages: 22
Offline


I want to create a custom tag and include it in my project. So, declare an xhtml page with some content, make sure that it's included in another page and show it on the screen.

I've followed this tutorial, but that doesn't work. It's a great idea to explain something but not to include it in the examples that are available to download :).

The structure of my application is:
- private
- some_page.xhtml
-- private\common
-- private\common\tags\custom_tag.xhtml
- WEB-INF\app.tag.xml
- WEB-INF\web.xml

WEB-INF folder and private folder are on the same level (if that's not clear to you).

My app.tag.xml looks like this:
Code:
     <facelet-taglib>
         <namespace>http://somenamespace.com/taglib</namespace>
     </facelet-taglib>
     <tag>
         <tag-name>entryList</tag-name>
        <source>../private/common/tags/custom_tag.xhtml
     </tag>
 


Web.xml:
Code:
     <context-param>
         <param-name>facelets.LIBRARIES</param-name>
         <param-value>/app.tag.xml</param-value>
     </context-param>
 


Web page
Code:
     <div xmlns:ft="http://somenamespace.com/taglib">
         <ft:entryList />
     </div>
 


Custom tag
Code:
     <div xmlns:ice="http://www.icesoft.com/icefaces/components">
         <ice:outputText value="TESTING" />
     </div>
 


Does anyone know what I'm doing wrong? I nearly tried everything, with no results thus far.
georges.goebel@pch.etat.l


Joined: 23/Jun/2007 00:00:00
Messages: 276
Offline


Hi,

I have a very small example of a spinner component.
It's quite simple, you need to implement a UIComponent and a renderer and there you go.

http://jira.icefaces.org/browse/ICE-1786
http://jira.icefaces.org/secure/attachment/10995/customIcefaces.zip


Georges Goebel
[Email]
Adamax

Joined: 19/Sep/2007 00:00:00
Messages: 27
Offline


Try this:
app.tag.xml:
Code:
     <facelet-taglib>
         <namespace>http://somenamespace.com/taglib</namespace>
     </facelet-taglib>
     <tag>
         <tag-name>entryList</tag-name>
        <source>/private/common/tags/custom_tag.xhtml</source>
     </tag>
 


Web.xml:
Code:
     <context-param>
         <param-name>facelets.LIBRARIES</param-name>
         <param-value>/WEB-INF/app.tag.xml</param-value>
     </context-param>
 


georges.goebel@pch.etat.l


Joined: 23/Jun/2007 00:00:00
Messages: 276
Offline


Hi again,

I have 3 configuration and definition files in WEB-INF/ and the faces config file is declared in javax.faces.CONFIG_FILES in web.xml
Check these files out and I hope your lucky

Georges
[Email]
Bjorn121

Joined: 28/Apr/2008 00:00:00
Messages: 22
Offline


The problem is that I don't want to create my own component, with java code and other stuff. I just want to include a page, to which I can pass some variables. I already used this method in another web application and that worked fine. We didn't use IceFaces tho, but I think it's weird that this method is limited.

edit>
You guys are too fast :). This reply was after George's first reply. Going to try the other suggestions now.
Bjorn121

Joined: 28/Apr/2008 00:00:00
Messages: 22
Offline


Solution of Adamax doesn't work unfortunately.

George, like I said, I don't want to write the component in Java or have some backing actions performed by a Pojo. I just want to include an xhtml file which contains some fields. I can't use a simple include, since I want to pass parameters to the tag.
georges.goebel@pch.etat.l


Joined: 23/Jun/2007 00:00:00
Messages: 276
Offline


Hi,

You don't know what fun you miss when not creating your own custom components written in Java

I tried the example and it works fine for me.

I attached the files (but I am only allowed to attach 2 files :-( )

In web.xml, I had to add

Code:
 <context-param>
         <param-name>facelets.LIBRARIES</param-name>
         <param-value>/WEB-INF/bubu_tag.xml</param-value>
     </context-param>
 
 Filename bubu.xhtml [Disk] Download
 Description the facelet page
 Filesize 1 Kbytes
 Downloaded:  424 time(s)

 Filename test.tar.gz [Disk] Download
 Description the taglib config files
 Filesize 488 bytes
 Downloaded:  397 time(s)

[Email]
Bjorn121

Joined: 28/Apr/2008 00:00:00
Messages: 22
Offline


Yeah it may be fun, but I don't have the time to do this and I really don't see the need in creating the components I need this way. I think it's quite stupid that IceFaces doesn't support this type of including files, since it's very handy and also a quick trick to avoid losing time to code almost everything in Java.

I'll try to find another solution, but I don't see why it's explained in the developers guide, but doesn't work at all.
Adamax

Joined: 19/Sep/2007 00:00:00
Messages: 27
Offline


Try putting your custom_tag.xhtml under WEB-INF directory
Bjorn121

Joined: 28/Apr/2008 00:00:00
Messages: 22
Offline


Weird behaviour. I managed to make it work, more or less. My xhtml looks as follows:

Code:
 <ui:composition xmlns="http://www.w3.org/1999"
                         xmlns:ui="http://java.sun.com/jsf/facelets"
                         xmlns:c="http://java.sun.com/jstl/core"
                         xmlns:ice="http://www.icesoft.com/icefaces/component"
                         xmlns:ft="http://mycustomtaglibns"
                         template="/private/common/layout.xhtml">
     <ui:define name="horizon_nav">
         <ui:include src="SOURCE" />
     </ui:define>
 
     <ui:define name="canvas">
         <ui:decorate template="/templatefile">
             <ui:define name="content">
                 
             </ui:define>
         </ui:decorate>
     </ui:define>
 </ui:composition>
 


Now, when I put <ft:entryList /> between <ui:define name="content">, it doesn't work. However, when I put this between <ui:define name="content">, it works:

Code:
     <div xmlns:ft="http://customtaglib">
         <ft:entryList />
     </div>
 


Does anyone know what the reason could be for this kind of behaviour?
Adamax

Joined: 19/Sep/2007 00:00:00
Messages: 27
Offline


What exactly doesn't work? What errors do you get? Post your layout.xhtml here
Bjorn121

Joined: 28/Apr/2008 00:00:00
Messages: 22
Offline


I don't get any errors. The tag simply isn't shown. I'll try to post the file here today, but I have no internet connection on my development machine for the moment :).
Adamax

Joined: 19/Sep/2007 00:00:00
Messages: 27
Offline


By the way, why do you have nested "ui:define" 's ?
It seems weird to me.
Also, you have different declarations
xmlns:ft="http://mycustomtaglibns" and xmlns:ft="http://customtaglib".
michelle2

Joined: 14/Nov/2007 00:00:00
Messages: 449
Offline


[Does anyone know what I'm doing wrong? I nearly tried everything, with no results thus far. 


Here's about the simplest example of a facelets tag I have, if you want something more complex pm me, if you want to do something way more complex like do direct to dom in a custom icefaces tag, we've written those too. but that would be way to long to post here as well as longer facelets examples.

This one should get you to a good start.
 Filename simpletag.rtf [Disk] Download
 Description
 Filesize 5 Kbytes
 Downloaded:  411 time(s)

[Email]
Bjorn121

Joined: 28/Apr/2008 00:00:00
Messages: 22
Offline


About the nested "ui:define"s, I don't know, my colleague came up with that :).

It seems like the problem is situated elsewhere. I now have a similar problem, but for spring-security. When I define the namespace and I want to use for instance the authorize-tag, the tag appears on my page in clear text, instead of being parsed. Does anyone know why this could be?

I really think it's odd, because we declare the core library in the same way, or the html library and these things work fine.

This is the code for our template (more or less):

Code:
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"
       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:c="http://java.sun.com/jstl/core"
       xmlns:ice="http://www.icesoft.com/icefaces/component">
 	<head>
 		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 		<title>APP_NAME</title>			
 		<ice:outputStyle href="../static/css/rime/rime.css"/>
 		<ice:outputStyle href="../static/css/styles.css"/>
 		<ice:outputStyle href="../static/css/always.css"/>
 		<ice:outputStyle href="../static/css/style_guide.css"/>			
 		<ice:outputStyle href="../static/css/modules.css"/>
 		<ice:outputStyle href="../static/css/APP_NAME.css"/>	
 		<!--[if lt IE 8]>
 			<ice:outputStyle href="../static/css/iestyles.css" />
 		<![endif]-->				
 	</head>
 	<body>
      
 	<!-- START: wrapper -->
 	<div id="wrapper">
 		<ice:form id="form">
                     <div id="header_bot" class="clearfix">
                         <ui:insert name="horiz_nav" />
                     </div>
                 </ice:form>
         </div>
 </html>
 


This is the code for our horizontal navigation:

Code:
 <div xmlns="http://www.w3.org/1999/xhtml"
 	xmlns:ui="http://java.sun.com/jsf/facelets"
 	xmlns:z="http://java.sun.com/jsf/html"
 	xmlns:f="http://java.sun.com/jsf/core"
 	xmlns:c="http://java.sun.com/jstl/core"
     xmlns:s="http://www.springframework.org/security/tags"
 	xmlns:ice="http://www.icesoft.com/icefaces/component">
     
     <div class="horiz_nav">
         <ul class="clearfix">
             <li><ice:commandLink action="dashboard">Home</ice:commandLink></li>
             <li><ice:commandLink action="xxx">ItemOne</ice:commandLink></li>	
         </ul>
     </div>
     
     <div>
         <s:authorize ifAnyGranted="ROLE_USER">TESTING</s:authorize>
     </div>
 </div>
 


When you open the page, <s:authorize ifAnyGranted="ROLE_USER">TESTING</s:authorize> appears on the page, instead of showing/not showing the word TESTING.

This is our web.xml:

Code:
 <?xml version="1.0" encoding="UTF-8"?>
 <web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
 	<display-name>NAME_APP</display-name>
     
     <filter>
         <filter-name>springSecurityFilterChain</filter-name>
         <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
     </filter>
     
     <filter-mapping>
         <filter-name>springSecurityFilterChain</filter-name>
         <url-pattern>/*</url-pattern>
     </filter-mapping>
     
 	<welcome-file-list>
 		<welcome-file>index.jsp</welcome-file>
 	</welcome-file-list>
     
     <!-- ##### Listeners #################### -->
 	<listener>
         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
     </listener>
 	
 	<!-- ##### Servlets #################### -->
 	<servlet>
 		<servlet-name>FacesServlet</servlet-name>
 		<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
 		<load-on-startup>1</load-on-startup>
 	</servlet>
 	
 	<servlet> 
 		<servlet-name>Persistent Faces Servlet</servlet-name> 
 		<servlet-class>com.icesoft.faces.webapp.xmlhttp.PersistentFacesServlet</servlet-class> 
 		<load-on-startup> 1 </load-on-startup> 
 	</servlet>
 	
 	<servlet> 
 		<servlet-name>Blocking Servlet</servlet-name> 
 		<servlet-class>com.icesoft.faces.webapp.xmlhttp.BlockingServlet</servlet-class> 
 		<load-on-startup> 1 </load-on-startup> 
 	</servlet>
 	
 	<!-- ##### Servlet Mappings #################### -->
 	<servlet-mapping>
 		<servlet-name>FacesServlet</servlet-name>
 		<url-pattern>*.faces</url-pattern>
 	</servlet-mapping>
 	
 	<servlet-mapping> 
 		<servlet-name>Persistent Faces Servlet</servlet-name> 
 		<url-pattern>*.faces</url-pattern>
 	</servlet-mapping>
 	
 	<servlet-mapping> 
 		<servlet-name>Persistent Faces Servlet</servlet-name> 
 		<url-pattern>*.iface</url-pattern>
 	</servlet-mapping>
 	
 	<servlet-mapping> 
 		<servlet-name>Persistent Faces Servlet</servlet-name> 
 		<url-pattern>/xmlhttp/*</url-pattern> 
 	</servlet-mapping>
  
 	<servlet-mapping> 
 		<servlet-name>Blocking Servlet</servlet-name> 
 		<url-pattern>/block/*</url-pattern> 
 	</servlet-mapping>  
 	 
    	<!-- ##### Context Parameters #################### -->
 	<context-param>
 		<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
 		<param-value>.xhtml</param-value>
 	</context-param>
     
 	<context-param>
 		<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
 		<param-value>server</param-value>
 	</context-param>
     
 	<context-param>
 		<param-name>contextConfigLocation</param-name>
 		<param-value>
             classpath:APP_NAME-webapp.xml
             /WEB-INF/applicationContext.xml
         </param-value>
 	</context-param>
     
 	<context-param>
 		<param-name>javax.faces.CONFIG_FILES</param-name>
 		<param-value>
 			/WEB-INF/faces.xml, 
 			/WEB-INF/faces-navigation.xml,
 			/WEB-INF/faces-beans.xml		
 		</param-value>
 	</context-param>
     
 	<context-param>
     	<param-name>facelets.SKIP_COMMENTS</param-name>
     	<param-value>true</param-value>
   	</context-param>	
 	
 	<context-param> 
 		<param-name>com.icesoft.faces.synchronousUpdate</param-name> 
 		<param-value>true</param-value> 
 	</context-param>
 	
 	<context-param>
 		<param-name>com.icesoft.faces.concurrentDOMViews</param-name>
 		<param-value>true</param-value>
 	</context-param>
 	
 	<context-param> 
 		<param-name>facelets.DEVELOPMENT</param-name> 
 		<param-value>false</param-value> 
 	</context-param>
 	
 	<context-param> 
 		<param-name>com.sun.faces.validateXml</param-name> 
 		<param-value>false</param-value> 
 	</context-param>
     
     <context-param>
         <param-name>facelets.LIBRARIES</param-name>
         <param-value>/WEB-INF/custom.taglib.xml</param-value>
     </context-param>
     
 	<!--	
 	http://www.icefaces.org/JForum/posts/list/3202.page
 	<context-param> 
 		<param-name>com.sun.faces.verifyObjects</param-name> 
 		<param-value>true</param-value> 
 	</context-param>
 	-->
  
 </web-app>
 
 


I already tried doing it the old fashioned way, by putting the TLD in the WEB-INF directory and add the taglib-descriptor to the web.xml, but with no result.

We have the same problem with Tomahawk btw, so I think this is related to the coöperation of ICEfaces and facelets.
 
Forum Index -> General Help Go to Page: 1, 2 Next 
Go to:   
Powered by JForum 2.1.7ice © JForum Team