You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Marco Tedone <mt...@jemos.co.uk> on 2006/04/24 20:34:20 UTC

[Jelly] How to pass a collection to a TagSupport

Hi, I've got a class which extends TagSupport. This class has got many 
initialization attributes. Some of them are Collections, some are arrays. 
How to I pass, from within the Jelly tag, all the values to a collection or 
to an array? 


---
[This E-mail has been scanned for viruses but it is your responsibility 
to maintain up to date anti virus software on the device that you are
currently using to read this email. ]


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


Re: [Jelly] How to pass a collection to a TagSupport

Posted by Paul Libbrecht <pa...@activemath.org>.
Marco Tedone wrote:
> I would like to test your solution. I created a simple ParentTag 
> containing FilterTag. In FilterTag I use:
>
> XMLOutput.objectData(new String("Hello World"));
>
> How do I catch object data from of type FilterTag from within ParentTag?
I think new String("Hello World") doesn't taste much like FilterTag but 
in any case...

I think your ParentTag should override doTag as follows:

    public void doTag(XMLOutput output) throws JellyTagException {
        super.doTag(new XMLOutput(output) {
            public void objectData(Object object) throws SAXException {
              // do something with object... e.g. a filter-data
            }
        });
    }

Tell me if it works for you.

paul

> Ta.
>
> Marco
>
>> - in the doTag of jemos:clanker, however, you have cared for an 
>> XMLOutput which catches the objectData calls of class filter-data... 
>> and you use them.
>
>
> ----- Original Message ----- From: "Paul Libbrecht" <pa...@activemath.org>
> To: "Marco Tedone" <mt...@jemos.co.uk>
> Cc: "Jakarta Commons Users List" <co...@jakarta.apache.org>
> Sent: Tuesday, April 25, 2006 10:03 PM
> Subject: Re: [Jelly] How to pass a collection to a TagSupport
>
>
>> I think Jelly is so flexible that there's half a dozen ways to do so.
>>
>> • I thought the Ant way of doing was supported (where addConfigured 
>> and add and... may work) but I am unsure.
>> • some tags use findAncestorWithClass which I don't like since it 
>> breaks if within a defined script
>> • I would suggest a fancy one which I think is the best style since 
>> it allows defined scripts to be used but requires a current snapshot 
>> of jelly: make jemos:filter tags be classes and use 
>> XMLOutput.objectData(object) at the end in their doTag classes.
>> - If not within a jemos:clanker tag, that would result into the 
>> toString() of object to be output as text.
>> - in the doTag of jemos:clanker, however, you have cared for an 
>> XMLOutput which catches the objectData calls of class filter-data... 
>> and you use them.
>>
>> Hope that helps.
>>
>> paul
>
>
> ---
> [This E-mail has been scanned for viruses but it is your 
> responsibility to maintain up to date anti virus software on the 
> device that you are
> currently using to read this email. ]
>


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


Re: [Jelly] How to pass a collection to a TagSupport

Posted by Marco Tedone <mt...@jemos.co.uk>.
I would like to test your solution. I created a simple ParentTag containing 
FilterTag. In FilterTag I use:

XMLOutput.objectData(new String("Hello World"));

How do I catch object data from of type FilterTag from within ParentTag?

Ta.

Marco

> - in the doTag of jemos:clanker, however, you have cared for an XMLOutput 
> which catches the objectData calls of class filter-data... and you use 
> them.


----- Original Message ----- 
From: "Paul Libbrecht" <pa...@activemath.org>
To: "Marco Tedone" <mt...@jemos.co.uk>
Cc: "Jakarta Commons Users List" <co...@jakarta.apache.org>
Sent: Tuesday, April 25, 2006 10:03 PM
Subject: Re: [Jelly] How to pass a collection to a TagSupport


