Adding a record to Servoy solution from a website

Questions and answers on developing, deploying and using plugins and JavaBeans

Adding a record to Servoy solution from a website

Postby OliverJenkins » Thu Sep 16, 2004 11:25 am

We currently have a Servoy solution in place which is being used to handle our back-office order fullfillment. We also run a large eCommerce store running of ePages. What I need to impliment is a system where by an order is sent over to Servoy and added as a new order in Servoy.

From looking around this forum and documentation I get the idea that writing a few servlets is the way to go. I can construct a request or a SOAP call to Servoy, but I don't know where to begin writing a Servlet.

I have the experience to actually write passible JavaScript (and some Java from about 6 years ago), but I have no Servoy, Filemaker, Servlet experience. Oh and by the way I've been given about three weeks to get it up and running!!

Can someone point me in the right direction, I could do with

1. A basic idea (development enviroment) of how to test servlets and beans ie. what directory they go in to, how to get them to compile and run (do I need to/how do I restart servoy)

2. Details of relevent APIs, and functions to INSERT data into a table in servoy from the bean.

From what I've seen of Servoy its seems impressive. Hopefully once this project is completed I will get a chance to have a look at it. Until then I hope someone can help me with this little Servlet?

Thanks in advance

Oliver
OliverJenkins
 
Posts: 4
Joined: Thu Sep 16, 2004 10:58 am

Postby Harry Catharell » Thu Sep 16, 2004 9:25 pm

Hi Oliver,

Whilst this may turn out to be a stupid question, I'll ask it anyway.

Is there any reason why you can't point your Servoy solution at the database which runs your ecommerce website and either :
1) Use Servoy to directly interact with the order table data which already exists and manipulate it ?
2) Use an opening method in the Servoy solution to query for the recent orders or modified orders and run an update to local files ?

I spent 3 man-days defining a webservice and windowsservice to move data backwards and forwards locally to a web site and then recreated the whole thing in 30 minutes using Servoy !

Cheers
Harry
Harry Catharell
 
Posts: 812
Joined: Fri Sep 26, 2003 10:23 am
Location: Milton Keynes, England

Postby OliverJenkins » Fri Sep 17, 2004 5:12 pm

Harry

Thanks for the reply,

We can't do a direct connection to the database on the server as our hosting provider is not keen on opening up the database to Servoy. They cite reliability as the reason. We use a specialised hosting platform, and changing the host is not an option as we are happy with them.

Also part of the spec I've been given states that every time an order is placed it should be sent directly to Servoy. We don't want a load of orders to be processed in one batch, but spread the load.

Hey I'm just a coder!

I don't mind spending a week trying to get it to work, as long as I can get it to work. So even if you can point me in the right direction I would be grateful.

Thanks for your reply

Oli
OliverJenkins
 
Posts: 4
Joined: Thu Sep 16, 2004 10:58 am

Postby Riccardino » Sat Sep 18, 2004 10:09 am

OliverJenkins wrote:Harry

Thanks for the reply,

We can't do a direct connection to the database on the server as our hosting provider is not keen on opening up the database to Servoy. They cite reliability as the reason. We use a specialised hosting platform, and changing the host is not an option as we are happy with them.

Ciao, Oliver

would your provider accept to let you directly interact with a replicated or a proxy table?
If so, all you have to do is to set the main database to write data on the proxy table every time an order is entered, in order to keep the two tables in sync.

Hope it helps
ciao, ric
User avatar
Riccardino
 
Posts: 911
Joined: Thu Apr 24, 2003 11:42 am
Location: Ferrara, Italy

Postby OliverJenkins » Mon Sep 20, 2004 1:07 pm

I've asked the hosting company, and they are asking why I can't just send the data over to Servoy.

We currently have a similar system in place which operates from the site to a filemaker backend. I thought Servoy could do something similar?

This works, when it does fall over (rarely) their are procedures in place to deal with issues and problems are picked up on.

Three days coding time to develop a solution to allow this does not bother me. I have been waiting that long already!

Can someone point me to a brief tutorial or guide on how to get a Servlet to compile and run?

Oli
OliverJenkins
 
Posts: 4
Joined: Thu Sep 16, 2004 10:58 am

Postby Harry Catharell » Mon Sep 20, 2004 2:06 pm

Hi Oli,

Me again !

Sorry if I seem to be asking as opposed to advising.....

If you are not fully conversant with Servoy but are more fluent with what has been done to work with FileMaker, you may not be aware that Servoy is purely the RAD tool used to develop the solution front end.

Thus the database is completely external to the presentation and Logic layers - which is completely unlike FM.

With that in mind is there a better way then for you to write the order directly to the database from the web site at the point of ordering.

This will then be picked up by Servoy front end which simply points to the records in the database.

Sorry if you are already aware of this but thought it might be good to point this out - just in case.

Harry
Harry Catharell
 
Posts: 812
Joined: Fri Sep 26, 2003 10:23 am
Location: Milton Keynes, England

Postby michaelwirz » Mon Sep 20, 2004 2:40 pm

Hi Oli!

I recently ran into the same problem. We are using servoy to
put some data in a database which consists - as you might
have expected - of some tables with relations. Few relations
tend to be more complex then others. I.e. there is a user and his
n std telephone numbers, m std emails, k logins for p projects and
stuff like that. When creating a user record we have to store
defaults in some of the linked tables.

Since we are using servoy to create user database records as
well as a web fontend, we wondered if its possible to keep the code
for the complex operations in one place (it would be awful to deploy
changes in more than one place).

