Page 1 of 1

Headless Client Update/Refresh/Flush

PostPosted: Thu Apr 14, 2005 5:22 pm
by michaelwirz
Hello Headless-Users.

Experimenting with a Headless Setup I found the following
to be strange. I use a jsp to call a forms method. This
method returns a value back to the jsp. The return value
gets displayed.

On startup calls to the jsp are working allright.
When I modify my forms method to return a different value
it doesnt show up.
The only way to force the modifications to work is stopping servoy
and restarting it.

I'd appreciate a way to flush the jsp cache of servoys tomcat
instance and all related caches.
Does anyone know a way to do it? Or is it simply not yet possible?

Thank you,
Michael

PostPosted: Thu Apr 14, 2005 7:09 pm
by pbakker
It's just like starting a regular client:Changes done in developer do not show up in an allready started Client.

You have to "kill" the client. How to do this? Go to the admin pages and shutdown the Headless Client.

Paul

\\localhost:8080\servoy-admin

PostPosted: Thu Apr 14, 2005 7:36 pm
by michaelwirz
Ok, I found the Clients list and killed the headles client.
But how to start it again?
A follow-up web request didn't succeed.
Instead the developer throws a

java.lang.NullPointerException
java.lang.NullPointerException
at com.servoy.j2db.server.headlessclient.a.executeMethod(Unknown Source)
....

Seems to me that the Headless Client was killed "for life".

Thanks for your suggestions,
Michael

PostPosted: Thu Apr 14, 2005 7:48 pm
by pbakker
All the examples supplied by Servoy contain:
Code: Select all
   ISessionBean servoy_hc = (ISessionBean)session.getAttribute("servoy");
   if (servoy_hc == null)
   {
      servoy_hc = HeadlessClientFactory.createSessionBean(request,"example_headless_client_01");
      session.setAttribute("servoy",servoy_hc);
   }
   boolean ok = servoy_hc.setMainForm("customers");
   if (!ok)
   {
      servoy_hc = HeadlessClientFactory.createSessionBean(request,"example_headless_client_01");
      session.setAttribute("servoy",servoy_hc);
   }


The first "if" checks if servoy_hc is null. If this is the case, the connection has never been established and will then be created.

After that, they try to set the form, by:
Code: Select all
boolean ok = servoy_hc.setMainForm("customers");


Now, if this fails, it means the connection is not valid anymore, so, as you can see in the code a new connection is setup.

I assume you do not have this part.

Now, WATCH OUT: I think there's something missing in the Servoy examples. If a new connection is made, because
Code: Select all
boolean ok = servoy_hc.setMainForm("customers");
returned false, then after reconnecting, you need to set the form again, so, you have to call
Code: Select all
servoy_hc.setMainForm("customers");
again.
Hope this will get you going.

Paul

PostPosted: Thu Apr 14, 2005 8:22 pm
by michaelwirz
Paul,

thank you for your help. That really did it.
The additional hint (re-set the MainForm) solved the last remaining
problem: After beeing killed the Headless client needed two requests
to restart (First to get the session, second to successfully set the MainForm).

Everythings allright now.
Michael

PostPosted: Wed Apr 20, 2005 2:45 pm
by Jan Blok
Tip: use a new browser window when you killed a headless client during development (then there will be no problems) or even better make a logout function as seen in the latest example and don't kill the headlessclient

PostPosted: Wed Apr 20, 2005 2:46 pm
by pbakker
Jan, do you agree the Setting of the form is missing in the current examples?

I would think that if a session times out, then, without the extra form setting, the session can never reconnect

Paul

PostPosted: Wed Apr 20, 2005 4:55 pm
by Jan Blok
pbakker wrote:1) do you agree the Setting of the form is missing in the current examples?

2)I would think that if a session times out, then, without the extra form setting, the session can never reconnect


1: no, if no form is specified is uses the current main form (visibleForm parameter is for forms used on tabpanels and such)

2: no, the session is gone, also is the headless client instance, you have to recreate the headless client