views:

640

answers:

2

Hi,

I have a small project where I would like to generate dynamic data entry forms with a little bit of logic behind them.

A simple use case might be a Football resulting form, so you have a button for a goalscorer, and when clicked the user will be prompted for a player. The form will then send a message (probably to a webservice, but maybe a JMS queue) with the event data. eg Barcelona, Goal, Henry.

Then I want to create a similar form for tennis...

My idea was that I would create a webservice, where you define business logic. (events, components, actions you take etc.) Initially I thought I would send the sport definition from the webservice in xml. Then write an app to parse the xml and dynamically create the data entry screen.

I was initially thinking of writing a webservice and returning a xml data. (which will look awful) the rendering technology could then be flex/ flash and be a thin client.

Then I thought it would just as easy to create the forms as a java app using the swing application framework and that was the way to go.

Then I thought, well, rather than write a xml schema to describe the java forms, can I just serialise a java class and send that across the wire.

Once on that path, I am now wondering if should just a java framework, and the dynamic forms become class that are called by reflection.

I would love feedback on the above approaches, and how people on stackoverflow would solve this problem.

thanks

David.

A: 

I would avoid serialisation because it is a bit fragile, difficult to do safely and difficult to diagnose.

You say it's a small project, so does the metadata really have to pass from client to server? Would you not be much better off very simply writing the metadata (really code) as Java code?

(FWIW, my first commercial Java project was creating forms dynamically from a database specification (with regular additions). Previous to that I working with C++ running an interpreter for training systems. In both cases I would now (and for the last decade), have written them as Java. Don't be put off by people mumbling disapprovingly about "hardcoded".)

Tom Hawtin - tackline
A: 

I would consider XForms as well. It allows you to define both the data model and the UI as XML, and all you need to render it on the client side is a web browser. I assume the event would be submitted to a remote server, which makes the web browser as a natural choice.

This would enable you to generate the UI on the server based on what kind of sport event the user wants to report about, so you can easily add new forms, fix bugs, etc. without ever having to update the client software.

By the way, I don't understand your concerns about using XML. In my opinion it's a viable option for your use case.

Zsolt Török