calling global methods from jsp

Hello!

I just looked at the Headless Client Framework. I got things working.
I like its easy and clean design. I successfully called form-methods.
Is it right that it is not possible to call methods of “non-visible” forms?

How do I proceed when I want to call global methods?

Thanks for help.
Michael Wirz,
Munich

My working example jsp is
(Solution: hc_test, Form: hc_test, Method: hc_test)

<%@ page import = “java.util." %>
<%@ page import = "com.servoy.j2db.server.headlessclient.
” %>
<%@ page import = “com.servoy.j2db.dataprocessing.IDataSet” %>
<%@ page errorPage=“errorpage.jsp” %>

Servoy Headless Client Test <% ISessionBean servoy_hc = (ISessionBean)session.getAttribute("servoy"); if (servoy_hc == null) { servoy_hc = HeadlessClientFactory.createSessionBean(request,"hc_test"); session.setAttribute("servoy",servoy_hc); }

boolean ok = servoy_hc.setMainForm(“hc_test”);

String theTable = null;
theTable = (String)servoy_hc.executeMethod(“hc_test”, hc_test", new Object{new Integer(17)});

if (theTable!=null) out.println(theTable);
else out.println(“theTable is null”);
%>

I think it is not possible to call global methods ‘just like that’ because you indeed need a visible form.

What you could do is this:

  1. create a method on your form;
  2. call the method from your hc with the name of the method as an argument (eg ‘globals.methodname()’);
  3. include the code eval(arguments[0]) in your method;

The method will be called like you wish…

Hope this helps a little,

Marcel

Marcel,

thanks for pointing this out. I decided to create a special form
“headless”. It holds all headless-methods. This works for my setup.

bye,
Michael

Accordig to the API, it should be possible to execute a global method, and I would think directly.

I ran into this while testing stuff, but worked around it by making formmethods, but still, I think it should work.

Can Servoyians comment?

Paul

Hi Paul!

I scanned through the API as well but didnt find anything
I thought would be useful.
Could you give me a hint to the API-call you suspect?

Michael

See the explanation for function executeMethod @ http://developer.servoy.com/docs/headle … index.html

Thanks.
– Thats been easy. I just overlooked it…

I tried executeMethod(null,“globals.my_own_global_method”,args)
without success.

Yep, tried it as well, doesn’t work. Now, the question is: Should it? :lol:

hmm, that’s why I replied that I thought it wouldn’t work because I tested this also :-)

So, we all tested it, it doesn’t work and we do not know if it should… :lol:

How to solve this dilemma… :?:

If there is a need to call global methods, I think we can make it so, is it badly needed?

Jan, if it would imply that we can avoid to call a form… Then YES…

Yes, would definetly like to be able to call them directly, instead of enabling them through the creation of forwarding form methods

Paul