You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Michael Ralston <mi...@ralston.id.au> on 2006/06/30 02:11:52 UTC
content managed dynamic cforms
I am attempting to create a Lenya module which displays a CForm, then
sends an email with the data entered into the form. A basic
Contact/Sendmail type form. I am trying to make this form content
managed so that the fields can be edited, new fields added etc.
The problem I am having is trying to bind the form to a java object to
send the email. Is it possible to do this binding without a specific
form binding xml for each instance of my contact form? Is there a way to
either create a generic binding which will send all form fields to the
same java method? IE, some sort of custom binding which does not specify
the form field id, but simply passes all form fields to something like:
void setData(String fieldId, String fieldValue);
Or alternatively is there a way to programmatically iterate over the
form fields, name and value? The 'forms.formmodel.Form' object supports
getChildren which returns an iterator over the widgets, but this is not
the class of object which is created in either a flowscript or javaflow
Form constructor. Is it possible to obtain an instance of
forms.formmodel.Form from a form which has been submitted or am I
barking up the wrong tree?
Any help appreciated
Michael R
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: content managed dynamic cforms
Posted by Dirk Meister <di...@gmail.com>.
Hello,
i'm working an a cocoon app where i have a comparable problem (a kind
of dynamic data model),
My approach was that i generate the binding file on the fly (which is
in my case was easy because i use a xmldb as data storage and can work
with xml transformations).
But it must be possible generate a form binding in which all fields are
bond to all fields of the java (getter and setter) for example by
getting all fields of the form (definition) and all fields in the java
object.
Greetings
Dirk
Am 30.06.2006 um 02:11 schrieb Michael Ralston:
> I am attempting to create a Lenya module which displays a CForm, then
> sends an email with the data entered into the form. A basic
> Contact/Sendmail type form. I am trying to make this form content
> managed so that the fields can be edited, new fields added etc.
>
> The problem I am having is trying to bind the form to a java object to
> send the email. Is it possible to do this binding without a specific
> form binding xml for each instance of my contact form? Is there a way
> to either create a generic binding which will send all form fields to
> the same java method? IE, some sort of custom binding which does not
> specify the form field id, but simply passes all form fields to
> something like: void setData(String fieldId, String fieldValue);
>
> Or alternatively is there a way to programmatically iterate over the
> form fields, name and value? The 'forms.formmodel.Form' object
> supports getChildren which returns an iterator over the widgets, but
> this is not the class of object which is created in either a
> flowscript or javaflow Form constructor. Is it possible to obtain an
> instance of forms.formmodel.Form from a form which has been submitted
> or am I barking up the wrong tree?
>
> Any help appreciated
>
> Michael R
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: content managed dynamic cforms
Posted by Michael Ralston <mi...@ralston.id.au>.
Toby wrote:
> Michael Ralston wrote:
>
>> It looks like you've basically hard coded your fields into the
>> flowscript. This is what I wanted to avoid.
>>
>
> Can't you just iterate over the fields with plain javascript?
>
I ended up doing it with javaflow with the following...
in my flow:
mailer.setForm(form.getModel());
inside mailer:
public void setForm(Widget widget) {
for (Iterator<Widget> i = ((Form)widget).getChildren();
i.hasNext();) {
Widget w = i.next();
String key = w.getFullName();
String value = w.getValue().toString();
map.put(key, value);
}
}
Michael R
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: content managed dynamic cforms
Posted by Toby <to...@linux.it>.
Michael Ralston wrote:
> It looks like you've basically hard coded your fields into the
> flowscript. This is what I wanted to avoid.
Can't you just iterate over the fields with plain javascript?
var model = form.getModel()
var body = ''
for (var field in model)
body += field + ':\t' + model[field] + '\n'
cocoon.sendPage("sendpage", {subject: 'Contact', body: body})
Toby
--
Signed/encrypted mail welcome. GPG/PGP Key-Id: 0x15C5C2EA
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: content managed dynamic cforms
Posted by Kamal Bhatt <kb...@tt.com.au>.
OK, I see your problem. I agree it is cruddy. I am surprised that you
cannot getChildren from the form. It has been a while since I looked
into those classes. Sorry for the misunderstanding.
Cheers.
Michael Ralston wrote:
> Kamal Bhatt wrote:
>>
>> It breaks the cocoon model, but it works. Maybe you can make the
>> parameter for body into another pipeline, turn the bizdata into XML
>> and use and XSLT to process the resultant XML. If you do, give me a
>> yell because now that I think about it that is a pretty crappy way of
>> doing things.
>>
> It looks like you've basically hard coded your fields into the
> flowscript. This is what I wanted to avoid. I'd like to make it
> possible to add/remove fields in lenya, then the code can obtain the
> data submitted in the form without any previous knowledge of what
> fields it will be given. This way I can use the same
> javaflow/flowscript code for every contact form, no matter what fields
> that form has.
>
> Michael
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
--
Kamal Bhatt
--
Disclaimer: This email is confidential and may contain privileged information for the sole use of the person or business to which it is addressed. If you are not the intended recipient, please notify the sender by return e-mail or phone as you must not view, disseminate, distribute or copy this email without our consent. We do not accept any liability in connection with any computer virus, data corruption, incompleteness, or unauthorised amendment of this email. It is the sole responsibility of the receiver to scan for viruses before opening.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: content managed dynamic cforms
Posted by Michael Ralston <mi...@ralston.id.au>.
Kamal Bhatt wrote:
>
> It breaks the cocoon model, but it works. Maybe you can make the
> parameter for body into another pipeline, turn the bizdata into XML
> and use and XSLT to process the resultant XML. If you do, give me a
> yell because now that I think about it that is a pretty crappy way of
> doing things.
>
It looks like you've basically hard coded your fields into the
flowscript. This is what I wanted to avoid. I'd like to make it possible
to add/remove fields in lenya, then the code can obtain the data
submitted in the form without any previous knowledge of what fields it
will be given. This way I can use the same javaflow/flowscript code for
every contact form, no matter what fields that form has.
Michael
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: content managed dynamic cforms
Posted by Kamal Bhatt <kb...@tt.com.au>.
In the JS:
....
var model = form.getModel();
var body = "Title: " + model.title + "\n";
body = body + "Given name: " + model.givenName + "\n";
body = body + "Surname: " + model.surname + "\n";
body = body + "CONTACT DETAILS:\n";
body = body + "Address: \n";
body = body + model.addr + "\n";
body = body + model.state + " " + model.country + " " + model.suburb
+ " " + model.postcode + "\n\n";
body = body + "Home Phone: " + model.homePhone + "\n";
body = body + "Work Phone: " + model.workPhone + "\n";
body = body + "Email :" + model.email + "\n";
...
var subject = "Request";
var bizdata = {
"body": body,
"subject" : subject
}
cocoon.sendPage("call-success-pipeline", bizdata);
...
The pipleline for success-pipeline (which is what eventually gets
called) uses the sendmail action. The body is retrieved like so:
<map:act type="sendmail">
...
<map:parameter name="subject" value="{flow-attr:subject}"/>
<map:parameter name="body" value="{flow-attr:body"}"/>
...
It breaks the cocoon model, but it works. Maybe you can make the
parameter for body into another pipeline, turn the bizdata into XML and
use and XSLT to process the resultant XML. If you do, give me a yell
because now that I think about it that is a pretty crappy way of doing
things.
Cheers.
Kamal
Michael Ralston wrote:
> So how did you get the form data into the email? Could you give me an
> example?
>
> Michael
>
> Kamal Bhatt wrote:
>>
>> We did this. We did not bother with the XML, just construct the
>> subject, pass it to the sitemap and send the mail.
>>
>> Michael Ralston wrote:
>>> I am attempting to create a Lenya module which displays a CForm,
>>> then sends an email with the data entered into the form. A basic
>>> Contact/Sendmail type form. I am trying to make this form content
>>> managed so that the fields can be edited, new fields added etc.
>>>
>>> The problem I am having is trying to bind the form to a java object
>>> to send the email. Is it possible to do this binding without a
>>> specific form binding xml for each instance of my contact form? Is
>>> there a way to either create a generic binding which will send all
>>> form fields to the same java method? IE, some sort of custom binding
>>> which does not specify the form field id, but simply passes all form
>>> fields to something like: void setData(String fieldId, String
>>> fieldValue);
>>>
>>> Or alternatively is there a way to programmatically iterate over the
>>> form fields, name and value? The 'forms.formmodel.Form' object
>>> supports getChildren which returns an iterator over the widgets,
>>> but this is not the class of object which is created in either a
>>> flowscript or javaflow Form constructor. Is it possible to obtain an
>>> instance of forms.formmodel.Form from a form which has been
>>> submitted or am I barking up the wrong tree?
>>>
>>> Any help appreciated
>>>
>>> Michael R
>>>
>>>
>
--
Kamal Bhatt
--
Disclaimer: This email is confidential and may contain privileged information for the sole use of the person or business to which it is addressed. If you are not the intended recipient, please notify the sender by return e-mail or phone as you must not view, disseminate, distribute or copy this email without our consent. We do not accept any liability in connection with any computer virus, data corruption, incompleteness, or unauthorised amendment of this email. It is the sole responsibility of the receiver to scan for viruses before opening.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: content managed dynamic cforms
Posted by Michael Ralston <mi...@ralston.id.au>.
So how did you get the form data into the email? Could you give me an
example?
Michael
Kamal Bhatt wrote:
>
> We did this. We did not bother with the XML, just construct the
> subject, pass it to the sitemap and send the mail.
>
> Michael Ralston wrote:
>> I am attempting to create a Lenya module which displays a CForm, then
>> sends an email with the data entered into the form. A basic
>> Contact/Sendmail type form. I am trying to make this form content
>> managed so that the fields can be edited, new fields added etc.
>>
>> The problem I am having is trying to bind the form to a java object
>> to send the email. Is it possible to do this binding without a
>> specific form binding xml for each instance of my contact form? Is
>> there a way to either create a generic binding which will send all
>> form fields to the same java method? IE, some sort of custom binding
>> which does not specify the form field id, but simply passes all form
>> fields to something like: void setData(String fieldId, String
>> fieldValue);
>>
>> Or alternatively is there a way to programmatically iterate over the
>> form fields, name and value? The 'forms.formmodel.Form' object
>> supports getChildren which returns an iterator over the widgets, but
>> this is not the class of object which is created in either a
>> flowscript or javaflow Form constructor. Is it possible to obtain an
>> instance of forms.formmodel.Form from a form which has been submitted
>> or am I barking up the wrong tree?
>>
>> Any help appreciated
>>
>> Michael R
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>>
>>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: content managed dynamic cforms
Posted by Kamal Bhatt <kb...@tt.com.au>.
We did this. We did not bother with the XML, just construct the subject,
pass it to the sitemap and send the mail.
Michael Ralston wrote:
> I am attempting to create a Lenya module which displays a CForm, then
> sends an email with the data entered into the form. A basic
> Contact/Sendmail type form. I am trying to make this form content
> managed so that the fields can be edited, new fields added etc.
>
> The problem I am having is trying to bind the form to a java object to
> send the email. Is it possible to do this binding without a specific
> form binding xml for each instance of my contact form? Is there a way
> to either create a generic binding which will send all form fields to
> the same java method? IE, some sort of custom binding which does not
> specify the form field id, but simply passes all form fields to
> something like: void setData(String fieldId, String fieldValue);
>
> Or alternatively is there a way to programmatically iterate over the
> form fields, name and value? The 'forms.formmodel.Form' object
> supports getChildren which returns an iterator over the widgets, but
> this is not the class of object which is created in either a
> flowscript or javaflow Form constructor. Is it possible to obtain an
> instance of forms.formmodel.Form from a form which has been submitted
> or am I barking up the wrong tree?
>
> Any help appreciated
>
> Michael R
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
--
Kamal Bhatt
--
Disclaimer: This email is confidential and may contain privileged information for the sole use of the person or business to which it is addressed. If you are not the intended recipient, please notify the sender by return e-mail or phone as you must not view, disseminate, distribute or copy this email without our consent. We do not accept any liability in connection with any computer virus, data corruption, incompleteness, or unauthorised amendment of this email. It is the sole responsibility of the receiver to scan for viruses before opening.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org