>I think Jelly is so flexible that there's half a dozen ways to do so.
>
> • I thought the Ant way of doing was supported (where addConfigured and 
> add and... may work) but I am unsure.
> • some tags use findAncestorWithClass which I don't like since it breaks 
> if within a defined script
> • I would suggest a fancy one which I think is the best style since it 
> allows defined scripts to be used but requires a current snapshot of 
> jelly: make jemos:filter tags be classes and use 
> XMLOutput.objectData(object) at the end in their doTag classes.
> - If not within a jemos:clanker tag, that would result into the toString() 
> of object to be output as text.
> - in the doTag of jemos:clanker, however, you have cared for an XMLOutput 
> which catches the objectData calls of class filter-data... and you use 
> them.
>
> Hope that helps.
>
> paul


---
[This E-mail has been scanned for viruses but it is your responsibility 
to maintain up to date anti virus software on the device that you are
currently using to read this email. ]


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


Re: [Jelly] How to pass a collection to a TagSupport

Posted by Paul Libbrecht <pa...@activemath.org>.
I think Jelly is so flexible that there's half a dozen ways to do so.

• I thought the Ant way of doing was supported (where addConfigured and 
add and... may work) but I am unsure.
• some tags use findAncestorWithClass which I don't like since it breaks 
if within a defined script
• I would suggest a fancy one which I think is the best style since it 
allows defined scripts to be used but requires a current snapshot of 
jelly: make jemos:filter tags be classes and use 
XMLOutput.objectData(object) at the end in their doTag classes.
- If not within a jemos:clanker tag, that would result into the 
toString() of object to be output as text.
- in the doTag of jemos:clanker, however, you have cared for an 
XMLOutput which catches the objectData calls of class filter-data... and 
you use them.

Hope that helps.

paul

Marco Tedone wrote:
> Ah ok...Thanks :)
>
> Then I have a question ;)
>
> I have got a tag (let's say <jemos:clanker> which launches an analysis 
> process. I want to pass some 'filters' to the analysis process, so I 
> am thinking of doing something like:
>
> <jemos:clanker attr...>
> <jemos:filter type="process" processJavadocs="true" 
> processAnnotations="true" />
> <jemos:filter type="javadocs" tags="@clanker1, @clanker2, etc." />
> <jemos:filter type="annotations" name="@ClankerDoSomething" 
> level="class" />
> <etc...>
> </jemos:clanker>
>
> <jemos:clanker> and <jemos:filter> map to a TagSupport class. I'd like 
> that each <jemos:filter> to be added to
> <jemos:clanker> in a programmatic way. I thought: ok, from within 
> <jemos:clanker> body I can obtain a reference to all the 
> <jemos:filter> filters and retrieve their values. Is this the right 
> thing to do? If so, is the getBody() method the right place where to 
> do that?
>
> Many thanks for any answers.
>
> Marco
>
> ----- Original Message ----- From: "Paul Libbrecht" <pa...@activemath.org>
> To: "Jakarta Commons Users List" <co...@jakarta.apache.org>
> Sent: Tuesday, April 25, 2006 8:38 AM
> Subject: Re: [Jelly] How to pass a collection to a TagSupport
>
>
>> Hey Marco,
>>
>> newbies are welcome at Jelly... and I fear the assistance of the list 
>> is needed since documentation can be somehow... lagging behind.
>>
>> paul
>>
>> Marco Tedone wrote:
>>> Thank you. That worked nicely. You know, I'm a newbie.
>>> ----- Original Message ----- From: "Paul Libbrecht" 
>>> <pa...@activemath.org>
>>> To: "Jakarta Commons Users List" <co...@jakarta.apache.org>
>>> Sent: Monday, April 24, 2006 11:08 PM
>>> Subject: Re: [Jelly] How to pass a collection to a TagSupport
>>>
>>>
>>>> Marco Tedone wrote:
>>>>> Hi, I've got a class which extends TagSupport. This class has got 
>>>>> many initialization attributes. Some of them are Collections, some 
>>>>> are arrays. How to I pass, from within the Jelly tag, all the 
>>>>> values to a collection or to an array?
>>>> Why does it not work to pass have a setter be called by the 
>>>> collection with such a thing as
>>>> <j:new var="coll" className="java.util.ArrayList"/>
>>>> <j:mute>${coll.add('a')} ${col.add('b')} ${col.add('c')}</j:mute>
>>>> <t:tag collection="${coll}"/>
>>>>
>>>> ?
>>>>
>>>> Or do you want to type in a litteral collection (such as 
>>>> ['a','b','c']) ?
>>>>
>>>> paul
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>>>> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>>>
>>>>
>>>
>>> ---
>>> [This E-mail has been scanned for viruses but it is your 
>>> responsibility to maintain up to date anti virus software on the 
>>> device that you are
>>> currently using to read this email. ]
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>>
>
>
> ---
> [This E-mail has been scanned for viruses but it is your 
> responsibility to maintain up to date anti virus software on the 
> device that you are
> currently using to read this email. ]
>


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


Re: [Jelly] How to pass a collection to a TagSupport

Posted by Marco Tedone <mt...@jemos.co.uk>.
Ah ok...Thanks :)

