You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Marc DeXeT (JIRA)" <co...@jakarta.apache.org> on 2005/01/08 19:33:14 UTC
[jira] Created: (JELLY-193) Custom Function Tag
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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Updated: (JELLY-193) Custom Function Tag
Posted by "Marc DeXeT (JIRA)" <co...@jakarta.apache.org>.
[ http://issues.apache.org/jira/browse/JELLY-193?page=history ]
Marc DeXeT updated JELLY-193:
-----------------------------
Attachment: patch.functionRC_.2.txt
New version compatible with RC2
> 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, patch.functionRC_.2.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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Updated: (JELLY-193) Custom Function Tag
Posted by "Marc DeXeT (JIRA)" <co...@jakarta.apache.org>.
[ http://issues.apache.org/jira/browse/JELLY-193?page=history ]
Marc DeXeT updated JELLY-193:
-----------------------------
Attachment: patch.function.test.txt
Unit tests
> 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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Commented: (JELLY-193) Custom Function Tag
Posted by "Marc DeXeT (JIRA)" <co...@jakarta.apache.org>.
[ http://issues.apache.org/jira/browse/JELLY-193?page=comments#action_57436 ]
Marc DeXeT commented on JELLY-193:
----------------------------------
I mean :
**********************
<function var="f">
<result>
<j:arg value="wooki">
<j:arg value="Laura">
<j:useBean var="book" class="org.foo.Book" title="Catch22" rating="excellent"/>
<j:arg value="${book}">
</result>
</function>
<call function="${f}" result="myPetName,myWifeName,myFavoriteBook"/>
**********************
> 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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Updated: (JELLY-193) Custom Function Tag
Posted by "Marc DeXeT (JIRA)" <co...@jakarta.apache.org>.
[ http://issues.apache.org/jira/browse/JELLY-193?page=history ]
Marc DeXeT updated JELLY-193:
-----------------------------
Attachment: patch.function.txt
Patch for util lib.
> 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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Commented: (JELLY-193) Custom Function Tag
Posted by "Marc DeXeT (JIRA)" <co...@jakarta.apache.org>.
[ http://issues.apache.org/jira/browse/JELLY-193?page=comments#action_57435 ]
Marc DeXeT commented on JELLY-193:
----------------------------------
Paul,
It's late but... :)
Function Tag seems to me more explicit :
- you can define several function without defining lib.
- each function can be considered as subroutine (without return) to write in XMLoutput
<function var="motif" args="link,name">
<bigStuffOnSeveralLines/>
<a href="${link}">${name}</a>
<bigStuffOnSeveralLines2/>
</function>
- you can return one or more distinct value with result and return tag
as they implement ArgTagParent.
<function var="f">
<result>
<j:arg value="${retVal0}">
<j:arg value="${retVal1}">
<j:arg value="${retVal2}">
</result>
</function>
<call function="${f}" result="myPetName,myWifeName,myFavoriteBook"/>
I prefer to avoid unreadable stuff like : ${context.parent.setVariable(var,date)}.
If you have customer to answer, less technical it looks, more customer can think he understand something :))
And I have a lot of not-technical users I want they use and customize little script for their every-day task.
> 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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Commented: (JELLY-193) Custom Function Tag
Posted by "Paul Libbrecht (JIRA)" <co...@jakarta.apache.org>.
[ 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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org