Yes, I know this. It was meant as suggestion for the problems Helma has
in the original question. :)
Olivier Billard wrote:
Thomas,
I think you're right. cocoon.sendPage() is not equivalent to return. You
have to explicitly set a return after a cocoon.sendPage that is not at
the end of a function. If not, Cocoon continues to execute the code
after redirecting the request.
I already experienced this type of error. In you case, you are not
throwing any Exception in your catch block, so the execution continues
after the catch block.
The code should be :
myFunction(){
try{
[something]
}
catch(error){
cocoon.sendPage([error message]);
return;
}
cocoon.sendPage([result]);
}
Thomas Kjeldahl Nilsson wrote:
Hello,
I have very limited knowledge of cforms, but I've had some problems
with the "jx generator already set" error on my current project.
Generally, I get this error when I do something like this:
myFunction(){
try{
[something]
}
catch(error){
cocoon.sendPage([error message])
}
cocoon.sendPage([result])
}
I got this error because when catching errors and sending the error
message with a sendPage() call rather than sendPageAndWait() the error
was displayed but the flowscript went on to the next sendPage() after
the catch statement, triggering the "jx generator already set" error.
Not sure if this helps you, but I'd look into what happens when you
show your form. Does the flowscript really wait for user input, or
does it try the next loop iteration\form display immediately, causing
the "jx generator already set"?
Just an idea.
-ThomasN
[EMAIL PROTECTED] wrote:
Guys,
anyone? Please help.
Thanks.
Bye, Helma
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Sent: Friday, 16 July 2004 11:06
To: [EMAIL PROTECTED]
Subject: how to avoid 'generator already set' error?
Hi,
I have this bit of flow script:
function myFunction() {
var form = new Form(formDef);
form.createBinding(formBind);
var success = false;
var errMsg = "";
var count = 0; // to prevent endless loops
while(!success && count < 10) {
try {
form.load(myForm);
var viewData = { some: data, errMsg: errMsg };
form.showForm(formDisplayPipeline, viewData);
form.save(myForm);
success = myHelper.storeNewForm(myForm);
}
catch(error) {
errMsg = "other error: " + error;
print(errMsg);
success = false;
}
count++;
}
cocoon.sendPage("displayResult");
}
FormDisplayPipeline points to a pipeline:
<map:generate type="jx" src="myTemplate.jx"/>
<map:transform type="cinclude"/>
<map:transform type="forms"/>
<map:transform src="stylesheets/resources/forms-samples-styling.xsl">
<map:parameter name="uri" value="stylesheets/resources"/>
</map:transform> <map:call resource="html-layout"/> <map:serialize
type="html"/>
The above works ok. However, when something happens errMsg is set
and the loop starts from the top, but rather than redisplaying the
form, I get an error message stating 'Generator already set'. This
repeats until count==10.
What should I do to redisplay the form properly with error message?
Thanks.
Bye,
Helma van der Linden
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]