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”);
%>
IT2Be
April 14, 2005, 2:18pm
2
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:
create a method on your form;
call the method from your hc with the name of the method as an argument (eg ‘globals.methodname()’);
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
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?
IT2Be
April 15, 2005, 9:20am
9
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…
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?
IT2Be
April 20, 2005, 12:36pm
12
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