You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Peter Kröpfl <fo...@groebi.com> on 2004/10/06 21:07:33 UTC

cforms + flow contination problem

Hi,

I am trying to do the following:

After filling out a form and submitting it i want to show all the data submitted.
If the user decides everything is correct he can klick OK and his data will be
saved.
So far, so good.
However, if the data is not correct (e.g. misspelled word, etc) there should be
a back button/link.

This back button/link is the Problem:

If I do a:
<form action="${cocoon.continuation.parent.id}.continue" method="POST">
to go back it goes back to the previous form, but all the field widgets are
empty and a validation error for each field is shown.

If I go back using the browser back button, everything is nice: all fields
(except password fields) show the previously entered data.

I even tried:
<input type="submit" value="Zurück" onClick="history.go(-1)" />
to imitate the behaviour of the browser back button, but with no luck. Same
empty fields and validation errors as with cocoon.continuation.parent.id.

Is this normal behaviour?
If yes is there a way to fill those cocoon forms with data?


I am using CForms for the forms.
JX Templates to show the data for a second check
and Flow to handle the stuff in between.




here is my flow file:
--------------------

cocoon.load("resource://org/apache/cocoon/forms/flow/javascript/Form.js");

function registration() {
	
	var form = new Form("forms/registration.xml");
	form.showForm("registration-display-pipeline");

	var model = form.getModel();
	
	var helper = new Helper();
	var timestamp = helper.timestamp();
     
   var person = new Person(model.username, model.password, model.email,
model.firstname, model.sirname, model.address, model.zip, model.country,
model.birthday, model.phone, timestamp);
    
			
	var bizData = person.Object2bizData();

// show data again and ask if everything is OK, if not go back
	
	var form_confirm = new Form("forms/registration_confirm.xml");
	form_confirm.showForm("registration-confirm-pipeline", bizData);
	
// save data to db
	person.create();

	cocoon.sendPage("registration-success-pipeline", person);
}



//---------- the form that redisplays the data and provides the go back button:
<?xml version="1.0" encoding="ISO-8859-1"?>
<page>
  <!-- This is a test page only implementing the "Go Back and Edit" button -->
   <title>Registration-Confirm</title>

 	<form action="${cocoon.continuation.parent.id}.continue" method="POST"> 
 	<!-- <form> -->
 	<table>
    <tr>
    	<td>
    	
    	<textbold>Confirm:</textbold>
    	<text>
    	Is this data correct?
    	</text>
    	
    	Username: ${username};
    	<br/>
    	Password: ${password};
    	<br/><br/>
    	
	</td>
	</tr>
	
	<tr>
	<td align="center">
		<!-- <input type="submit" value="Go Back" onClick="history.go(-1)" /> -->
		<input type="submit" value="Go Back" />
   </td>
    </tr>
    </table>
    </form>

</page>



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


retrieving webdav metadata

Posted by Francois Jannin <fr...@etu.enseeiht.fr>.
Hi all,

I'm trying to use Cocoon with Webdav server (Slide), and i can't figure 
out how to retrieve custom metadatas i put on collections and resources. 
Traversable generator just returns a set of collection elements that do 
not reflect my properties. Is there a way to customize request to webdav 
thru Cocoon ? And if so, how could i proceed ?

Thanks.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: cforms + flow contination problem

Posted by Philipp Rech <ph...@gmx.de>.
hallo Peter,

maybe you should put

<input type="button" value="Back via JS" onClick="history.go(-1)" />

or...	

<a href="javascript: history.go(-1)">Back via JS Link</a>

into the XSLT Stylesheet (for JX Template transformation). Works fine for me
and data gets redisplayed without the <fd:output /> element. NOTE: passwords
won't get redisplayed though!

ciao,
Philipp


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: cforms + flow contination problem

Posted by Peter Kröpfl <fo...@groebi.com>.
 
> I avoid this by reloadind my form datas from a bean 

I don't use beans yet (maybe there will be no way without doing beans)

> (form.load(some_bean);), if you don't use a bean, maybe you can try like 
> this, then i hope you reload the form.
> 
> var form = new Form("forms/registration.xml");
> var model = form.getModel(); //1
> form.load(model); //2
> form.showForm("registration-display-pipeline");
> var model = form.getModel();

