cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Barbara Slupik <barbara_slu...@wro.vectranet.pl>
Subject Re: Stateless form.processForm
Date Thu, 13 Nov 2014 07:59:28 GMT
Hello

Do you have main_template.xml in your main-display-pipeline? Perhaps  
is is enough to define your form template without continuation, like  
<ft:form-template action="xxx" method="POST">. Also perhaps you don't  
need any processing in flow.js after form.showForm("main-display- 
pipeline", data).

Barbara

On 12 Nov 2014, at 17:22, Oliver Bienert wrote:

> Hello Cocoon users,
>
> I have created a cocoon 2.2 project. It uses cforms to present a  
> record
> from an h2 database to the user. I use continuations and a page  
> redirect
> to switch between records:
>
>        var form = new Form("cocoon://resource/internal/ 
> main_definition.xml");
>        form.createBinding("cocoon://resource/internal/ 
> main_binding.xml");
>        // Get data from database and update model
>        var bean = javaMain.fillBean(active);
>        // Load bean data into form
>        form.load(bean);
>        form.showForm("main-display-pipeline", data);
>        // After submit: Load form data into model
>        form.save(bean);
>        // Save bean to database
>        ...
>        // Issue a http redirect from client
>        cocoon.sendPage("redirect");
>
> In the sitemap I issue the redirect via redirect-to uri="..."
>
> Works so far but I don't really feel this the right way to present  
> records to a user.
> I mean I don't need a flow between pages so IMHO I don't need  
> continuation.
>
> I found out about sending a form stateless by using sendForm.
> When the form is submitted I could reattached data by  
> form.processForm(viewdata).
>
> Now here I'm stuck. How do I create an appropriate viewData map? I  
> googled several hours, but to no avail.
> I found a solution with javaflow, but that's not an option for me:
>
>        FormInstance form = new FormInstance("forms/ 
> formdefinition.xml");
>        Form model = (Form) form.getModel();
>        FormContext formContext = new FormContext(getRequest(),  
> Locale.getDefault());
>        model.process(formContext);
>
> How would I do that in Javascript?
>
> I tried something along those lines:
>
>        function processForm() {
>            var javaMain = cocoon.getComponent("mainbean");
>            var form = new Form("cocoon://resource/internal/ 
> main_definition.xml");
>            form.createBinding("cocoon://resource/internal/ 
> main_binding.xml");
>            var request = cocoon.request;
>            var bean = javaMain.newBean();
>            form.processForm(request);
>            form.save(bean);
>        }
>
> but get an error:
>
> org.mozilla.javascript.EvaluatorException:  
> "servlet:org.apache.cocoon.forms.impl.servlet+:/resource/internal/ 
> flow/javascript/Form.js", line 157: Java class  
> "org.apache.cocoon.environment.http.HttpRequest" has no public  
> instance field or method named "CocoonFormsInstance".
>
> How is this supposed to work?
>
> Regards Oliver
>
>
>
> ---------------------------------------------------------------------
> 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


Mime
View raw message