Hi Andrew,
please file a bug about this on
http://issues.apache.org/jira/browse/COCOON . I'm not sure about it,
but maybe it's not so difficult to initialize the cocoon _javascript_
object for definition embedded _javascript_ even when the entire
_javascript_ flow engine is not on.
Write your code snippet in the bug, so that committers can test it.
Apart from the (horrible) work around i wrote you about, nothing else
came to my mind.
Simone
Andrew Madu wrote:
Hi Simone,
I should have mentioned that the error I am getting is the following:
ReferenceError: "cocoon" is not defined
The rest of the code seems to be fine though. I am hoping that this is
simple issue to resolve, without having to do a major code change ;-),
otherwise I will have to stiick with flowscript.
Andrew
On 3/21/06, Simone Gianni <[EMAIL PROTECTED]> wrote:
Hi
Andrew,
I would move all the login code in the flow, since the fd:validation is
not the right place to do application logic.
But if you really need it there, i think you will have to rewrite your
code. Unfortunately, the _javascript_ snippet is executed using the
FOM_SCOPE, which contains the cocoon object and all the rest, but it
seems like this scope is initialized inside the flowscript code, so
looks like it's not available when in javaflow. I think this is a cocoon
bug, since the usage of a different flow engine should not change the
behaviour or embedded _javascript_ snippets of a definition. I think
nobody noticed this since it's not so common to access the session from
inside an fd:validation expecially when javaflow is used.
You could try a really non-tidy way : put the session in a form
attribute from javaflow, and then retrieve it inside the _javascript_:
FormInstance form = new FormInstance("forms/login.xml");
form.setAttribute("session", getRequest().getSession());
<fd:_javascript_>
var success = true;
var newUserReg = new Packages.test.User();
var username = widget.lookupWidget("username");
var password = widget.lookupWidget("password");
var session = widget.getForm().getAttribute('session');
session.setAttribute
("user", null);
I haven't tested this, and don't know which error your code reports, but
hope it helps. Please consider moving the login code from the
fd:validation to the flow.
Simone
Andrew Madu wrote:
> Hi,
> I have created a java flow class which does the following:
>
> //Load in validation file
> FormInstance form = new FormInstance("forms/login.xml");
>
> My login map is as follows:
>
> Login.xml:
> <fd:validation>
> <fd:_javascript_>
> var success = true;
> var newUserReg = new Packages.test.User();
> var username = widget.lookupWidget("username");
> var password = widget.lookupWidget("password");
> cocoon.session.setAttribute
("user", null);
>
> try {
>
>
var checkUserTest = newUserReg.getUser(username.value,
> password.value);
>
>
if (checkUserTest != null) {
>
cocoon.session.setAttribute("user", checkUserTest);
>
success = true;
> }else{
>
username.setValidationError(new
> Packages.org.apache.cocoon.forms.validation.ValidationError(e,
false));
>
password.setValidationError(new
> Packages.org.apache.cocoon.forms.validation.ValidationError("The
> password, username combination does not exist. Please enter another
> one.", false));
>
success = false;
> }
> } catch (e) {
>
username.setValidationError(new
> Packages.org.apache.cocoon.forms.validation.ValidationError(e,
false));
>
password.setValidationError(new
> Packages.org.apache.cocoon.forms.validation.ValidationError("The
> password, username combination does not exist. Please enter another
> one.", false));
>
success = false;
> }
>
> return success;
> </fd:_javascript_>
> </fd:validation>
>
> I am getting an error message when the line:
>
> cocoon.session.setAttribute("user", null);
>
> is hit. What is the issue with this when using javaflow instead of
> flowscript? How can I alter thsi map so that it is java flow
> complient? I tried:
>
> <fd:java>
>
> as a starter but got an error with that.
>
> Andrew
--
Simone Gianni
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
Simone Gianni
|