Then I have a question ;)

I have got a tag (let's say <jemos:clanker> which launches an analysis 
process. I want to pass some 'filters' to the analysis process, so I am 
thinking of doing something like:

<jemos:clanker attr...>
  <jemos:filter type="process" processJavadocs="true" 
processAnnotations="true" />
  <jemos:filter type="javadocs" tags="@clanker1, @clanker2, etc." />
  <jemos:filter type="annotations" name="@ClankerDoSomething" level="class" 
/>
 <etc...>
</jemos:clanker>

<jemos:clanker> and <jemos:filter> map to a TagSupport class. I'd like that 
each <jemos:filter> to be added to
<jemos:clanker> in a programmatic way. I thought: ok, from within 
<jemos:clanker> body I can obtain a reference to all the <jemos:filter> 
filters and retrieve their values. Is this the right thing to do? If so, is 
the getBody() method the right place where to do that?

Many thanks for any answers.

Marco

----- Original Message ----- 
From: "Paul Libbrecht" <pa...@activemath.org>
To: "Jakarta Commons Users List" <co...@jakarta.apache.org>
Sent: Tuesday, April 25, 2006 8:38 AM
Subject: Re: [Jelly] How to pass a collection to a TagSupport


> Hey Marco,
>
> newbies are welcome at Jelly... and I fear the assistance of the list is 
> needed since documentation can be somehow... lagging behind.
>
> paul
>
> Marco Tedone wrote:
>> Thank you. That worked nicely. You know, I'm a newbie.
>> ----- Original Message ----- From: "Paul Libbrecht" <pa...@activemath.org>
>> To: "Jakarta Commons Users List" <co...@jakarta.apache.org>
>> Sent: Monday, April 24, 2006 11:08 PM
>> Subject: Re: [Jelly] How to pass a collection to a TagSupport
>>
>>
>>> Marco Tedone wrote:
>>>> Hi, I've got a class which extends TagSupport. This class has got many 
>>>> initialization attributes. Some of them are Collections, some are 
>>>> arrays. How to I pass, from within the Jelly tag, all the values to a 
>>>> collection or to an array?
>>> Why does it not work to pass have a setter be called by the collection 
>>> with such a thing as
>>>  <j:new var="coll" className="java.util.ArrayList"/>
>>>  <j:mute>${coll.add('a')} ${col.add('b')} ${col.add('c')}</j:mute>
>>>   <t:tag collection="${coll}"/>
>>>
>>> ?
>>>
>>> Or do you want to type in a litteral collection (such as ['a','b','c']) 
>>> ?
>>>
>>> paul
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>>
>>>
>>
>> ---
>> [This E-mail has been scanned for viruses but it is your responsibility 
>> to maintain up to date anti virus software on the device that you are
>> currently using to read this email. ]
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
> 


---
[This E-mail has been scanned for viruses but it is your responsibility 
to maintain up to date anti virus software on the device that you are
currently using to read this email. ]


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


Re: [Jelly] How to pass a collection to a TagSupport

Posted by Paul Libbrecht <pa...@activemath.org>.
Hey Marco,

newbies are welcome at Jelly... and I fear the assistance of the list is 
needed since documentation can be somehow... lagging behind.

paul

Marco Tedone wrote:
> Thank you. That worked nicely. You know, I'm a newbie.
> ----- Original Message ----- From: "Paul Libbrecht" <pa...@activemath.org>
> To: "Jakarta Commons Users List" <co...@jakarta.apache.org>
> Sent: Monday, April 24, 2006 11:08 PM
> Subject: Re: [Jelly] How to pass a collection to a TagSupport
>
>
>> Marco Tedone wrote:
>>> Hi, I've got a class which extends TagSupport. This class has got 
>>> many initialization attributes. Some of them are Collections, some 
>>> are arrays. How to I pass, from within the Jelly tag, all the values 
>>> to a collection or to an array?
>> Why does it not work to pass have a setter be called by the 
>> collection with such a thing as
>>  <j:new var="coll" className="java.util.ArrayList"/>
>>  <j:mute>${coll.add('a')} ${col.add('b')} ${col.add('c')}</j:mute>
>>   <t:tag collection="${coll}"/>
>>
>> ?
>>
>> Or do you want to type in a litteral collection (such as 
>> ['a','b','c']) ?
>>
>> paul
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>>
>
> ---
> [This E-mail has been scanned for viruses but it is your 
> responsibility to maintain up to date anti virus software on the 
> device that you are
> currently using to read this email. ]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>


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


Re: [Jelly] How to pass a collection to a TagSupport

Posted by Marco Tedone <mt...@jemos.co.uk>.
Thank you. That worked nicely. You know, I'm a newbie.
----- Original Message ----- 
From: "Paul Libbrecht" <pa...@activemath.org>
To: "Jakarta Commons Users List" <co...@jakarta.apache.org>
Sent: Monday, April 24, 2006 11:08 PM
Subject: Re: [Jelly] How to pass a collection to a TagSupport


> Marco Tedone wrote:
>> Hi, I've got a class which extends TagSupport. This class has got many 
>> initialization attributes. Some of them are Collections, some are 
>> arrays. How to I pass, from within the Jelly tag, all the values to a 
>> collection or to an array?
> Why does it not work to pass have a setter be called by the collection 
> with such a thing as
>  <j:new var="coll" className="java.util.ArrayList"/>
>  <j:mute>${coll.add('a')} ${col.add('b')} ${col.add('c')}</j:mute>
>   <t:tag collection="${coll}"/>
> 
> ?
> 
> Or do you want to type in a litteral collection (such as ['a','b','c']) ?
> 
> paul
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
>

---
[This E-mail has been scanned for viruses but it is your responsibility 
to maintain up to date anti virus software on the device that you are
currently using to read this email. ]


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


Re: [Jelly] How to pass a collection to a TagSupport

Posted by Paul Libbrecht <pa...@activemath.org>.
Marco Tedone wrote:
> Hi, I've got a class which extends TagSupport. This class has got many 
> initialization attributes. Some of them are Collections, some are 
> arrays. How to I pass, from within the Jelly tag, all the values to a 
> collection or to an array?
Why does it not work to pass have a setter be called by the collection 
with such a thing as
  <j:new var="coll" className="java.util.ArrayList"/>
  <j:mute>${coll.add('a')} ${col.add('b')} ${col.add('c')}</j:mute>
   <t:tag collection="${coll}"/>

?

Or do you want to type in a litteral collection (such as ['a','b','c']) ?

paul

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