calling global methods from jsp

The forum to discuss the Headless version of Servoy. Web, Java and Servlet development questions can all be posted here.

calling global methods from jsp

Postby michaelwirz » Thu Apr 14, 2005 2:36 pm

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" %>

<html>
<head>
<title>Servoy Headless Client Test</title>
</head>
<body>
<%
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");
%>
</body>
</html>
michaelwirz
 
Posts: 23
Joined: Mon Sep 13, 2004 1:47 pm

Postby IT2Be » Thu Apr 14, 2005 4:18 pm

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 J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Postby michaelwirz » Thu Apr 14, 2005 5:08 pm

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
michaelwirz
 
Posts: 23
Joined: Mon Sep 13, 2004 1:47 pm

Postby pbakker » Thu Apr 14, 2005 5:17 pm

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
pbakker
 
Posts: 2821
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Postby michaelwirz » Thu Apr 14, 2005 7:01 pm

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
michaelwirz
 
Posts: 23
Joined: Mon Sep 13, 2004 1:47 pm

Postby pbakker » Thu Apr 14, 2005 7:13 pm

See the explanation for function executeMethod @ http://developer.servoy.com/docs/headle ... index.html
pbakker
 
Posts: 2821
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Postby michaelwirz » Thu Apr 14, 2005 7:29 pm

Thanks.
-- Thats been easy. I just overlooked it....

I tried executeMethod(null,"globals.my_own_global_method",args)
without success.
michaelwirz
 
Posts: 23
Joined: Mon Sep 13, 2004 1:47 pm

Postby pbakker » Thu Apr 14, 2005 7:32 pm

Yep, tried it as well, doesn't work. Now, the question is: Should it? :lol:
pbakker
 
Posts: 2821
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Postby IT2Be » Fri Apr 15, 2005 11:20 am

hmm, that's why I replied that I thought it wouldn't work because I tested this also :-)
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Postby pbakker » Fri Apr 15, 2005 12:07 pm

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

How to solve this dilemma.... :?:
pbakker
 
Posts: 2821
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Postby Jan Blok » Wed Apr 20, 2005 2:33 pm

If there is a need to call global methods, I think we can make it so, is it badly needed?
Jan Blok
Servoy
Jan Blok
 
Posts: 2684
Joined: Mon Jun 23, 2003 11:15 am
Location: Amsterdam

Postby IT2Be » Wed Apr 20, 2005 2:36 pm

Jan, if it would imply that we can avoid to call a form... Then YES...
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Postby pbakker » Wed Apr 20, 2005 2:44 pm

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

Paul
pbakker
 
Posts: 2821
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands


Return to Servoy Headless Client

Who is online

Users browsing this forum: No registered users and 2 guests

cron