So I sat down and wrote a Servlet plugin for servoy, providing
a kind-of-web-service "webConnector" access to call methods
of a specific servoy solution via http requests. I recently got to
know that the servoy developers are
aware of the problems arising when thinking about that but have
scheduled development for an "easy-to-use" convinient interface
for 4th quarter 20004 or 1st quarter of 2005.

My "webConnector" works like this:
- Open a Solution in the servoy server, initializing a plugin with
a "callback" method. This can be done on solution start.
- The plugin itself registers with the tomcat of the servoy server
providing access to its handlers (doGet, doPost). Within these
I parse the requests parameters and URL packaging them for the
callback.
- The callback is called from the servlet with the parameter names
and values as arguments. At now this works completely
asynchronously, i.e. you have no chance of getting any result code
or the like. This is still work in progress (might be solved by thread
synchronisation or a row in a database table).

This has just been prototype development but might be useful
for your problem. If you are interested I'd mail you a jar and example
solution.

Greetings from near Munich, Germany,
Michael Wirz
michaelwirz
 
Posts: 23
Joined: Mon Sep 13, 2004 1:47 pm

Postby OliverJenkins » Mon Sep 20, 2004 3:33 pm

michaelwirz

Excellent, this is exactly the start I need. Could you post the details of this here please, alternativly email them to Oliver_Jenkins63@hotmail.com

Thanks

Oli
OliverJenkins
 
Posts: 4
Joined: Thu Sep 16, 2004 10:58 am

Postby pbakker » Mon Sep 20, 2004 3:51 pm

Hi Michael,

More people have been attempting to do what you did. If you would be willing to share..... :D

It's possible to upload the jars on the forum.

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

Postby michaelwirz » Tue Sep 21, 2004 3:53 pm

Hi Oli, Paul,

Thank you for your interest. I'd really like to know what you think
about this stuff.

Attached you can find two files: A sample solution with one form
(connected to a database table dummy) and a jar containing the
Servlet-Plugin.
I am new to servoy, hopefully you are able to get things working
with these two files. I think you have to copy the jar in the plugin
directory and import the solution attaching it to a dummy table. that
should work.

Afterwards try the following:
- Start servoy opening the attached solution.
- Open a browser checking the URL:
http://localhost:8080/servoy-service/we ... aram=value
You will see some parsed parameters and that a "func" is null.
- Now check the button "call plugin" of the solution. This will
initialize the plugins web-Callback.
- Again send the http request and you will get a dialog in servoy
telling you the callback arrived, displaying one of the params.

The above steps show how it works: Initialize a callback (currently
only one
single callback is possible), then call it from the servlet. The
parameters are optional, they are packaged in JAVA Arrays which
have to be sorted into javascript arrays in your solution.

There are many improvements left:
- Provide a number of callbacks (using a hash or something).
Switch via the servlet-URL between the different callbacks.
- Provide a mechanism to distinguish different solutions methods.
- Build a synchonisation to keep track whether the method
succeeded or failed. (This is currently not possible because the
method call is inserted asynchronuously into the swing event queue)

The source is there in the jar. If some of you are willing to improve
or enhance this stuff for their needs I'd kindly appreciate to have
a look. If this prototype is interesting enough for a few of other
developers I'd maintain a repository to keep track of the development. I used eclipse for development and encourage
you to do the same since eclipse in my opinion is a very
powerful and easy development environment.

Thank you for your opinions. If there are questions feel free to ask.
Till friday I'm here, afterwards I'll be travelling three weeks through
south-africa.

Best regards,
from near Munich,
Michael Wirz
Attachments
servoy_plugin_test.servoy
Sample solution for a test/demo of the "webConnector" plugin
(3.95 KiB) Downloaded 408 times
MyServoyClientServerPlugin.jar
The "webConnector" plugin jar
(9.43 KiB) Downloaded 428 times
michaelwirz
 
Posts: 23
Joined: Mon Sep 13, 2004 1:47 pm

Postby IT2Be » Wed Sep 22, 2004 8:21 pm

Michael, I just tested your plugin and it does almost what I need it to do!

The only thing missing is a reply like you stated yourself. I didn't have a look at the source yet but I fear this thing is not my cup of tea (yet)...

Further I would like to get rid of the return message in the webbrowser...

I tweeked your test solution a little here and there to make it possible to address a method now. See for yourself. The plugin is unchanged.

Code: Select all
http://localhost:8080/servoy-service/webConnector/showDialog/?x=1000&y=5¶m=yes

Code: Select all
http://localhost:8080/servoy-service/webConnector/doBeep/?loop=5
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 IT2Be » Wed Sep 22, 2004 9:20 pm

Another issue is the fact that this seems to be a client plugin with server functionality. That means you have to have a local client running. Maybe necessary anyhow but then there has to be a check in the plugin to see if it is running on the server. Otherwise the client will load it with an error message
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 Sep 23, 2004 1:59 pm

You are absolutely right!
I discussed this with Jan Blok from Servoy.
They are planning to implement support for this problem
using a more native approach. He told me of a socalled
HeadlessClient, which allows access to many of a solutions
properties and methods.
Unfortunately the implemntation is scheduled for Q4/04 or
Q1/05. Until then we have to work on this workaround
replacing it with an easy and beautiful piece of code when
it is available.

Best regards,
Michael
michaelwirz
 
Posts: 23
Joined: Mon Sep 13, 2004 1:47 pm


Return to Plugins and Beans

Who is online

Users browsing this forum: No registered users and 39 guests

cron