You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Philipp Rech <ph...@gmx.de> on 2004/10/26 13:41:36 UTC

[sorry but not all done yet] RE: pass a variable from flowscript into cfrom text input field

sorry i was too fast... 
the solution  

var test;

form = new Form("my-form.xml");
wid = form.lookupWidget("test");
wid.setValue(test);

form.showForm("registration-display-pipeline");
var test = cocoon.request.test;


only works fine with input field widgets but not with booleanfield
widgets. There i get an error: 

java.lang.RuntimeException: Cannot set value of boolean field "test" to a
non-Boolean value.

Same as with the text field i use it to figure out if it has been "changed"
before and redisplay its old value... all to solve my multi page from
problem.... user has enterd a falue in page 2 and submitetd it then goes
back to page 1 and changes something and submits page one. now i want page 2
to be displayed again but with the data entered before!


thanks again!
phil






> thank you Bart it works now! 
> 
> what i like most about Cocoon
> is the community of users and 
> developers! thanks guys!
> 
> regards,
> phil
> 
> 
> 
> 
> > No, the code belongs to your flowscript.
> > 
> > var name = "Cocoon";
> > 
> > form = new Form("my-form.xml");
> > wid = form.lookupWidget("name");
> > wid.setValue(name);
> > 
> > ...
> > 
> > form.showForm("form-pipe");
> > 
> > ...
> > 
> > > 
> > > Thank you Bart, Gunter and Nacho!
> > > 
> > > still i am not shure how to use this:
> > > 
> > > nameWidget = form.lookupWidget("name");
> > > nameWidget.setValue(name);
> > > 
> > > can i put this in my Flowscript? Again i want to pass a variable
> > > from a flowscript and set it as default value for the widget.
> > > I guess the code above belongs in the cfrom template but how do i pass
> > the
> > > variable "name" to it?
> > > 
> > > 
> > > > and with v2 of the javascript API, you could write:
> > > >
> > > > var form = new Form("form1.xml");
> > > > var wid = form.getWidget();
> > > > wid.name.value = name;
> > > >
> > > uhh, how can i use version 2 of the javascript API?
> > > 
> > 
> > cocoon.load("resource://org/apache/cocoon/forms/flow/javascript/v2/Form.
> > js");
> > 
> > (ie load Form.js from the v2/ directory). But the code above should work
> > with the regular (version 1) Form.js
> > 
> > > 
> > > Thanks again,
> > > phil
> > Bart
> > 
> > 
> > ---------------------------------------------------------------------
> > 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
> 


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


Re: [sorry but not all done yet] RE: pass a variable from flowscript into cfrom text input field

Posted by Johannes Textor <jc...@gmx.de>.
hi philipp,

>> var mail = "";     //here is the boolean field mail!!!!

"mail" is a booleanfield, so you have to set either  

var mail = true; 

or 

var mail = false; 

as you can see from the error message: 

java.lang.RuntimeException: Cannot set value of boolean field "test" to a
non-Boolean value.

"" is not a boolean value, hence the error message. 


hth, johannes 




Philipp Rech wrote:

>okay my from definition and template look almost like this
>http://cocoon.apache.org/2.1/userdocs/forms/sample.html
>the only thing different is that they are split up in two
>pages thus two from definitions and templates.
>the reason for all that is to be able to go back to the first page 
>change something and will u click on submit the second page appears with the
>values u enteres before... wizard like. mybe there is even a better
>soloution for this... *wonders*...
>
>here is my flowscript. it works as i want with the input fields but not with
>the boolean (checkbox!) fields called "mail". 
>see: 
>//(DOENST WORK)  wmail = form_2.lookupWidget("mail");
>//(DOSENT WORK)  wmail.setValue(mail);
>
>
>---------- the flowscript: -------------------
>
>cocoon.load("resource://org/apache/cocoon/forms/flow/javascript/Form.js");
>
>function registration (){
>    
>
>	var username = "";
>	var email = "";
>	var password = "";
>	var sex = "";
>	var color = "";
>    	var mail = "";     //here is the boolean field mail!!!!
>	var age = "";
>
>
>     var form_1 = new Form("form-1.xml");
>
>    form_1.showForm("registration-display-pipeline");
>  
>	var username = cocoon.request.name;
>	var email = cocoon.request.email;
>      var age = cocoon.request.age;
>	var sex = cocoon.request.sex;
>   
>	var form_2 = new Form("form-2.xml");
>
>
>     //here check is the value hase been chenged from "" to something
>     // and if yes redisplay the old value!!!
>
>	wfarbe = form_2.lookupWidget("farbe");
>	wfarbe.setValue(farbe);
>	wpassword = form_2.lookupWidget("password");
>	wpassword.setValue(password);
>	//(DOENST WORK)  wmail = form_2.lookupWidget("mail");
>	//(DOSENT WORK)  wmail.setValue(mail);
>
>  	form_2.showForm("registration-display-pipeline-2");
>
>	var password = cocoon.request.password;
>	var farbe = cocoon.request.farbe;
>    	var mail = cocoon.request.mail;
>
>
>	var model_1 = form_1.getModel();
>   	 var model_2 = form_2.getModel();
>    
>   	 var bizdata = { "username" : model_1.name, 
>                    "email" : model_1.email, 
>                    "age" : model_1.age,
>		     "sex" : model_1.sex,
>                     "pw" : model_2.password,
>  	             "mail" : model_2.mail,
>			   "farbe" : model_2.farbe
>			};
>    
>    cocoon.sendPage("registration-success-pipeline", bizdata);
>   
>}
>
>
>-----------------------------------------------------------
>
>thank you!
>philipp
>
>  
>

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


Re: [sorry but not all done yet] RE: pass a variable from flowscript into cfrom text input field

Posted by Philipp Rech <ph...@gmx.de>.
okay my from definition and template look almost like this
http://cocoon.apache.org/2.1/userdocs/forms/sample.html
the only thing different is that they are split up in two
pages thus two from definitions and templates.
the reason for all that is to be able to go back to the first page 
change something and will u click on submit the second page appears with the
values u enteres before... wizard like. mybe there is even a better
soloution for this... *wonders*...

here is my flowscript. it works as i want with the input fields but not with
the boolean (checkbox!) fields called "mail". 
see: 
//(DOENST WORK)  wmail = form_2.lookupWidget("mail");
//(DOSENT WORK)  wmail.setValue(mail);


---------- the flowscript: -------------------

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

function registration (){
    

	var username = "";
	var email = "";
	var password = "";
	var sex = "";
	var color = "";
    	var mail = "";     //here is the boolean field mail!!!!
	var age = "";


     var form_1 = new Form("form-1.xml");

    form_1.showForm("registration-display-pipeline");
  
	var username = cocoon.request.name;
	var email = cocoon.request.email;
      var age = cocoon.request.age;
	var sex = cocoon.request.sex;
   
	var form_2 = new Form("form-2.xml");


     //here check is the value hase been chenged from "" to something
     // and if yes redisplay the old value!!!

	wfarbe = form_2.lookupWidget("farbe");
	wfarbe.setValue(farbe);
	wpassword = form_2.lookupWidget("password");
	wpassword.setValue(password);
	//(DOENST WORK)  wmail = form_2.lookupWidget("mail");
	//(DOSENT WORK)  wmail.setValue(mail);

  	form_2.showForm("registration-display-pipeline-2");

	var password = cocoon.request.password;
	var farbe = cocoon.request.farbe;
    	var mail = cocoon.request.mail;


	var model_1 = form_1.getModel();
   	 var model_2 = form_2.getModel();
    
   	 var bizdata = { "username" : model_1.name, 
                    "email" : model_1.email, 
                    "age" : model_1.age,
		     "sex" : model_1.sex,
                     "pw" : model_2.password,
  	             "mail" : model_2.mail,
			   "farbe" : model_2.farbe
			};
    
    cocoon.sendPage("registration-success-pipeline", bizdata);
   
}


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

thank you!
philipp






> hi philipp,
> 
> the error message seems quite clear, you have to supply a boolean
> value (true or false) to a booleanfield. if you did that it's maybe a
> javascript-java-interaction problem. can you post the actual code that
> generated the error message ? from below i can only see you try to
> set the field "test" to a non-instantiated javascript variable ...
> 
> greetings, johannes
> 
> Philipp Rech wrote:
> 
> >sorry i was too fast... 
> >the solution  
> >
> >var test;
> >
> >form = new Form("my-form.xml");
> >wid = form.lookupWidget("test");
> >wid.setValue(test);
> >
> >form.showForm("registration-display-pipeline");
> >var test = cocoon.request.test;
> >
> >
> >only works fine with input field widgets but not with booleanfield
> >widgets. There i get an error: 
> >
> >java.lang.RuntimeException: Cannot set value of boolean field "test" to a
> >non-Boolean value.
> >
> >Same as with the text field i use it to figure out if it has been
> "changed"
> >before and redisplay its old value... all to solve my multi page from
> >problem.... user has enterd a falue in page 2 and submitetd it then goes
> >back to page 1 and changes something and submits page one. now i want
> page 2
> >to be displayed again but with the data entered before!
> >
> >
> >thanks again!
> >phil
> >
> >  
> >
> >  
> >
> 
> 
> ---------------------------------------------------------------------
> 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: [sorry but not all done yet] RE: pass a variable from flowscript into cfrom text input field

Posted by Johannes Textor <jc...@gmx.de>.
hi philipp,

the error message seems quite clear, you have to supply a boolean
value (true or false) to a booleanfield. if you did that it's maybe a
javascript-java-interaction problem. can you post the actual code that
generated the error message ? from below i can only see you try to
set the field "test" to a non-instantiated javascript variable ...

greetings, johannes

Philipp Rech wrote:

>sorry i was too fast... 
>the solution  
>
>var test;
>
>form = new Form("my-form.xml");
>wid = form.lookupWidget("test");
>wid.setValue(test);
>
>form.showForm("registration-display-pipeline");
>var test = cocoon.request.test;
>
>
>only works fine with input field widgets but not with booleanfield
>widgets. There i get an error: 
>
>java.lang.RuntimeException: Cannot set value of boolean field "test" to a
>non-Boolean value.
>
>Same as with the text field i use it to figure out if it has been "changed"
>before and redisplay its old value... all to solve my multi page from
>problem.... user has enterd a falue in page 2 and submitetd it then goes
>back to page 1 and changes something and submits page one. now i want page 2
>to be displayed again but with the data entered before!
>
>
>thanks again!
>phil
>
>  
>
>  
>


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