[ 
http://issues.apache.org/jira/browse/JELLY-193?page=comments#action_57434 ]
     
Paul Libbrecht commented on JELLY-193:
--------------------------------------

Marc,

Can you also support a parameter form that's an XML-element so that a 
documentation can be written in (hence read out by some documenters) ?

Overall, it has a strong taste of jelly:define (and I think it should go there) 
except that... you cannot invoke it as function="${f}" giving you some 
flexibility in the way you treat functions... I am not even sure it makes an 
enormous difference... oh yes... the return value.

For this, here's something that should help you: XMLOutput now has an 
objectData(Object) method which, by default, converts it to string. It would be 
easy to modify SetTag and some others which you use to "receive" the value of a 
return value so that simply saying ${anObject} is "received" by the SetTag.

The following would then work:

<j:jelly xmlns:j="jelly:core" xmlns:define="jelly:define"
    xmlns:blip="blip">
<define:taglib name="blip">
  <define:tag name="giveDate">
    <j:new var="date" className="java.util.Date"/>
    ${date}
  </define:tag>
</define:taglib>

<j:set var="d"><blip:giveDate/></j:set>


An alternative is working now, though somewhat unreadable:

<j:jelly xmlns:j="jelly:core" xmlns:define="jelly:define"
    xmlns:blip="blip">
<define:taglib name="blip">
  <!-- here something one day to say that we expect param "var" -->
  <define:tag name="giveDate">
    <j:new var="date" className="java.util.Date"/>
    ${context.parent.setVariable(var,date)}
  </define:tag>
</define:taglib>

<blip:giveDate var="dateOfToday"/>

paul

> Custom Function Tag
> -------------------
>
>          Key: JELLY-193
>          URL: http://issues.apache.org/jira/browse/JELLY-193
>      Project: jelly
>         Type: Improvement
>   Components: taglib.util
>     Versions: 1.0
>     Reporter: Marc DeXeT
>     Priority: Minor
>  Attachments: patch.function.test.txt, patch.function.txt
>
> Create custom callable function in jelly script.
> Feature
> 1 - isolated context for function execution.
> 2 - return list support break
> 3 - result list support
> For example :
> <u:function var="f" args="arg0,arg1">
>  <u:result value="${arg0 + arg1}"/>
> </u:function>
>       
> <u:call function="${f}" result="s">
>   <j:arg value="1"/>
>   <j:arg value="2"/>
> </u:call>
> <!-- s = 3 -->
> Another example :
> <u:function var="f" args="arg0">
>   <j:switch on="${arg0}">
>     <j:case value="start">
>        <u:return value="started"/>
>     </j:case>
>     <j:case value="end">
>        <u:return value="ended"/>
>     </j:case>
>     <j:default>
>        <j:set var="ret" value="none"/>
>     </j:default>                                                              
>   </j:switch>
>                       
>   <u:result value="${ret}"/>
> </u:function>
>       
> <u:call function="${f}" result="s">
>   <j:arg value="start"/>
> </u:call>
> <!-- s = "started" -->

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


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

Reply via email to