[ 
http://issues.apache.org/jira/browse/COCOON-1804?page=comments#action_12371418 
] 

Simone Gianni commented on COCOON-1804:
---------------------------------------

Implemented a custom java validator. See COCOON-1806. It should be possible to 
apply this patch also to older versions of cocoon since it's mainly file 
additions.

Anyway, the problem of accessing the request, session or other objectmodel 
objects from inside these classes is unresolved.

IMMO, this is a cocoon flow : the fact that a user decides to use another flow 
interpreter should not modify the behaviour of a definition javascript snippet.

There are two possible solutions :
- Either we decide that a definition snippet shouldn't access the cocoon 
object, since that's commonly used for "control", and definition is not the 
right place for control. So the javascript scope in which the definition 
snippets are executed should not be the same of the flowscript interpreter but 
a new one, without the FOM objects inside.
- Or the behaviour must be the same, so the o.a.c.forms.utils.JavaScriptHelper, 
if does not find an already prepared "FOM-enabled" javascript context creates a 
new one, so that also with javaflow you have the same objects inside a 
javascript snippet. It should not be that difficult, I think it's just a matter 
of exporting relevant methods of the flowscript interpreter (expecially 
createSessionScope) in another utility class, and partially export the 
setupContext method in this same utility class.


> Javascript FOM_SCOPE issue when using Java as the flow engine - 
> ReferenceError: "cocoon" is not defined
> -------------------------------------------------------------------------------------------------------
>
>          Key: COCOON-1804
>          URL: http://issues.apache.org/jira/browse/COCOON-1804
>      Project: Cocoon
>         Type: Bug
>   Components: Blocks: Java Flow
>     Versions: 2.1.8
>     Reporter: Andrew Madu
>     Priority: Blocker

>
> 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 (snippet) 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");
>            
>             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("e.", false));
>                     success = false;
>             }
>             return success;
>         </fd:javascript>
>     </fd:validation>
> I am getting an error message when the line 
> 'cocoon.session.setAttribute("user", checkUserTest)' is hit.:
> ReferenceError: "cocoon" is not defined
> What is the issue here, can I create a session object from within form 
> validation/javascript in another way?
> Andrew

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to