Call Zen Method from Zen Method

174 views
Skip to first unread message

Mike

unread,
Jan 17, 2008, 11:57:09 AM1/17/08
to InterSystems: Zen Community
Hello,

I'm having difficulty calling a Zen Method from within one. Can't
find it in the documentation. Any ideas?

Also, how to call a Javascript method from a Zen method might help
down the road.

Thanks,
Mike

Jill Singer

unread,
Jan 17, 2008, 1:21:41 PM1/17/08
to InterSys...@googlegroups.com
To call a zen method from another zen method, just put .. (dot dot) in
front of the method name:

<Method name="saveConditionSet">
<ClassMethod>1</ClassMethod>
<FormalSpec>conditionSet:HL7Conditions.ConditionSet1</FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
set sC = conditionSet.XMLExportToString(.exportStr)
set %session.Data("conditionXML") = exportStr
//every time the condition set is saved, something has changed in
it,
// and the
//cached query terms (the serialqueryform), if in session, has
just
// been invalidated
//(it needs to keep up with the form)--> thus: invalidate it:
do ..removeCachedSearchTerms()
quit $$$OK
]]></Implementation>
</Method>


<Method name="removeCachedSearchTerms">
<ClassMethod>1</ClassMethod>
<ZenMethod>1</ZenMethod>
<Implementation><![CDATA[ set %session.Data("serialQueryForm") =
"empty"
]]></Implementation>
</Method>


For your second request, I don't believe that it is possible, as the
javascript methods are on the client, and the zen methods are on the
server.

(the client can call to the server, but the other way around is more
difficult/not built in; but if there are counter-examples out there I
would definitely like to see them)

-Jill

Dale du Preez

unread,
Jan 17, 2008, 2:43:31 PM1/17/08
to InterSys...@googlegroups.com
It's possible to call some javascript in a Zen Method using &js<>, but I don't think this is quite what you are looking for.

Still, it's worth knowing that it's available.
-- 
Dale du Preez
Support Advisor
Dale.d...@intersystems.com
+1 (617) 621 0700
Please CC sup...@intersystems.com with regard to any active problems so that you can receive assistance should I be unavailable.

Jill Singer

unread,
Jan 17, 2008, 4:01:09 PM1/17/08
to Joel Solon, InterSys...@googlegroups.com

 

 


>Hi Jill,

>I'm assuming that the code you sent below comes from some sample you have. I believe that the 2nd method doesn't need to be a ZenMethod. Am I right?

Yes, it comes from code I’m working on; and that method doesn’t have to be a zen method

 

Also, from Dale:

Ø      It's possible to call some javascript in a Zen Method using &js<>, but I don't think this is quite what you are looking for.

When I tried the above method, I got the text inside the &js< > to print out to the screen; certainly not the affect that I was looking for.

 

--Jill

 

Joel Solon

unread,
Jan 17, 2008, 6:04:27 PM1/17/08
to InterSys...@googlegroups.com
ZenMethods are server-side methods that are called from the client, normally triggered by some event (like a button click). They package up the page's object model and send it to the server, and they use CSP's Hyper-Event (AJAX) functionality. Once the ZenMethod is running, if it needs to call another method on the server, even though the method is defined in a Zen class, it doesn't have to be a ZenMethod. It can be a method that runs on the server only (the Zen Method Wizard has this option). The 2nd method doesn't need to be a ZenMethod because it isn't going to be called from the client.

Calling a JavaScript method from a ZenMethod is impossible. The Caché server cannot call JavaScript code sitting in someone's browser somewhere in the world. The only way a ZenMethod can "run code" in a browser is to "return" some JavaScript statements, using embedded JavaScript (&js<>) that will be executed in the browser.

Anne

unread,
Jan 18, 2008, 2:39:22 AM1/18/08
to InterSystems: Zen Community
Hi,

from ZenMethod you can call javascript method as told
<zenPage.jsMethod();> if the calling method is used as ZenMethod.

Methods like %OnAfterCreatePage etc. are not ZenMethods and there you
can't call those jsMethods, but you need to live the work to some
other method like onloadHandler. No-ZenMethod works with jsMethods as
you told: code will be just like text at the top of page.

-Anne-

On Jan 18, 1:04 am, Joel Solon <joel.so...@intersystems.com> wrote:
> ZenMethods are server-side methods that are called from the client, normally triggered by some event (like a button click). They package up the page's object model and send it to the server, and they use CSP's Hyper-Event (AJAX) functionality. Once the ZenMethod is running, if it needs to call another method on the server, even though the method is defined in a Zen class, it doesn't have to be a ZenMethod. It can be a method that runs on the server only (the Zen Method Wizard has this option). The 2nd method doesn't need to be a ZenMethod because itisn'tgoing to be called from the client.
> Calling a JavaScript method from a ZenMethod is impossible. The Caché server cannot call JavaScript code sitting in someone's browser somewhere in the world. The only way a ZenMethod can "run code" in a browser is to "return" some JavaScript statements, using embedded JavaScript (&js<>) that will be executed in the browser.-----Original Message----- From:InterSys...@googlegroups.com[mailto:InterSys...@googlegroups.com] On Behalf Of Mike Sent: Thursday, January 17, 2008 11:57 AM To: InterSystems: Zen Community Subject: [InterSystems-Zen] Call Zen Method from Zen Method Hello, I'm having difficulty calling a Zen Method from within one. Can't find it in the documentation. Any ideas? Also, how to call a Javascript method from a Zen method might help down the road. Thanks, Mike

Dale du Preez

unread,
Jan 18, 2008, 8:46:10 AM1/18/08
to InterSys...@googlegroups.com
I very definitely got that wrong earlier. Thanks everyone for correcting me.

Dale
Reply all
Reply to author
Forward
0 new messages