You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Robert <rm...@bull-enterprises.com> on 2002/10/07 18:18:43 UTC

[Jelly] Invoking methods (was: WhileTag)

That clears it up for me, thanks James. One quick question, can the
parameter of a method call be a variable in the context? Using your
example:
${plantViewRemote.foo(a, b, 123, 'hello')}

I'm guessing/assuming/hoping that the 'a' and 'b' can be variables in
the JellyContext, while 'hello' in this case is a static parameter?

- Robert

-----Original Message-----
From: James Strachan [mailto:james_strachan@yahoo.co.uk] 
Sent: Saturday, October 05, 2002 4:48 AM
To: Jakarta Commons Developers List
Subject: Re: [Jelly] WhileTag

From: "Eric Alexander" <er...@genscape.com>
> Hi all! Here's a patch to Jelly for a simple while tag. The usage
looks
like
> this:
>
> <j:while test="${trueVar == 'true'}">
> <i:ask question="Goal:" answer="goal"/>
> <j:if test="${goal == 'exit'}">
> <j:set var="trueVar" value="false"/>
> </j:if>
> </j:while>
>
> So it simply takes an Expression for an argument and continues to loop
while
> it's true.

Great stuff! Many thanks and to dIon for committing it.


> Anyway, Jelly is really really cool. I'm having a lot of fun with it
lately.
> Jim Birchfield and I have
> also came up with the beginnings to an EJB tag.. Here's a sample of
what
it
> looks like now:
>
>  <ejb:context var="jboss" provider="localhost:1099"
> factory="org.jnp.interfaces.NamingContextFactory"/>
>  <ejb:home ctx="jboss" var="plantViewHome"
> homeClass="com.genscape.ejb.common.PlantViewHome"
jndiName="ejb/PlantView"/>
>  <ejb:remote home="plantViewHome" var="plantViewRemote"
> remoteClass="com.genscape.ejb.plant.PlantView"/>
>  <ejb:invokeMethod var="results" remote="plantViewRemote"
> method="findPlant"/>
>
> This is all working pretty good, but we're trying to figure out a way
to
> pass arguments into the invoked method...
> If anyone has any good ideas, just holler!

Groovy.

You can use the expression language to invoke methods...

${plantViewRemote.foo(a, b, 123, 'hello')}

If you want to capture a return value then use this

  <j:set var="answer" value="${somebean.calculateSomething(a, b)}"/>

If you want to you can use a real scripting language like beanshell,
jython,
javascript, jacl etc. Though typically just invoking methods via the
expression language (Jexl) is enough. e.g. here's Jason's example script
for
using the command line..

<jelly xmlns="jelly:core" xmlns:bsh="jelly:beanshell">
-a option = ${commandLine.getOptionValue("a")}
-b option = ${commandLine.getOptionValue("b")}
-c option = ${commandLine.getOptionValue("c")}
<bsh:script>
Properties sysprops = System.getProperties();
System.out.println("-testsysprop = " + sysprops.get("testsysprop"));
</bsh:script>
</jelly>
James-------http://radio.weblogs.com/0112098/


__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: [Jelly] Invoking methods (was: WhileTag)

Posted by Robert <rm...@bull-enterprises.com>.
Thanks again James and Bob :-)

- Rober

-----Original Message-----
From: James Strachan [mailto:james_strachan@yahoo.co.uk] 
Sent: Monday, October 07, 2002 11:24 AM
To: Jakarta Commons Developers List
Subject: Re: [Jelly] Invoking methods (was: WhileTag)

From: "Robert" <rm...@bull-enterprises.com>
> That clears it up for me, thanks James. One quick question, can the
> parameter of a method call be a variable in the context? Using your
> example:
> ${plantViewRemote.foo(a, b, 123, 'hello')}
>
> I'm guessing/assuming/hoping that the 'a' and 'b' can be variables in
> the JellyContext, while 'hello' in this case is a static parameter?

Yes. a and b are vairables in the JellyContext, 123 is a number and
'hello'
is a String. (Strings can use ' or " to encode themselves). Its actually
Jexl that does all the magic here.

James
-------
http://radio.weblogs.com/0112098/

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [Jelly] Invoking methods (was: WhileTag)

Posted by James Strachan <ja...@yahoo.co.uk>.
From: "Robert" <rm...@bull-enterprises.com>
> That clears it up for me, thanks James. One quick question, can the
> parameter of a method call be a variable in the context? Using your
> example:
> ${plantViewRemote.foo(a, b, 123, 'hello')}
>
> I'm guessing/assuming/hoping that the 'a' and 'b' can be variables in
> the JellyContext, while 'hello' in this case is a static parameter?

Yes. a and b are vairables in the JellyContext, 123 is a number and 'hello'
is a String. (Strings can use ' or " to encode themselves). Its actually
Jexl that does all the magic here.

James
-------
http://radio.weblogs.com/0112098/

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [Jelly] Invoking methods (was: WhileTag)

Posted by bob mcwhirter <bo...@werken.com>.
On Mon, 7 Oct 2002, Robert wrote:

> That clears it up for me, thanks James. One quick question, can the
> parameter of a method call be a variable in the context? Using your
> example:
> ${plantViewRemote.foo(a, b, 123, 'hello')}
> 
> I'm guessing/assuming/hoping that the 'a' and 'b' can be variables in
> the JellyContext, while 'hello' in this case is a static parameter?

	Yes.

		-bob


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>