JSF 1.2 style facelets custom tags in JSF 2.0

Ahoy.
Using facelets with JSF 1.2, one could create a custom tag in an xhtml file along the lines of:
labelledInput.xhtml:
<ui:component>
    <h:outputLabel value="#{label}: ">
        <h:inputText value="#{value}"/>
    </h:outputLabel>
</ui:component>
...You could register it in faces-config.xml or somewhere and then use it with <custom:labeledInput label="Type Something: " value="#{bean.value}"/>.
Alternatively, one could use <ui:composition> instead of <ui:component> in which case the tag wouldn't be considered as a component.
I think it could possibly be done with composite components, but they're not quite the same, and their documentation is pretty limited (at least until some of the books come out this year).
I want to use these more as shortcuts to reduce code duplication rather than adding functionality and they seemed to work well in the past for this.
If they can't be used, is there a way of creating a composite component that doesn't act as a component?
In particular, I want to make a tag that contains two components:
- a label
- a panel group containing an input and a message for that input
Then I can add a bunch of these to a 2-column panel grid for a nicely formatted form. Doing it with composite components forces each tag to be a single component, which I don't want. Old-facelets <ui:composition> based tags would let me do this (I think.)

Hello,
You posted in the wrong forum. This one is dedicated to the Oracle Forms product.
Francois

