You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by beya! <an...@jibeya.com> on 2004/11/15 16:08:36 UTC

Flowscript + CForms problem

Hi,
I am having a problem with a flowscript function which:

1. Doesn't pull in the values from my Cform
2. Doesn't jump out of the while loop

The code is as follows:

var userGlobal = null;
var newUser = new User();
var msg = null;
var neworder = null;

function login() {
	var form = new Form("forms/definition.xml");
	
	while (true) {
		
		//make sure form is filled in correctly
		form.showForm("unprotected.xml", {"msg":msg,  
"userGlobal":userGlobal});
		var model = form.getModel();
		
		msg = null;
		
		//check user input against database
		try {
			userGlobal = newUser.getUser(model.username, model.password); //1.  
This line does not work
			//userGloabl =  
newUser.getUser(cocoon.request.get("username"),cocoon.request.get("passw 
ord")); //2. This does work.
			break;
		}catch(e) {
			msg = "Incorrect username or password. Please re-enter.";
		}
	}
	
	//Create session variable
	cocoon.createSession();
	
	//Redirect user to registered area of site
	cocoon.sendPage("registered_section1.xml", {"msg":msg,  
"userGlobal":userGlobal});
}

In the try {} section the first option does not work, but the second  
one does. If I use the second option the break is then not acted on and  
the user is redirected back to showForm although in the logs it shows  
that the the form values have been referenced in the database and the  
appropriate user details returned. What am I doing wrong here?

regards


Andrew

Re: Flowscript + CForms problem

Posted by beya! <an...@jibeya.com>.
Problem solved...
I added the following lines:

var bizData = {"username" : model.username, "password" : model.password}

try {
	userGlobal = newUser.getUser(bizData.username, bizData.password);
     ...........
}

regards


Andrew
On 15 Nov 2004, at 15:08, beya! wrote:

> Hi,
> I am having a problem with a flowscript function which:
>
> 1. Doesn't pull in the values from my Cform
> 2. Doesn't jump out of the while loop
>
> The code is as follows:
>
> var userGlobal = null;
> var newUser = new User();
> var msg = null;
> var neworder = null;
>
> function login() {
> 	var form = new Form("forms/definition.xml");
> 	
> 	while (true) {
> 		
> 		//make sure form is filled in correctly
> 		form.showForm("unprotected.xml", {"msg":msg,  
> "userGlobal":userGlobal});
> 		var model = form.getModel();
> 		
> 		msg = null;
> 		
> 		//check user input against database
> 		try {
> 			userGlobal = newUser.getUser(model.username, model.password); //1.  
> This line does not work
> 			//userGloabl =  
> newUser.getUser(cocoon.request.get("username"),cocoon.request.get("pass 
> word")); //2. This does work.
> 			break;
> 		}catch(e) {
> 			msg = "Incorrect username or password. Please re-enter.";
> 		}
> 	}
> 	
> 	//Create session variable
> 	cocoon.createSession();
> 	
> 	//Redirect user to registered area of site
> 	cocoon.sendPage("registered_section1.xml", {"msg":msg,  
> "userGlobal":userGlobal});
> }
>
> In the try {} section the first option does not work, but the second  
> one does. If I use the second option the break is then not acted on  
> and the user is redirected back to showForm although in the logs it  
> shows that the the form values have been referenced in the database  
> and the appropriate user details returned. What am I doing wrong here?
>
> regards
>
>
> Andrew
>