Do you know of a taglib that can build xml compliant elements and
attributes.

For example:

I have an image tag that I need to assign attributes to conditionally.

<img src="my.jpg" width="12" height="24"/>

The src, width and height are provided by data entered into the database.

If the width or height is empty I want to remove the width attribute or the
height attribute.

I can do this with jstl, now, as follows:

....
<c:set var="form" scope="page" value="requestScope.myStrutsForm"/>

<c:set var="imgString">
<img src="<c:out value="${form.image.src}" />"
<c:if test="${!empty form.image.width}">
 width="<c:out value="${form.image.width}" />"
</c:if>
<c:if test="${!empty form.image.height}">
 height="<c:out value="${form.image.height}" />"
</c:if>
/>
</c:set>
....

shweeeew! messy! My head is spinning and I hope I got all my quotes right
:-D


Now it would be nice to do something like:

<c:set var="form" scope="page" value="requestScope.myStrutsForm"/>

<c:set var="imgString">
 <tag:element name="a">
     <tag:attribute name="src" value="${form.image.src}"/>
   <c:if test="${!empty form.image.width}">
     <tag:attribute name="width" value="${form.image.width}"/>
   </c:if>
   <c:if test="${!empty form.image.height}">
     <tag:attribute name="height" value="${form.image.height}"/>
   </c:if>
 </tag:element>
</c:set>

aaaaaaaaaaah! manageable.

So, do you know of any tags like these. Wouldn't this be nice for building
conditional markup on your page?

Brandon Goodin
Phase Web and Multimedia
PO Box 85
Whitefish MT 59937
P (406) 862-2245
F (406) 862-0354
[EMAIL PROTECTED]
http://www.phase.ws



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to