You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by korebantic <ko...@yahoo.com> on 2004/04/15 03:18:11 UTC

[Jelly] feature addition for jelly-tags-http

> 
> 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

Re: [Jelly] feature addition for jelly-tags-http

Posted by Paul Libbrecht <pa...@dfki.de>.
On 18-Apr-04, at 01:13 Uhr, korebantic wrote:
>> you indeed can but it typically pollutes the output
>> (so much that I'm
>> thinking of making a util:mute tag soon which would
>> /dev/nullify the
>> xml-output).
> Interesting. One thing that bothers me about the Jelly
> output is that no matter how many trim="true"
> attributes I use, I still get more whitespace then I
> want. Then I end up spending to much time trying to
> make the output pretty. So this tag would kill all
> output? What would the interaction be with
> jelly-tags-log? It would be nice to have something
> configurable -- then you could either get the
> behaviour Jelly gives now, or something more like a
> scripting language, where you have to explicitly call
> something like <echo> to get output.

As far as I know log-output and ant:echo are both directed to 
system.err and are, for sure, competely separate from the default 
jelly-output.
It's easy to make your own mute tag, it's just, sooooo ugly:

<x:parse var="blop">
  I am some ${'junk'}some ${'blop'.class}o... far far...
  </x:parse><j:set var="blop" value="${null}"/>

paul


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: [Jelly] feature addition for jelly-tags-http

Posted by korebantic <ko...@yahoo.com>.
--- Paul Libbrecht <pa...@dfki.de> wrote:
> 
> 
> 
> On 15-Apr-04, at 23:37 Uhr, robert burrell donkin
> wrote:
> > [...]
> > i think that you should be able to use jexl (the
> jelly expression 
> > language) to populate lists
> 
> you indeed can but it typically pollutes the output
> (so much that I'm 
> thinking of making a util:mute tag soon which would
> /dev/nullify the 
> xml-output).
Interesting. One thing that bothers me about the Jelly
output is that no matter how many trim="true"
attributes I use, I still get more whitespace then I
want. Then I end up spending to much time trying to
make the output pretty. So this tag would kill all
output? What would the interaction be with
jelly-tags-log? It would be nice to have something
configurable -- then you could either get the
behaviour Jelly gives now, or something more like a
scripting language, where you have to explicitly call
something like <echo> to get output.
   
> I also think it tastes good but I would see
> something such better in 
> the util taglib. If I understood correctly, this is
> mostly two things:
> - a value-pair tag compatible with the http params
> (something of the 
> form Map.Entry, or ?)
The parameters attribute that the jelly-tags-http
library expects is a java.util.List whose elements are
 org.apache.commons.httpclient.NameValuePair objects.

> - an "add" tag which simply invokes the method "add"
> to a collection 
> for each children.
> I agree the first might be specific to http
> taglib... so keep it there 
> if you feel. The second, however, is probably even
> more generic than 
> what you expect, it doesn't need, at all, to have a
> collection as 
> operating object... (make the "add" method-name
> configurable).
Yes, a more generic solution that provided a way to
easily manipulate data structures in the collections
framework would be cool and very useful.

> One thing that would be nice when proposing such
> tags, aside of an 
> example as you provide, would be a kind of
> tag-documentation, asciied 
> for the list.
Ok
 
> And, as Robert indicated, I believe this should come
> along with junit 
> tests.
Sure thing -- Junit is a breeze. With a few junit tags
I could easily change that last script into a Junit
test script.



	
		
__________________________________
Do you Yahoo!?
Yahoo! Photos: High-quality 4x6 digital prints for 25�
http://photos.yahoo.com/ph/print_splash

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: [Jelly] feature addition for jelly-tags-http

Posted by Paul Libbrecht <pa...@dfki.de>.


On 15-Apr-04, at 23:37 Uhr, robert burrell donkin wrote:
> [...]
> i think that you should be able to use jexl (the jelly expression 
> language) to populate lists

you indeed can but it typically pollutes the output (so much that I'm 
thinking of making a util:mute tag soon which would /dev/nullify the 
xml-output).

> 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).

I also think it tastes good but I would see something such better in 
the util taglib. If I understood correctly, this is mostly two things:
- a value-pair tag compatible with the http params (something of the 
form Map.Entry, or ?)
- an "add" tag which simply invokes the method "add" to a collection 
for each children.
I agree the first might be specific to http taglib... so keep it there 
if you feel. The second, however, is probably even more generic than 
what you expect, it doesn't need, at all, to have a collection as 
operating object... (make the "add" method-name configurable).

One thing that would be nice when proposing such tags, aside of an 
example as you provide, would be a kind of tag-documentation, asciied 
for the list.

And, as Robert indicated, I believe this should come along with junit 
tests.

thanks in advance.

paul


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: [Jelly] feature addition for jelly-tags-http

Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
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: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org