Similar Messages

  • Custom tag for Marquee in JSF

    Hi,
    I am trying to develop a custom tag for Marquee in JSF, my usecase is to display a value from managed bean(Dynamically). please find the code below and guide me where i have made mistake
    regards
    Sandeep
    Component class:
    package customtags;
    import javax.el.ValueExpression;
    import javax.faces.component.UIComponentBase;
    import javax.faces.context.FacesContext;
    public class Marquee extends UIComponentBase {
         public static final String COMPONENT_TYPE = "marqueecomp";
         public static final String RENDERER_TYPE = "marqueeRenderer";
         private Object[] _state = null;
         private String value;
         public String getValue() {
              if (null != this.value) {
                   return this.value;
              ValueExpression _ve = getValueExpression("value");
              return (_ve != null) ? (String) _ve.getValue(getFacesContext()
                        .getELContext()) : null;
         public void setValue(String marquee) {
              this.value = marquee;
         public String getFamily() {
              // TODO Auto-generated method stub
              return COMPONENT_TYPE;
    //     public void encodeBegin(FacesContext context) throws IOException {
    //          ResponseWriter writer = context.getResponseWriter();
    //          writer.startElement("marquee", this);
    //          writer.write(getValue());
    //          writer.endElement("marquee");
         public void restoreState(FacesContext context, Object state) {
              this._state = (Object[]) _state;
              super.restoreState(_context, this._state[0]);
              value = (String) this._state[1];
         public Object saveState(FacesContext _context) {
              if (_state == null) {
                   _state = new Object[2];
              state[0] = super.saveState(context);
              _state[1] = value;
              return _state;
    Tag Class:
    package customtags;
    import javax.el.ValueExpression;
    import javax.faces.component.UIComponent;
    import javax.faces.webapp.UIComponentELTag;
    public class MarqueeTag extends UIComponentELTag {
         protected ValueExpression marquee;
         public String getComponentType() {
              // TODO Auto-generated method stub
              return Marquee.COMPONENT_TYPE;
         public String getRendererType() {
              // TODO Auto-generated method stub
              return Marquee.RENDERER_TYPE;
         * protected void setProperties(UIComponent component) {
         * super.setProperties(component); Marquee marqComp = (Marquee) component;
         * if (marquee != null) { marqComp.setValue(marquee); } }
         protected void setProperties(UIComponent component) {
              super.setProperties(component);
              Marquee marqComp = null;
              try {
                   marqComp = (Marquee) component;
              } catch (ClassCastException cce) {
                   throw new IllegalStateException(
                             "Component "
                                       + component.toString()
                                       + " not expected type. Expected: com.foo.Foo. Perhaps you're missing a tag?");
              if (marquee != null) {
                   //marqComp.setValueExpression("value", marquee);
                   marqComp.setValue("fsdfsdfsdfsdfsd");
         * @return the marquee
         public ValueExpression getMarquee() {
              return marquee;
         * @param marquee
         * the marquee to set
         public void setMarquee(ValueExpression marquee) {
              this.marquee = marquee;
    *.tld file*
    <?xml version="1.0" encoding="UTF-8"?>
    <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-jsptaglibrary_2_1.xsd"
         version="2.1">
         <tlib-version>1.0</tlib-version>
         <short-name>marqueecomp</short-name>
         <uri>http://tags.org/marquee</uri>
         <tag>
              <name>marqueeTag</name>
    <tag-class>customtags.MarqueeTag</tag-class>
    <body-content>empty</body-content>
    <attribute>
    <description><![CDATA[Your description here]]></description>
    <name>id</name>
    <required>false</required>
    <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
    <description><![CDATA[Your description here]]></description>
    <name>value</name>
    </attribute>
         </tag>
    </taglib>
    Renderer class:
    package customtags;
    import java.io.IOException;
    import javax.faces.component.UIComponent;
    import javax.faces.context.FacesContext;
    import javax.faces.context.ResponseWriter;
    import javax.faces.render.Renderer;
    public class MarqueeRenderer extends Renderer {
         public void encodeBegin(final FacesContext facesContext,
    final UIComponent component) throws IOException {
    super.encodeBegin(facesContext, component);
    final ResponseWriter writer = facesContext.getResponseWriter();
    writer.startElement("DIV", component);
    /*String styleClass =
    (String)attributes.get(Shuffler.STYLECLASS_ATTRIBUTE_KEY);
    writer.writeAttribute("class", styleClass, null);*/
    public void encodeEnd(final FacesContext facesContext,
    final UIComponent component) throws IOException {
    final ResponseWriter writer = facesContext.getResponseWriter();
    writer.endElement("DIV");
    in Faces-Config:
    <component>
              <display-name>marqueecomp</display-name>
              <component-type>marqueecomp</component-type>
              <component-class>customtags.Marquee</component-class>
              <component-extension>
    <renderer-type>marqueeRenderer</renderer-type>
    </component-extension>
         </component>
         <render-kit>
    <renderer>
    <component-family>marqueecomp</component-family>
    <renderer-type>marqueeRenderer</renderer-type>
    <renderer-class>customtags.MarqueeRenderer</renderer-class>
    </renderer>
    </render-kit>
    In class path --->marquee.taglib.xml
    <?xml version="1.0"?>
    <!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>http://tags.org/marquee</namespace>
    <tag>
    <tag-name>marqueeTag</tag-name>
    <component>
    <component-type>marqueecomp</component-type>
    <renderer-type>marqueeRenderer</renderer-type>
    </component>
    </tag>
    </facelet-taglib>
    *.xhtml file*
    <html 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" xml:lang="en" lang="en"
         xmlns:a4j="http://richfaces.org/a4j"
         xmlns:rich="http://richfaces.org/rich" xmlns:mycomp="http://tags.org/marquee">
    <head>
    <title>DEBTDOC Home Page</title>
    <meta http-equiv="keywords" content="enter,your,keywords,here" />
    <meta http-equiv="description"
         content="A short description of this page." />
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" type="text/css" href="../css/common.css"></link>
    <script language="javascript" src="../script/common.js"></script>
    </head>
    <body>
    <f:view>
    <mycomp:marqueeTag value="hello World"></mycomp:marqueeTag>

    There exist the JSTL SQL taglib, but I don't recommend this. It should only be used for quick development and testing. For database connectivity, rather create a data layer with DAO classes which you on its turn just plug in your business layer (with servlets).

  • JSF dynamic include and custom tag

    Anybody has experience to enclude custom tags between <f:verbatim> </f:verbatim> ? The custom code embeded this tags won't work, my code as below:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <%-- jsf:pagecode language="java" location="/JavaSource/pagecode/jsp/Server_request.java" --%><%-- /jsf:pagecode --%>
    <%@taglib uri="http://www.ibm.com/jsf/html_extended" prefix="hx"%>
    <%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
    <%@taglib uri="/WEB-INF/mytaglib.tld" prefix="first" %>
    <HTML>
    <HEAD>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
         pageEncoding="ISO-8859-1"%>
    <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <META name="GENERATOR" content="IBM Software Development Platform">
    <META http-equiv="Content-Style-Type" content="text/css">
    <LINK href="../theme/Master.css" rel="stylesheet"
         type="text/css">
    <TITLE>server_request.jsp</TITLE>
    <LINK rel="stylesheet" type="text/css" href="../theme/stylesheet.css"
         title="Style">
    </HEAD>
    <f:view>
         <BODY><hx:scriptCollector id="scriptCollector1">
         <P><hx:outputLinkEx styleClass="outputLinkEx" value="header"
                   id="linkEx1">
                   <h:outputText id="text1" styleClass="outputText" value="Header"></h:outputText>
              </hx:outputLinkEx><BR></P>
    <jsp:include page="server_req.jsp"/>
              <hx:outputLinkEx styleClass="outputLinkEx" value="Footer" id="linkEx2">
                   <h:outputText id="text2" styleClass="outputText" value="Footer"></h:outputText>
              </hx:outputLinkEx>
         </hx:scriptCollector></BODY>
    </f:view>
    </HTML>
    <%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@taglib uri="/WEB-INF/mytaglib.tld" prefix="first"%>
    <f:subview id="server_req">
    <f:verbatim>
    <first:hello/>
    </f:verbatim>
    </f:subview>

    I don't know if there is a solution to the problem you are having with JSP 1.1. If you look in the spec, it actually warns you that dynamic includes can not be done inside a body tag. The spec actually states that the included code shout write directly to the response and not to the BodyContent.
    I was excited to find out they had fixed this in JSP 1.2, but they seem to have foiled me again. If my tag calls PageContext.include(), the spec says that include must call the flush method, which causes BodyContent to throw an exception since flush is not a valid call.

  • How To create a custom tag in jsf

    I'm trying to create a custom tag in jsf.what should be the approach to create it.it would be better if somebody will explain me from the skretch.

    There's a decent tutorial here, Priyo:
    http://www.exadel.com/tutorial/jsf/HowToWriteYourOwnJSFComponents.pdf
    Hope it helps,
    Illu

  • Custom Tag output not being rendered in JSF

    Hello,
    I have the following for loop in a custom tag that I developed;
    out.println("<ul>");
    for (int i = 0; i < noOfDays; i++)
    //out.println("<li><h:commandLink value=\"" +DateHelper.addDays(dtToday, i)+ "\" action=\"#{BookingBean.showAvailability}\"/></li>");
    out.println("<li><a href=\"" +DateHelper.addDays(dtToday, i)+ "\">" DateHelper.addDays(dtToday, i) "</a></li>");
    out.println("</ul>");
    The issue I have is that the second line prints out fine whereas the first one (when uncommented) prints out the bullet points associated with a list but does not render the h:commandLink.
    Any thoughts would be great.
    Cheers,
    Rich

    Hi,
    You can not embade a JSF tag in your code as you did, try adding component as children to your custum tag
    see this code as exemple : [HTMLDataTable.java|http://www.docjar.com/html/api/org/apache/myfaces/component/html/ext/HtmlDataTable.java.html]

  • Integrating a legacy custom tag with facelets webapp

    Hi
    I have an external custom tag ( a handler that had extended javax.servlet.jsp.tagext.TagSupport ). I am trying to use that custom tag in my .xhtml file(mine is facelets webapp). Please see the xhtml content below
    <html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:tGrid="http://java.pershing.com/tGrid">
    <tGrid:gridFields viewname="view1" isDefault="true" fields="Symbol,Quantity,Security Description,Account Type"/>
    </html>
    The problem here, the tag handler class is not getting invoked, i do not get the HTML content from it.
    I understand like we need to add 'taglib.xml' file as below, and register as config files in servlet context param.
    <tag>
    <tag-name>gridFields </tag-name>
    <handler-class>
    xyz.Grid
    </handler-class>
    </tag>
    I have collected the attributes and kept as TagAttribute in Grid handler class..
    But how could i invoke the custom handler class that had implemented TagSupport and start its own life cycle.
    Please help me out.
    Thanks
    -vijay

    Okay. so we cannot use any legacy custom tags and we need to duplicate the code into a new facelets handler class and add into tablig.xml file. is my understanding correct.?
    By the way, JSTL tags like <c:out> <c:if> are being identified by facelets view handler. How this cud have been supported by it?
    Thanks
    -vijay

  • JSF custom tag body content problem

    Hi, I'm having some problem with a custom tag I built, but the body of the tag content is not rendered correctly.
    I have:<foo:bar>
        <ul>
            <li>blah</li>
            <li>blah</li>
        </ul>
    </foo:bar>
    </pre>But the rendered html source look like this:    <ul>
            <li>blah</li>
            <li>blah</li>
        </ul>
    <!-- beging foo tag -->
    <!-- end foo tag -->The <ul> tags are supposed to be inside of the <!-- begin foo --> & <!-- end foo -->. I've declared in TLD it has JSP content. I've compared to the J2EE tutorial and corejsp book again and again, couldn't figure where I went wrong. So, am I missing something?
    Thanks a lot.

    Use <f:verbatim> around the non-jsf content.
    I.e.<foo:bar>
    <f:verbatim>
        <ul>
            <li>blah</li>
            <li>blah</li>
        </ul>
    </f:verbatim>
    </foo:bar>--
    Sergey : jsfTutorials.net

  • Can I write Design-time for JSP custom tag(not JSF components)

    I have some old JSP custom tags(not JSF components), and I want to use them in the IDE through the toolbox.
    Now I have already written the BeanInfos for these tags, and they can be drag from the toolbox; but it will throw a Exception when render the tags, and the properties in the Property Editor are not which I describe in the BeanInfos.
    How can I write Design-time for these tags? or whether it is possible to write the Design-time for these tags?
    the Exception is shown as follow:
    java.lang.ClassCastException
         at com.sun.rave.insync.faces.FacesPageUnit.renderNode(FacesPageUnit.java:1347)
    [catch] at com.sun.rave.insync.faces.FacesPageUnit.renderBean(FacesPageUnit.java:1086)
         at com.sun.rave.insync.faces.FacesPageUnit.getFacesRenderTree(FacesPageUnit.java:993)
         at com.sun.rave.css2.FacesSupport.getFacesHtml(FacesSupport.java:152)
         at com.sun.rave.css2.CssContainerBox.addNode(CssContainerBox.java:373)
         at com.sun.rave.css2.CssContainerBox.createChildren(CssContainerBox.java:354)
         at com.sun.rave.css2.DocumentBox.createChildren(DocumentBox.java:90)
         at com.sun.rave.css2.DocumentBox.relayout(DocumentBox.java:160)
         at com.sun.rave.css2.PageBox.layout(PageBox.java:392)
         at com.sun.rave.css2.PageBox.relayout(PageBox.java:454)
         at com.sun.rave.css2.DocumentBox.redoLayout(DocumentBox.java:313)
         at com.sun.rave.css2.PageBox.redoLayout(PageBox.java:460)
         at com.sun.rave.css2.DocumentBox.changed(DocumentBox.java:634)
         at com.sun.rave.designer.DesignerPaneUI$UpdateHandler.changedUpdate(DesignerPaneUI.java:1012)
         at com.sun.rave.text.Document.fireChangedUpdate(Document.java:851)
         at com.sun.rave.text.Document$5.run(Document.java:631)
         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)

    I have some old JSP custom tags(not JSF components), and I want to use them in the IDE through the toolbox.
    Now I have already written the BeanInfos for these tags, and they can be drag from the toolbox; but it will throw a Exception when render the tags, and the properties in the Property Editor are not which I describe in the BeanInfos.
    How can I write Design-time for these tags? or whether it is possible to write the Design-time for these tags?
    the Exception is shown as follow:
    java.lang.ClassCastException
         at com.sun.rave.insync.faces.FacesPageUnit.renderNode(FacesPageUnit.java:1347)
    [catch] at com.sun.rave.insync.faces.FacesPageUnit.renderBean(FacesPageUnit.java:1086)
         at com.sun.rave.insync.faces.FacesPageUnit.getFacesRenderTree(FacesPageUnit.java:993)
         at com.sun.rave.css2.FacesSupport.getFacesHtml(FacesSupport.java:152)
         at com.sun.rave.css2.CssContainerBox.addNode(CssContainerBox.java:373)
         at com.sun.rave.css2.CssContainerBox.createChildren(CssContainerBox.java:354)
         at com.sun.rave.css2.DocumentBox.createChildren(DocumentBox.java:90)
         at com.sun.rave.css2.DocumentBox.relayout(DocumentBox.java:160)
         at com.sun.rave.css2.PageBox.layout(PageBox.java:392)
         at com.sun.rave.css2.PageBox.relayout(PageBox.java:454)
         at com.sun.rave.css2.DocumentBox.redoLayout(DocumentBox.java:313)
         at com.sun.rave.css2.PageBox.redoLayout(PageBox.java:460)
         at com.sun.rave.css2.DocumentBox.changed(DocumentBox.java:634)
         at com.sun.rave.designer.DesignerPaneUI$UpdateHandler.changedUpdate(DesignerPaneUI.java:1012)
         at com.sun.rave.text.Document.fireChangedUpdate(Document.java:851)
         at com.sun.rave.text.Document$5.run(Document.java:631)
         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)

  • How to create a new custom tag in JSF 1.2

    Hi there,
    In JSF 1.2, all the classes (CommandButtonTag, CommandLinkTag, DataTableTag,...) in package com.sun.faces.taglib.html_basic are defined as final class. In JSF 1.1, we can create a custom tag that extends the tag in JSF taglib; it save us lots of time.
    Could anybody know how to create a new custom tag in JSF 1.2?
    Many thanks,
    Emily

    If I recall, it was done because how tags were to be handled in 1.2 was very different from 1.1 and it was felt that developers shouldn't rely on implementation specific classes (unless they were SPI) for several other reasons (application portability being the big one here).
    If it's felt that this was the wrong decision, please feel free to log an issue [1] against the RI (to date, no one has).
    As to the 'borked' dependency URLs, please log an issue [1] if you find these. We have nightly builds going that work from a clean workspace and checking today's result, it seems ok.
    [1] https://javaserverfaces.dev.java.net/issues

  • Tiles + JSF error (Illegal to flush within a custom tag)

    Hi,
    When I try to use Tiles + JSF I have this error message :
    javax.servlet.jsp.JspException: Illegal to flush within a custom tag
    I am already using flush="false" on my tiles:insert tag.
    This is my .jsp code :
    <%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
    <tiles:insert beanName="cadastro_base" beanScope="request" flush="false">
    <tiles:put name="form_body" type="string">
    <f:view>
    <h:form id="DisciplinaJsfBean" binding="#{DisciplinaJsfBean.form}" >
    <h:inputText id="codigo" binding="#{DisciplinaJsfBean.itCodigo}"/>
    </h:form>
    </f:view>
    </tiles:put>
    </tiles:insert>
    And this is the stack trace message :
    exception
    javax.servlet.ServletException: Illegal to flush within a custom tag
         org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
         org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
         org.apache.jsp.security.disciplina.cadastrarDisciplinas_jsp._jspService(cadastrarDisciplinas_jsp.java:99)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
         com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
         com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
         com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
         com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
         com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
    root cause
    javax.servlet.jsp.JspException: Illegal to flush within a custom tag
         com.sun.faces.taglib.jsf_core.ViewTag.doEndTag(ViewTag.java:223)
         org.apache.jsp.security.disciplina.cadastrarDisciplinas_jsp._jspx_meth_f_view_0(cadastrarDisciplinas_jsp.java:205)
         org.apache.jsp.security.disciplina.cadastrarDisciplinas_jsp._jspx_meth_tiles_put_0(cadastrarDisciplinas_jsp.java:157)
         org.apache.jsp.security.disciplina.cadastrarDisciplinas_jsp._jspx_meth_tiles_insert_0(cadastrarDisciplinas_jsp.java:122)
         org.apache.jsp.security.disciplina.cadastrarDisciplinas_jsp._jspService(cadastrarDisciplinas_jsp.java:92)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
         com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
         com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
         com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
         com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
         com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
    Danilo.

    What worked for me was to add a flush="false" to each of the <tiles:insert tags in my layout page.
    I'm using this with JSF so it may be different for you:
    ... Layout stuff ...
       <tiles:insert attribute="body" flush="false" />
    ... More layout stuff, including more inserts with the flush="false" ....

  • Custom Tag in JSF Data Table

    I would like to do the equivalent of a custom tag within a JSF data table. How is this done? Custom tags don't seem to work within a JSF data table.

    There's a decent tutorial here, Priyo:
    http://www.exadel.com/tutorial/jsf/HowToWriteYourOwnJSFComponents.pdf
    Hope it helps,
    Illu

  • Cannot get facelets custom components to work

    Hi,
    I'm switching to facelets but I fail to get my custom components to work. I hope any of you can help me point out what is going wrong. My component is built into a seperate jar file:
    package be.xxx.web.tag;
    import java.io.IOException;
    import javax.faces.component.UIOutput;
    import javax.faces.context.FacesContext;
    import javax.faces.context.ResponseWriter;
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    public class IfTag extends UIOutput {
         public IfTag() {
              super();
              Log log = LogFactory.getLog(IfTag.class);
              log.debug("THIS IS THE IFTAG FACELETS IMPLEMENTATION");
              setRendererType(null);
         public boolean getRendersChildren() {
              return true;
         @Override
         public void encodeBegin(FacesContext facesContext) throws IOException {
              // We're rendering a table row
              facesContext.getResponseWriter().startElement("span", null);
         @Override
         public void encodeChildren(FacesContext facesContext) throws IOException {
              ResponseWriter writer = facesContext.getResponseWriter();
              writer.append("This if the IF tag");
         @Override
         public void encodeEnd(FacesContext facesContext) throws IOException {
              facesContext.getResponseWriter().endElement("span");
         @Override
         public String getFamily() {
              return COMPONENT_TYPE;
    }The taglib file in META-INF of the jar file:
    <?xml version="1.0" encoding="UTF-8"?>
    <!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>http://www.xxx.be/jsf/mw</namespace>
         <tag>
              <tag-name>menu</tag-name>
              <component>
                   <component-type>be.xxx.web.Menu</component-type>
              </component>
         </tag>
         <tag>
              <tag-name>if</tag-name>
              <component>
                   <component-type>be.xxx.web.If</component-type>
              </component>
         </tag>
    </facelet-taglib>Also in META-INF of the same jar, a faces-config.xml:
    <?xml version="1.0" encoding="utf-8"?>
    <faces-config 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-facesconfig_1_2.xsd"
                  version="1.2">
      <component>
        <component-type>be.xxx.web.Menu</component-type>
        <component-class>be.xxx.web.tag.MenuTag</component-class>
      </component>
      <component>
        <component-type>be.xxx.web.If</component-type>
        <component-class>be.xxx.web.tag.IfTag</component-class>
      </component>
    </faces-config>Finally, in the main project where the jar with above files is used, I try to call a custom tag:
    <html xmlns="http://www.w3.org/1999/xhtml"
         xmlns:mw="http://www.xxx.be/jsf/mw"
         xmlns:ui="http://java.sun.com/jsf/facelets">
    <mw:if></mw:if>
    </html>The result is that the if tag just writed out nothing, so "<mw:if></mw:if>" in the output just becomes "".
    I haven't found a way to debug this either (as in: I don't think the java code is even executed), so any tips would be greatly appreciated!
    Thanks

    Looks like I posted the wrong class. Here is the problematic one:
    public class MenuTag extends FacesBean implements BodyTag {
         private transient PageContext pc = null;
         private transient Tag parent = null;
         private transient BodyContent bodyContent;
         public void setPageContext(PageContext p) {
              pc = p;
         public void setParent(Tag t) {
              parent = t;
         public Tag getParent() {
              return parent;
         public int doStartTag() throws JspException {
              String url = null;
              try {
                   WebSession ws = (WebSession) getBean("ws");
                   if (ws.isLoggedIn()) {
                        // Get the value of the applicable menu rule
                        url = ws.getPolicy().getMenu();
                        if (url != null && !"".equals(url)) {
                             // Some logic to get correct file
                             String inputLine;
                             while ((inputLine = in.readLine()) != null)
                                  pc.getOut().write(inputLine);
                             in.close();
                             // We printed the menu, so skip the default menu
                             // that is in this tag's body.
                             return SKIP_BODY;
                   } else {
                        getLog().info("The user is not logged in, reverting to default menu.");
              } catch (FileNotFoundException ex) {
                   getLog().warn("Menu file not found (" + url + "), reverting to default menu.");
              } catch (Exception ex) {
                   throw new JspTagException("Error when applying the menu rule.", ex);
              return EVAL_BODY_BUFFERED;
         public int doEndTag() throws JspException {
              try {
                   if (bodyContent != null) {
                        bodyContent.writeOut(bodyContent.getEnclosingWriter());
              } catch (IOException e) {
                   throw new JspException("Error: " + e.getMessage());
              return EVAL_PAGE;
         public void release() {
              pc = null;
              parent = null;
         private String resolveServerUrl() {
              HttpServletRequest req = (HttpServletRequest) FacesContext
                        .getCurrentInstance().getExternalContext().getRequest();
              String url = req.getScheme() + "://" + req.getServerName();
              if (req.getServerPort() != 80) {
                   url += ":" + req.getServerPort();
              return url;
         public void doInitBody() throws JspException {
         public void setBodyContent(BodyContent bc) {
              bodyContent = bc;
         public int doAfterBody() throws JspException {
              return 0;
    }So, problem is that this is not working in facelets as a component, while it did in JSP's.
    Can I get any hints what I am doing wrong here?
    Thanks

  • Why doesn't my custom tag work?

    First, my backend database is MS Access. Nothing I can do about that, unfortunately.
    I have defined three custom tags (no body, no attributes) to display report information from my project tracking/metrics Access database:
    <prefix:showProjectInfo />
    <prefix:showProjectTeam />
    <prefix:showProjectHistory />
    In my JSP, the first tag I use, <prefix:showProjectInfo />, works perfectly. However, <prefix:showProjectTeam /> gives no output.
    First, here is the tld file that defines the tags (report.tld):
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE taglib
            PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
            "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
    <taglib>
        <tlib-version>1.0</tlib-version>
        <jsp-version>1.2</jsp-version>
        <short-name>report</short-name>
        <uri>/report</uri>   
        <!-- Forte4J_TLDX:  This comment contains code generation information. Do not delete.
        <tldx>
            <tagHandlerGenerationRoot>classes</tagHandlerGenerationRoot>
        </tldx>
        -->
        <!-- A validator verifies that the tags are used correctly at JSP
             translation time. Validator entries look like this:
          <validator>
              <validator-class>com.mycompany.TagLibValidator</validator-class>
              <init-param>
                 <param-name>parameter</param-name>
                 <param-value>value</param-value>
           </init-param>
          </validator>
       -->
       <!-- A tag library can register Servlet Context event listeners in
            case it needs to react to such events. Listener entries look
            like this:
         <listener>
             <listener-class>com.mycompany.TagLibListener</listener-class>
         </listener>
       -->
       <tag>
            <name>showProjectInfo</name>
            <tag-class>mil.usaf.rad.metrics.report.showProjectInfoTag</tag-class>
            <body-content>empty</body-content>
            <description>Shows the basic project information</description>       
       </tag>
       <tag>
            <name>showProjectTeam</name>
            <tag-class>mil.usaf.rad.metrics.report.showProjectTeamTag</tag-class>
            <body-content>empty</body-content>
       </tag>
       <tag>
            <name>showProjectHistory</name>
            <tag-class>mil.usaf.rad.metrics.report.showProjectHistoryTag</tag-class>
            <body-content>empty</body-content>
       </tag>
    </taglib>Next, here is the relevant section of web.xml that defines this taglib:
      <taglib>
            <taglib-uri>/WEB-INF/report.tld</taglib-uri>
            <taglib-location>/WEB-INF/report.tld</taglib-location>
      </taglib>Next, the code for showProjectTeamTag.java:
    * showProjectTeam.java
    * Created on March 9, 2005, 10:46 AM
    package mil.usaf.rad.metrics.report;
    import java.io.*;
    import java.sql.*;
    import java.lang.Integer;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.servlet.jsp.*;
    import javax.servlet.jsp.tagext.*;
    * @author  jason.ferguson
    public class showProjectTeamTag extends TagSupport
        public showProjectTeamTag()
            super();
        public int doAfterBody() throws JspException
            HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();
            int pr_id = Integer.parseInt(req.getParameter("pr_id"));
            JspWriter out = pageContext.getOut();
            Connection conn = null;
            Statement stmt = null;
            ResultSet rs = null;
            try
               out.print("test");
               Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
               conn = DriverManager.getConnection("jdbc:odbc:Metrics");
            catch (Exception e)
                throw new JspException(e.getMessage());
            String queryGetTeam = "SELECT Projects.pr_id, Accounts.name AS Name, Sum(Schedule.hours) AS SumOfhours FROM tblTAAccounts AS Accounts INNER JOIN ((tblTAScheduleEntries AS Schedule INNER JOIN tblProjectRelease AS ProjectRelease ON Schedule.projectID = ProjectRelease.tblFKTimeAccntProject) INNER JOIN tblPMProjects AS Projects ON ProjectRelease.Release_ID = Projects.pr_id) ON Accounts.accountID = Schedule.accountID WHERE Projects.pr_id=" + pr_id + " GROUP BY Projects.pr_id, Accounts.name, ProjectRelease.Release_number, Projects.Project_name";
            try
                out.print(queryGetTeam);
                stmt = conn.createStatement();
                rs = stmt.executeQuery(queryGetTeam);
                if (rs == null)
                    out.print("No Results!");
                out.print("<table>\n");
                out.print("<tr>\n");
                out.print("<th>Name</th>\n");
                out.print("<th>Total Hours</th>\n");
                out.print("</tr>\n");
                while(rs.next())
                    out.print("<tr>\n");
                    out.print("<td>" + rs.getString("Name") + "</td>\n");
                    out.print("<td>" + rs.getInt("SumOfhours") + "</td>\n");
                    out.print("</tr>\n");
                out.print("</table>\n");
                rs.close();
                stmt.close();
                conn.close();
            catch (Exception e)
                throw new JspException(e.getMessage());
            return SKIP_BODY;
    }Finally, projectdetail.jsp, where the tag is called:
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@page import="java.sql.*" %>
    <%@page import="java.lang.Integer" %>
    <%@taglib uri="/WEB-INF/report.tld" prefix="report" %>
    <html>
    <head><title>Project Detail</title></head>
    <body>
    <h1 align="center">Project Status</h1>
    <h3>Project Description</h3>
    <report:showProjectInfo />
    <h3>Team Members</h3>
    <report:showProjectTeam />
    </body>
    </html>The first tag, <report:showProjectInfo />, works fine. However, I get no output whatsoever when the system encounters <report:showProjectTeam />. I am a relative newbie at this, so any help is appreciated.
    Jason

    It doesnt seem to matter if the code is in doStartTag(), doEndTag(), orr any of the other functions.
    I also put, as the first item in the function:
    System.out.println("TEST");Nothing.
    Just as an aside, here is the code for the <prefix:showProjectInfo />. Maybe I made a mistake in it? I closed the resultset and connection...
    import java.io.*;
    import java.sql.*;
    import java.lang.Integer;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.servlet.jsp.*;
    import javax.servlet.jsp.tagext.*;
    * @author  jason.ferguson
    public class showProjectInfoTag extends BodyTagSupport
        public int doEndTag() throws JspException
            HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();
            int pr_id = Integer.parseInt(req.getParameter("pr_id"));
            JspWriter out = pageContext.getOut();
            Connection conn = null;
            Statement stmt = null;
            ResultSet rs = null;
            try
               Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                conn = DriverManager.getConnection("jdbc:odbc:Metrics");
            catch (Exception e)
                throw new JspException(e.getMessage());
            String queryProjectInfo = "SELECT * FROM tblPMProjects WHERE pr_id=" + pr_id;
            try
                stmt = conn.createStatement();
                rs = stmt.executeQuery(queryProjectInfo);
                while (rs.next())
                    out.print("<table border=\"1\" style=\"border-collapse:collapse\">\n");
                    out.print("<tr>\n");
                    out.print("<td><b>Project Name:</b>" + rs.getString("Project_name") + "</td>\n");
                    out.print("<td align=\"right\"><b>RAD Number:</b>" + rs.getString("tblProjectNumber") + "</td>\n");
                    out.print("</tr>\n");
                    out.print("<tr>\n");
                    out.print("<td>Project description: " + rs.getString("Project_description") + "</td>\n");
                    out.print("</tr>\n");
                    out.print("<tr>\n");
                    out.print("<td>Customer: " + rs.getString("Customer_POC") + "</td>");
                    out.print("<tr>\n");
                    out.print("<tr>\n");
                    out.print("<td>Customer Unit: " + rs.getString("Customer_OFC") + "</td>\n");
                    out.print("</tr>\n");
                    out.print("<tr>\n");
                    out.print("<td>Customer Phone: " + rs.getString("Customer_phone") + "</td>\n");
                    out.print("</tr>\n");
                    out.print("</table>\n");
                    rs.close();
                    stmt.close();
                    conn.close();
            catch (Exception e)
                throw new JspException(e.getMessage());
            finally
                //conn.close();
            return SKIP_BODY;

  • Is possible to write a custom tag inside another custom tag ??

    Hi
    I�m trying to reduce the time needed to code mi app presentation layer, it uses some custom tags with certain configuration, i would like to know if its possible to do something like this inside my custom tag doAfterBody().
    public int doAfterBody() throws JspException {
              JspWriter writer=bodyContent.getEnclosingWriter();
              try {
                   writer.print("<customTag:myAnotherTag someEspecificConfigurationParams="someEspecificValues"/>");
              } catch (IOException e) {
                   pageContext.getServletContext().log("Error: "+e.getMessage());
              }return SKIP_BODY;
         }The goal is to simplify the jsp code because the configuration params for the custom tags (css styles and similar) are allways the same.
    That don�t work, it simply prints <customTag:myAnotherTag/> in screen but the tag is not evaluated, i�ve tried too something like
    public int doAfterBody() throws JspException {
              if (repeat) {
                   JspWriter writer = bodyContent.getEnclosingWriter();
                   try {
                        writer.print("<customTag:myAnotherTag/>");
                   } catch (IOException e) {
                        pageContext.getServletContext().log("Error: " + e.getMessage());
                   repeat = false;
                   return EVAL_BODY_AGAIN;
              return SKIP_BODY;
         }And it doesn�t worked worked. Maybe using the taghandler classes and calls to the doAfterBody could make it work, but when you need to nest tags it could be a little hell of coupling calls, so before doing it i would like to know if what i want is possible. After reading some books i tought it could work because the stack of out objects, but i can�t make it work.
    Another idea is to inherit from tagHandler and override some properties in the tags, but i don�t like the idea to much.
    So, can anyone help me??
    Thanks.

    You cannot do that and I have listed out the reason and a possible solution in this post http://forum.java.sun.com/thread.jspa?threadID=697243 from yesterday.
    cheers,
    ram.

  • Custom tag with rendered attribute

    Is it possible to create a custom tag that operates similar to a JSF tag with the rendered attribute? Wrapping output with c:if test="..." is not as nice as the JSF rendered option, but I don't want to use JSF for this particular project.
    Edited by: black_lotus on Nov 23, 2007 12:13 PM

    TLD File, per your previous recommendation:
    <attribute>
         <name>disabled</name>
         <required>false</required>
         <rtexprvalue>true</rtexprvalue>
         <type>boolean</type>
    </attribute>My Tag class (snippet):
    public class ButtonTag extends TagSupport
      private boolean disabled;
      public ButtonTag() {}
      public boolean isDisabled()
         return disabled;
      public void setDisabled(boolean b)
        disabled = b;
    }A sample of the jsp file invoking it:
    <c:set var="result" value="${computedValue}"/>
    <ltm:button disabled="${result}"/>Regardless of the value of result, ("true" or "false") it always passes false to the setDisabled method of the button tag class.

Maybe you are looking for

  • Premiere Elements 12 Windows project to Mac

    I started my project on Windows 7 with Premiere Elements 12. Now I want to work with the project on Mac with Premiere Elements 12 (the same version). Unfortunately I got the error "The project is not compatible with current version of Premiere Elemen

  • Vendor change in PO

    Dear Experts, We have created PO for Vendor X and subsequent goods movements has taken place. As we are using QM, usage decision was also made and stock has been moved to unrestricted use. Being this PO is for material(Customer will provide material

  • Can I use a central glossary file across several projects?

    Hi everyone, hope you are all well. I have started a major project which needs a major glossary covering the companies definitions of various measures. These definitions will be needed by several other projects in the future. Is there a way of each p

  • Problems deleting an album previously synced from pc

    Hi, I have read several threads on the subject, and all seems simple, but I can't get it to work! I go to iTunes, select photos, uncheck the sync photos box, and get a popup saying " iTunes will no longer synch photos on the iPad. D you want to keep

  • Get Server Address in the cluster

    I want to get all the servers IP's participating in my cluster.           Is there a way to do it?           (I tried to use ClusterMBean APIs but it returns only the server names)           Thanks.