Hi,

I'm writing this mail to get your suggestions to a problem and a
proposed solution.

In Tobago we have many components with a label. In the moment every
renderer renders the label itself (by the XxxRenderer). (I'm talking
about labels for e.g. t:in and t:textarea like the attached image, not
t:box or the labels for f:selectItem)
The disadvantage is that every theme and every renderer has to
implement the rendering of the label. That is boring and error-prone.

So I want to use a layout-manager to define the positioning of the label
per theme only once. See:
   <t:panel>
     <f:facet name="layout">
       <t:labelLayout />
     </f:facet>
     <t:label value="Name:" for="name"/>
     <t:in value="#{name}" id="name" />
   </t:panel>
This works fine, but it is very much code.

A smart way to solve this are tag files (JSP 2.0).
File: WEB-INF/tobago-extension/label.tag:

<%@ taglib uri="http://www.atanion.com/tobago/component"; prefix="t" %>
<%@ taglib uri="http://java.sun.com/jsf/core"; prefix="f" %>

<%@ attribute name="value" %>
<%@ attribute name="tip" %>

<t:panel>
   <f:facet name="layout">
     <t:labelLayout />
   </f:facet>
   <t:label value="${value}" tip="${tip}" />
   <jsp:doBody/>
   <t:relationSolver />
</t:panel>

Your can use it like:
<%@ taglib tagdir="/WEB-INF/tags/tobago-extension" prefix="tx" %>

<tx:label value="Name:" tip="Please input your name">
   <t:in value="#{name}"/>
</tx:label>

advantages:
* Usable with many tags (inside the body).
* Very transparent for the developer.
* simple to write analog tags.

disadvantages:
* needs JSP 2.0
* need a "relationSolver" (to set the "for" attribute of the label)

Some people say that this is too long for me:
<tx:label value="Name:" tip="Please input your name">
   <t:in value="#{name}"/>
</tx:label>

I want to write:
<tx:in label="Name:" value="#{name}" />

To do that, one can write another tag file: in.tag
<%@ attribute name="label" %>
<%@ attribute name="value" %>
<tx:label value="${label}">
   <t:in value="${value}"/>
</tx:label>


Another approach was to make all the stuff internally in the tag class.
The t:in has to create a UIComponent structure:
UIPanel
   +LayoutManager (as facet)
   +UIOutput (label)
   +IUInput
disadvantages:
* different component structure if there is a label or not.
* not easy to understand
* does the binding belong to the UIInput or to the UIPanel?
* ...
So we rejected this approach.


GIF image

Reply via email to