Unfortunately this produces an error:

org.mozilla.javascript.EvaluatorException:
"resource://org/apache/cocoon/forms/flow/javascript/Form.js", line 166: Invalid
JavaScript value of type org.mozilla.javascript.UniqueTag


it is the form.load(model) that causes the problems.

var form = new Form("forms/registration.xml");
var model = form.getModel(); //1
// form.load(model); //2
form.showForm("registration-display-pipeline");
var model = form.getModel();

would load without errors, but without the functionality too. ;(


peter




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: cforms + flow contination problem

Posted by pguillard <pg...@soociety.com>.
I avoid this by reloadind my form datas from a bean 
(form.load(some_bean);), if you don't use a bean, maybe you can try like 
this, then i hope you reload the form.

var form = new Form("forms/registration.xml");
var model = form.getModel(); //1
form.load(model); //2
form.showForm("registration-display-pipeline");
var model = form.getModel();
.....

Phil



Peter Kröpfl wrote:

>>I don't really have a full understanding on continuations but with JX  i 
>>use continue.#{$cocoon/continuation/parent/parent/id}, i  mean pointing 
>>one more parent gets me back to the page before. To be able to be sure 
>>where i get back i also added  some     var continuation = 
>>cocoon.createWebContinuation(); in my flow at the points i really want 
>>to go back.
>>
>>Tell me if it's bad practice...
>>
>>    
>>
>
>Hi Phil,
>
>This works form me only partly, becaus if I go back, i keep loosing all the data
>previously entered into the form.
>That means the Forms are displayed correctly, but empty.
>
>snip of my flow:
>trying your solution:
>
>cocoon.load("resource://org/apache/cocoon/forms/flow/javascript/Form.js");
>
>function registration() {
>
>	var continuation = cocoon.createWebContinuation();
>
>	var form = new Form("forms/registration.xml");
>	
>	form.showForm("registration-display-pipeline");
>	
>
>	
>	var model = form.getModel();
>	
>
>    
>   	var helper = new Helper();
>	var timestamp = helper.timestamp();
>    
>    
>   var person = new Person(model.username, model.password, model.email,
>model.firstname, model.sirname, model.address, model.zip, model.country,
>model.birthday, model.phone, timestamp);
>    
>
>	var bizData = person.Object2bizData();
>	
>	var form_confirm = new Form("forms/registration_confirm.xml");
>	form_confirm.showForm("registration-confirm-pipeline", bizData);
>....
>
>
>---------------------------------------------------------------------
>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: cforms + flow contination problem

Posted by Peter Kröpfl <fo...@groebi.com>.
> I don't really have a full understanding on continuations but with JX  i 
> use continue.#{$cocoon/continuation/parent/parent/id}, i  mean pointing 
> one more parent gets me back to the page before. To be able to be sure 
> where i get back i also added  some     var continuation = 
> cocoon.createWebContinuation(); in my flow at the points i really want 
> to go back.
> 
> Tell me if it's bad practice...
> 

Hi Phil,

This works form me only partly, becaus if I go back, i keep loosing all the data
previously entered into the form.
That means the Forms are displayed correctly, but empty.

snip of my flow:
trying your solution:

cocoon.load("resource://org/apache/cocoon/forms/flow/javascript/Form.js");

function registration() {

	var continuation = cocoon.createWebContinuation();

	var form = new Form("forms/registration.xml");
	
	form.showForm("registration-display-pipeline");
	

	
	var model = form.getModel();
	

    
   	var helper = new Helper();
	var timestamp = helper.timestamp();
    
    
   var person = new Person(model.username, model.password, model.email,
model.firstname, model.sirname, model.address, model.zip, model.country,
model.birthday, model.phone, timestamp);
    

	var bizData = person.Object2bizData();
	
	var form_confirm = new Form("forms/registration_confirm.xml");
	form_confirm.showForm("registration-confirm-pipeline", bizData);
....


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: cforms + flow contination problem

Posted by pguillard <pg...@soociety.com>.
Hi,

I don't really have a full understanding on continuations but with JX  i 
use continue.#{$cocoon/continuation/parent/parent/id}, i  mean pointing 
one more parent gets me back to the page before. To be able to be sure 
where i get back i also added  some     var continuation = 
cocoon.createWebContinuation(); in my flow at the points i really want 
to go back.

Tell me if it's bad practice...

Phil

Philipp Rech wrote:

>Hello Peter,
>
>i looked into your stuff and work with it a little. In my opinion the
>onClick="history.go(-1)" is a good idea and works fine. As a link and as a
>button. Both are resiplaying the data just fine. Also i've done it on a 2nd
>CForms page and NOT on the JX Template!!! The more 'Cocoonish' and therefore
>better '${cocoon.continuation.parent.id}.continue' method never worked for
>me. If anyone knows how to implement back funktion via
>'${cocoon.continuation.parent.id}' in CForms or JXT please post, i think its
>a common problem....Here is my code hope that helps somewhat. I will try
>something for JXTemplates too.
>Ciao,
>philipp
>
>
><html xmlns:ft="http://apache.org/cocoon/forms/1.0#template"
>  xmlns:fi="http://apache.org/cocoon/forms/1.0#instance">
>  <head>
>    <title>Registration form</title>
>  </head>
>  <body>
>    <h1>Registration Step 2/2</h1>
>    <ft:form-template action="#{$continuation/id}.continue" method="POST">  
> 
>
>  <ft:widget-label id="password"/>
>      <ft:widget id="password">
>        <fi:styling type="password"/>
>      </ft:widget>
>
>     <!-- .... more widhets here -->
>
><input type="submit" value="Submit" />
><input type="button" value="Back via JS" onClick="history.go(-1)" />
><a href="javascript: history.go(-1)">Back via JS Link</a>
>
>    </ft:form-template>
>
>
>-------------------------------------------------------
>-------------------------------------------------------
>
>
>
>
>  
>
>>Hi,
>>
>>I am trying to do the following:
>>
>>After filling out a form and submitting it i want to show all the data
>>submitted.
>>If the user decides everything is correct he can klick OK and his data
>>will be
>>saved.
>>So far, so good.
>>However, if the data is not correct (e.g. misspelled word, etc) there
>>should be
>>a back button/link.
>>
>>This back button/link is the Problem:
>>
>>If I do a:
>><form action="${cocoon.continuation.parent.id}.continue" method="POST">
>>to go back it goes back to the previous form, but all the field widgets
>>are
>>empty and a validation error for each field is shown.
>>
>>If I go back using the browser back button, everything is nice: all fields
>>(except password fields) show the previously entered data.
>>
>>I even tried:
>><input type="submit" value="Zurück" onClick="history.go(-1)" />
>>to imitate the behaviour of the browser back button, but with no luck.
>>Same
>>empty fields and validation errors as with cocoon.continuation.parent.id.
>>
>>Is this normal behaviour?
>>If yes is there a way to fill those cocoon forms with data?
>>
>>
>>I am using CForms for the forms.
>>JX Templates to show the data for a second check
>>and Flow to handle the stuff in between.
>>
>>
>>
>>
>>here is my flow file:
>>--------------------
>>
>>cocoon.load("resource://org/apache/cocoon/forms/flow/javascript/Form.js");
>>
>>function registration() {
>>	
>>	var form = new Form("forms/registration.xml");
>>	form.showForm("registration-display-pipeline");
>>
>>	var model = form.getModel();
>>	
>>	var helper = new Helper();
>>	var timestamp = helper.timestamp();
>>     
>>   var person = new Person(model.username, model.password, model.email,
>>model.firstname, model.sirname, model.address, model.zip, model.country,
>>model.birthday, model.phone, timestamp);
>>    
>>			
>>	var bizData = person.Object2bizData();
>>
>>// show data again and ask if everything is OK, if not go back
>>	
>>	var form_confirm = new Form("forms/registration_confirm.xml");
>>	form_confirm.showForm("registration-confirm-pipeline", bizData);
>>	
>>// save data to db
>>	person.create();
>>
>>	cocoon.sendPage("registration-success-pipeline", person);
>>}
>>
>>
>>
>>//---------- the form that redisplays the data and provides the go back
>>button:
>><?xml version="1.0" encoding="ISO-8859-1"?>
>><page>
>>  <!-- This is a test page only implementing the "Go Back and Edit" button
>>-->
>>   <title>Registration-Confirm</title>
>>
>> 	<form action="${cocoon.continuation.parent.id}.continue" method="POST"> 
>> 	<!-- <form> -->
>> 	<table>
>>    <tr>
>>    	<td>
>>    	
>>    	<textbold>Confirm:</textbold>
>>    	<text>
>>    	Is this data correct?
>>    	</text>
>>    	
>>    	Username: ${username};
>>    	<br/>
>>    	Password: ${password};
>>    	<br/><br/>
>>    	
>>	</td>
>>	</tr>
>>	
>>	<tr>
>>	<td align="center">
>>		<!-- <input type="submit" value="Go Back" onClick="history.go(-1)" />
>>-->
>>		<input type="submit" value="Go Back" />
>>   </td>
>>    </tr>
>>    </table>
>>    </form>
>>
>></page>
>>
>>
>>
>>---------------------------------------------------------------------
>>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: cforms + flow contination problem

Posted by Peter Kröpfl <fo...@groebi.com>.
Philipp Rech <
> i looked into your stuff and work with it a little. In my opinion the
> onClick="history.go(-1)" is a good idea and works fine. As a link and as a
> button. Both are resiplaying the data just fine. Also i've done it on a 2nd
> CForms page and NOT on the JX Template!!! 
> 
> <html xmlns:ft="http://apache.org/cocoon/forms/1.0#template"
>   xmlns:fi="http://apache.org/cocoon/forms/1.0#instance">
>   <head>
>     <title>Registration form</title>
>   </head>
>   <body>
>     <h1>Registration Step 2/2</h1>
>     <ft:form-template action="#{$continuation/id}.continue" method="POST">  
> 
>   <ft:widget-label id="password"/>
>       <ft:widget id="password">
>         <fi:styling type="password"/>
>       </ft:widget>
> 
>      <!-- .... more widhets here -->
> 
> <input type="submit" value="Submit" />
> <input type="button" value="Back via JS" onClick="history.go(-1)" />
> <a href="javascript: history.go(-1)">Back via JS Link</a>
> 
>     </ft:form-template>

Thanks for helping me.

This is looking really good!

the back button/link works fine, but the problem is that the data is not shown
on the same page with the go back button/link. - At least in my implementation.

Could you please post the sitemap pipeline matchers and your forms definition?


I also tried the fd:output widget but it didn't show the data either.


Is <fd:output /> _the_ way to show data in cforms?

I don't understand what:
---"). An output widget does not read its value from the request, so is most
useful in the case where the form is stored accross requests (automatically the
case when using flowscript "---
shall mean.

http://cocoon.apache.org/2.1/userdocs/forms/widget_output.html

Thank for your help.
Peter


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: cforms + flow contination problem

Posted by Philipp Rech <ph...@gmx.de>.
Hello Peter,

i looked into your stuff and work with it a little. In my opinion the
onClick="history.go(-1)" is a good idea and works fine. As a link and as a
button. Both are resiplaying the data just fine. Also i've done it on a 2nd
CForms page and NOT on the JX Template!!! The more 'Cocoonish' and therefore
better '${cocoon.continuation.parent.id}.continue' method never worked for
me. If anyone knows how to implement back funktion via
'${cocoon.continuation.parent.id}' in CForms or JXT please post, i think its
a common problem....Here is my code hope that helps somewhat. I will try
something for JXTemplates too.
Ciao,
philipp


<html xmlns:ft="http://apache.org/cocoon/forms/1.0#template"
  xmlns:fi="http://apache.org/cocoon/forms/1.0#instance">
  <head>
    <title>Registration form</title>
  </head>
  <body>
    <h1>Registration Step 2/2</h1>
    <ft:form-template action="#{$continuation/id}.continue" method="POST">  
 

  <ft:widget-label id="password"/>
      <ft:widget id="password">
        <fi:styling type="password"/>
      </ft:widget>

     <!-- .... more widhets here -->

<input type="submit" value="Submit" />
<input type="button" value="Back via JS" onClick="history.go(-1)" />
<a href="javascript: history.go(-1)">Back via JS Link</a>

    </ft:form-template>


-------------------------------------------------------
-------------------------------------------------------




> Hi,
> 
> I am trying to do the following:
> 
> After filling out a form and submitting it i want to show all the data
> submitted.
> If the user decides everything is correct he can klick OK and his data
> will be
> saved.
> So far, so good.
> However, if the data is not correct (e.g. misspelled word, etc) there
> should be
> a back button/link.
> 
> This back button/link is the Problem:
> 
> If I do a:
> <form action="${cocoon.continuation.parent.id}.continue" method="POST">
> to go back it goes back to the previous form, but all the field widgets
> are
> empty and a validation error for each field is shown.
> 
> If I go back using the browser back button, everything is nice: all fields
> (except password fields) show the previously entered data.
> 
> I even tried:
> <input type="submit" value="Zurück" onClick="history.go(-1)" />
> to imitate the behaviour of the browser back button, but with no luck.
> Same
> empty fields and validation errors as with cocoon.continuation.parent.id.
> 
> Is this normal behaviour?
> If yes is there a way to fill those cocoon forms with data?
> 
> 
> I am using CForms for the forms.
> JX Templates to show the data for a second check
> and Flow to handle the stuff in between.
> 
> 
> 
> 
> here is my flow file:
> --------------------
> 
> cocoon.load("resource://org/apache/cocoon/forms/flow/javascript/Form.js");
> 
> function registration() {
> 	
> 	var form = new Form("forms/registration.xml");
> 	form.showForm("registration-display-pipeline");
> 
> 	var model = form.getModel();
> 	
> 	var helper = new Helper();
> 	var timestamp = helper.timestamp();
>      
>    var person = new Person(model.username, model.password, model.email,
> model.firstname, model.sirname, model.address, model.zip, model.country,
> model.birthday, model.phone, timestamp);
>     
> 			
> 	var bizData = person.Object2bizData();
> 
> // show data again and ask if everything is OK, if not go back
> 	
> 	var form_confirm = new Form("forms/registration_confirm.xml");
> 	form_confirm.showForm("registration-confirm-pipeline", bizData);
> 	
> // save data to db
> 	person.create();
> 
> 	cocoon.sendPage("registration-success-pipeline", person);
> }
> 
> 
> 
> //---------- the form that redisplays the data and provides the go back
> button:
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <page>
>   <!-- This is a test page only implementing the "Go Back and Edit" button
> -->
>    <title>Registration-Confirm</title>
> 
>  	<form action="${cocoon.continuation.parent.id}.continue" method="POST"> 
>  	<!-- <form> -->
>  	<table>
>     <tr>
>     	<td>
>     	
>     	<textbold>Confirm:</textbold>
>     	<text>
>     	Is this data correct?
>     	</text>
>     	
>     	Username: ${username};
>     	<br/>
>     	Password: ${password};
>     	<br/><br/>
>     	
> 	</td>
> 	</tr>
> 	
> 	<tr>
> 	<td align="center">
> 		<!-- <input type="submit" value="Go Back" onClick="history.go(-1)" />
> -->
> 		<input type="submit" value="Go Back" />
>    </td>
>     </tr>
>     </table>
>     </form>
> 
> </page>
> 
> 
> 
> ---------------------------------------------------------------------
> 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: cforms + flow contination problem

Posted by Upayavira <uv...@upaya.co.uk>.
Surely you can do the following (add a while loop with a boolean 'confirmed' variable? 

Won't that work?

Upayavira

function registration() {
	
	var form = new Form("forms/registration.xml");

var confirmed = false;
while (!confirmed) {
	form.showForm("registration-display-pipeline");

	var model = form.getModel();
	
	var helper = new Helper();
	var timestamp = helper.timestamp();
     
   var person = new Person(model.username, model.password, model.email,
model.firstname, model.sirname, model.address, model.zip, model.country,
model.birthday, model.phone, timestamp);
    
			
	var bizData = person.Object2bizData();

// show data again and ask if everything is OK, if not go back
	
	var form_confirm = new Form("forms/registration_confirm.xml");
	form_confirm.showForm("registration-confirm-pipeline", bizData);
confirmed = form.getChild("confirmed");
}

// save data to db
	person.create();

	cocoon.sendPage("registration-success-pipeline", person);
}



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org