hi

(i'm pretty new to jelly myself so hopefully paul or dIon might like to jump in here with better informed comments.)

i think that you should be able to use jexl (the jelly expression language) to populate lists but i do think that your proposed tag does make for readable jelly. i'd therefore be inclined to commit it so long as it was supported by unit tests and documentation (unless other more experienced people jump in with reasons why this is bad idea).

- robert

On 15 Apr 2004, at 02:18, korebantic wrote:


http://jakarta.apache.org/commons/patches.html


I added a feature as part of my own custom tag
library, but it would be of some benefit to others. If
you feel like the feature is worthwhile I'll "port" it
over from my tag library to the jelly-tags-http and
provide a patch.

Many of the http tags support passing in a parameter
java.util.List with the parameter element. However,
there are no tags that make it easy to build this
list. My addition makes building these lists a cinch.

I've included a sample jelly script to give you an
idea of how the tag(s) work.


__________________________________ Do you Yahoo!? Yahoo! Tax Center - File online by April 15th http://taxes.yahoo.com/filing.html<?xml version="1.0"?> <!-- author: Trent Albright

description:

Example illustrating the use of a custom tag library. The taglib itself
implements a List of name value pairs, suitable for use with the http
taglib. See the source for more details.
-->
<j:jelly
xmlns:j="jelly:core"
xmlns:http="jelly:http"
xmlns:nvplist="jelly: com.ibm.commerce.jellyroll.tags.nvplist.NVPListTagLibrary"
trim="false">


Testing taglib

Pairs can be created using the jelly core tag "useBean"
<j:useBean var="myusebean" class="org.apache.commons.httpclient.NameValuePair" name="usebeannvp" value="Created using core tag useBean"/>
useBean myusebean={${myusebean}}


Pairs can be created outside the add and create tags and used later
<nvplist:pair name="xxx" value="yyy" var="standalonenvp"/>

Create and Add
<nvplist:add var="parms">
<nvplist:pair name="x" value="y"/>
<nvplist:pair name="xx" value="yy"/>
<nvplist:pair name="${standalonenvp.name}" value="${standalonenvp.value}"/>
</nvplist:add>


<j:forEach items='${parms}' var="nvp" trim="false">
  nvp=${nvp}
</j:forEach>

Add to already existing list
<nvplist:add var="parms">
        <nvplist:pair name="morestuff" value="added"/>
</nvplist:add>

<j:forEach items='${parms}' var="nvp" trim="false">
  nvp=${nvp}
</j:forEach>

Create and Add to a new list
<nvplist:create var="newlist">
  <nvplist:pair name="newlistx" value="newlisty"/>
</nvplist:create>

<j:forEach items='${newlist}' var="nvp" trim="false">
  nvp=${nvp}
</j:forEach>

Create an empty list
<nvplist:add var="emptylist"></nvplist:add>

<j:forEach items='${emptylist}' var="nvp" trim="false">
  nvp=${nvp}
</j:forEach>

Copy from one list to another
<nvplist:copyinto to="${newlist}" from="${parms}"/>
<j:forEach items='${newlist}' var="nvp" trim="false">
  nvp=${nvp}
</j:forEach>

Now clear the list
<nvplist:clear list="${newlist}"/>
<j:forEach items='${newlist}' var="nvp" trim="false">
  nvp=${nvp}
</j:forEach>


Make sure exceptions are thrown


<j:catch var="ex">
<nvplist:add var="emptylist">
  <nvplist:pair name="foo"/>
</nvplist:add>
</j:catch>

<j:if test="${ex!=null}">
  Exception thrown
</j:if>

<j:catch var="ex">
<nvplist:add var="emptylist">
  <nvplist:pair value="foo"/>
</nvplist:add>
</j:catch>

<j:if test="${ex!=null}">
  Exception thrown
</j:if>

Try using the list with http tag lib
<nvplist:create var="gparms">
  <nvplist:pair name="hl" value="en"/>
  <nvplist:pair name="ie" value="UTF-8"/>
</nvplist:create>

<http:get uri="http://www.google.com/imghp"; var="results" parameters="${gparms}"/>
status code ${results.statusCode} (${results.statusText})
query string ${results.queryString}


<http:get uri="http://127.0.0.1/test.php"; var="results" parameters="${gparms}"/>
status code ${results.statusCode} (${results.statusText})
query string ${results.queryString}


</j:jelly>

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


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



Reply via email to