View Full Version : Form submission question
ilpapabuono
02-08-2010, 01:55 AM
Hello all,
first of all I've to say that last Laszlo versions for swf10 are a gem.
When used toghether with Zinc 3.0, OL is capable of very interesting applications, expecially if over time one senses the particular idiosyncrasies of OL (in particular I refer to operations on more complex components that operate on large amounts of data. The timing play an important role and we must always think in "multithreading").
In my opinion it makes sense to explain a bit better both replication and how data-oriented components use it. Data Grid in particular needs a generous documentation rewriting..;) In every case: my compliments to you!
Now, the question: is it possible to use <form> to submt an entire "data structure" (in a certain sense "embedded" in the form itself) to a dataset (i mean: an inline dataset)? I often use SharedObject in order to allow off-line use of OL applications. My need is something able to save the entire data structure (or, perhaps, the generated submit request) in a bunch of xml nodes, or a string, save them/it in a SharedObject list of records and - once on-line - to resubmit them once at a time.
I've already made the base scripting, but this particular need is driven by the fact that OL app is "semi-dinamically generated" from a "php form generator" i already made.
The "dataset" structure is therefore not known in advance; it's a collection of "question/response" couples, that only needs to be glued toghether with a common, "root" id.
I hope I've been clear...not sure of this.
Thanks in advance
Federico Luciani
First it's easier if you have a SharedObject Editor to inspect your SharedObjects generated by OpenLaszlo.
SOL editor (http://www.alexisisaac.net/flash/articles/.sol-editor-local-shared-object--2.html)
See SharedObject XML type which allows OpenLaszlo datasets to be stored locally.
But note the risk that SharedObjects might be erased if cookies are purged by a user. So they should be used as a temporary storage until the user is back on line to synch with a server side database.
ilpapabuono
02-09-2010, 12:10 AM
First it's easier if you have a SharedObject Editor to inspect your SharedObjects generated by OpenLaszlo.
Thank you for your response.
I use it by over 3 months, with a "localcache.lzx" library found time ago on this forum. Very satisfied.
As already stated, I normally enclose the flash "SOLO" apps in .exe using Zinc 3.0, so the cookies problem is not so important.
The whole runs as a charm.
(it is an application that will be used in a hospital on handheld PCs, and serves to book meals. The data is downloaded from a database in XML format. Handle several hundred patients at a time, and a few hundred diets. It runs everything).
Unfortunately the code is proprietary and can not publish it. Moreover, the application domain is a niche and do not think that would be of interest.
The problem now is the collection of rating questionnaires. I had already made an application for questionnaires configuration in php, but obviously it only works online. I am therefore trying to reuse the logic that I put together for the management of off-line in the main application.
I extended the generator of form, which now generates an OpenLaszlo file; the problem is to temporarily store the various questionnaires. I repeat: the problem is not the storage itself and the logic, that' I've already made.
The problem is: how to store the fields as a simple set of name / value pairs, so simple. The openlaszlo mechanism of "form submit" would be ideal but, as I said, it normally operates on-line, I must then save the "POST"ed content in some way.
For what may happen next, my ideas are already clear enough.
Thank you
Federico
The problem is: how to store the fields as a simple set of name / value pairs, so simple.
Please read this old thread ..
storing xml dataset in SharedObject (http://forum.openlaszlo.org/showthread.php?t=9207&highlight=SharedObject+XMLobject)
and explain why storing an xml dataset in SharedObject does not meet your requirements.
ilpapabuono
02-09-2010, 06:34 AM
Please read this old thread ..
storing xml dataset in SharedObject (http://forum.openlaszlo.org/showthread.php?t=9207&highlight=SharedObject+XMLobject)
and explain why storing an xml dataset in SharedObject does not meet your requirements.
Explain in English is more difficult than I thought.
Besides, I said that I use SharedObject to 3 months (actually since I started using it almost 2 years ago).
I needed something about the mechanisms of <FORM> <SUBMIT> </ FORM> in Open Laszlo.
Thanks anyway.
Federico
senshi
02-09-2010, 07:42 AM
The openlaszlo mechanism of "form submit" would be ideal but, as I said, it normally operates on-line, I must then save the "POST"ed content in some way.
The <submit> elements just traverses all form elements and collects the element's values. The form elements are stored in the "formdata" attribute of <form>, so a simple collector which creates a data-element with the form's data may look like this:
<class name="collector" extends="node">
<method name="toXML" ><![CDATA[
var attrs = "";
var formdata = this.parent.formdata;
for (var k in formdata) {
attrs += formdata[k].toXML() + " ";
}
return lz.DataElement.stringToLzData("<form " + attrs + "/>");
]]></method>
</class>
<form>
<collector name="c" />
<!-- .... -->
</form>
A better approach for this task is presented in the Developer's Guide at Chapter 40 (http://www.openlaszlo.org/lps4.7/docs/developers/data_app.html#d0e106070). There is an example to demonstrate the usage of the "new:/" syntax for datasets to build dynamic datasets with arbitrary content. The generated dataset can later be serialized by calling the "serialize()" and deserialized by calling "lz.DataElement.stringToLzData(..)".
<canvas debug="true">
<window>
<form datapath="new:/questionnaire">
<statictext>What is your gender?</statictext>
<radiogroup name="gender" datapath="@gender">
<radiobutton>Male</radiobutton>
<radiobutton>Female</radiobutton>
</radiogroup>
<statictext>What is your favorite vacation spot?</statictext>
<radiogroup name="place" datapath="@place">
<radiobutton>Hawaii</radiobutton>
<radiobutton>Paris</radiobutton>
<radiobutton>Jamaica</radiobutton>
</radiogroup>
<button isdefault="true" onclick="parent.datapath.updateData(); Debug.write(parent.datapath.data.serialize())">submit</button>
</form>
</window>
</canvas>
ilpapabuono
02-09-2010, 08:45 AM
Exactly what I were searching for.
Thanks VERY much.
Federico
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.