You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by "Andrew Madu (JIRA)" <ji...@apache.org> on 2006/03/21 18:42:58 UTC

[jira] Created: (COCOON-1804) Javascript FOM_SCOPE issue when using Java as the flow engine - ReferenceError: "cocoon" is not defined

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


[jira] Commented: (COCOON-1804) Javascript FOM_SCOPE issue when using Java as the flow engine - ReferenceError: "cocoon" is not defined

Posted by "Bruno Dumon (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/COCOON-1804?page=comments#action_12371398 ] 

Bruno Dumon commented on COCOON-1804:
-------------------------------------

Implementing a WidgetValidator + Builder + adding it to cocoon.xconf should IMO only be done for providing entirely new types of validators, not for your application-logic validators.

Now what's been missing for a long time is a generic java class validator, i.e. something one could use like:

<fd:validation>
   <fd:java class="...."/>
</fd:validation>

and which delegates to the specified class, without requiring registration in cocoon.xconf. Creating such a fd:java validator should be easy. If Avalon interfaces such as Contextualizable and Serviceable are honored, the validator can access the request object etc.

As an alternative, you can also add a validator on the form instance (using the addValidator method on any widget). This makes it very easy to make objects from your flow available to the validator.

> 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


[jira] Commented: (COCOON-1804) Javascript FOM_SCOPE issue when using Java as the flow engine - ReferenceError: "cocoon" is not defined

Posted by "Reinhard Poetz (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/COCOON-1804?page=comments#action_12371283 ] 

Reinhard Poetz commented on COCOON-1804:
----------------------------------------

http://cocoon.apache.org/2.1/userdocs/widgetconcepts/validation.html should help

> 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


[jira] Commented: (COCOON-1804) Javascript FOM_SCOPE issue when using Java as the flow engine - ReferenceError: "cocoon" is not defined

Posted by "Andrew Madu (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/COCOON-1804?page=comments#action_12371381 ] 

Andrew Madu commented on COCOON-1804:
-------------------------------------

Simone,could you point me in the direction of  any exiting class code examples for implementing both o.a.c.forms.validation.WidgetValidator, WidgetValidatorBuilder,registering the builder with cocoon.xconf and final usage of, my defined, WidgetValidator from within cforms?

> 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


[jira] Commented: (COCOON-1804) Javascript FOM_SCOPE issue when using Java as the flow engine - ReferenceError: "cocoon" is not defined

Posted by "Andrew Madu (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/COCOON-1804?page=comments#action_12371415 ] 

Andrew Madu commented on COCOON-1804:
-------------------------------------

To be fair I am a bit surprised that a generic java class validator:

<fd:validation>
  <fd:java class="...."/>
</fd:validation>

was not implemented as part of CForms/JavaFlow from the get go! How long would it take to implement one?

Andrew

> 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


[jira] Commented: (COCOON-1804) Javascript FOM_SCOPE issue when using Java as the flow engine - ReferenceError: "cocoon" is not defined

Posted by "Andrew Madu (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/COCOON-1804?page=comments#action_12371515 ] 

Andrew Madu commented on COCOON-1804:
-------------------------------------

Simone, i've never applied a patch before so how do I go about applying this one to cocoon 2.1.8?

Andrew

> 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


[jira] Commented: (COCOON-1804) Javascript FOM_SCOPE issue when using Java as the flow engine - ReferenceError: "cocoon" is not defined

Posted by "Simone Gianni (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/COCOON-1804?page=comments#action_12371298 ] 

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

Andrew, a validator is simply a java class, so you can create your own validators writing a java class implementing o.a.c.forms.validation.WidgetValidator . Once you have the class, you have to write also another class implementing WidgetValidatorBuilder which acts as a factory creating instances of your validator class, and register this builder in cocoon.xconf so that cocoon forms can load, configure and use it thru the avalon framework.

But Reinhard, AFAIK this does not solve (at least not directly) the problem of accessing the session from inside this validator, if not with some context/objectmodel static classes.

Could you tell us how to retrieve the current session (request, object model.. ) from inside a java widget validator (so, eventually, translating it to javascript it could be usable also inside the javascript validator)?


> 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


[jira] Commented: (COCOON-1804) Javascript FOM_SCOPE issue when using Java as the flow engine - ReferenceError: "cocoon" is not defined

Posted by "Simone Gianni (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/COCOON-1804?page=comments#action_12371909 ] 

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

here is the java class : src/blocks/forms/java/org/apache/cocoon/forms/samples/CustomBirthDateValidator.java
here is the form model : src/blocks/forms/samples/forms/form2_model.xml


> 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


[jira] Closed: (COCOON-1804) Javascript FOM_SCOPE issue when using Java as the flow engine - ReferenceError: "cocoon" is not defined

Posted by "Simone Gianni (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/COCOON-1804?page=all ]
     
Simone Gianni closed COCOON-1804:
---------------------------------

    Fix Version: 2.1.10-dev (current SVN)
     Resolution: Fixed

Committed the patch

> 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
>      Fix For: 2.1.10-dev (current SVN)
>  Attachments: javaflow-fomcocoon.diff
>
> 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


[jira] Commented: (COCOON-1804) Javascript FOM_SCOPE issue when using Java as the flow engine - ReferenceError: "cocoon" is not defined

Posted by "Andrew Madu (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/COCOON-1804?page=comments#action_12371845 ] 

Andrew Madu commented on COCOON-1804:
-------------------------------------

Simone,
could you please tell me, or direct me to  docucmentation, which will allow me to convert the <fd:javascript /> validation example I gave above to <fd:java />?

many thanks for all your help

Andrew

P.S. Are we any closer to resolving 'ReferenceError: "cocoon" is not defined'?

> 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


[jira] Commented: (COCOON-1804) Javascript FOM_SCOPE issue when using Java as the flow engine - ReferenceError: "cocoon" is not defined

Posted by "Reinhard Poetz (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/COCOON-1804?page=comments#action_12371271 ] 

Reinhard Poetz commented on COCOON-1804:
----------------------------------------

I had the same problem when I used cForms together with Apples. The problem is that there is no Cocoon object unless you use Flowscript. As a workaround I implemented the javascript validator as a Java class within the controller IIRC. This should work for Javaflow too.

> 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


[jira] Updated: (COCOON-1804) Javascript FOM_SCOPE issue when using Java as the flow engine - ReferenceError: "cocoon" is not defined

Posted by "Simone Gianni (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/COCOON-1804?page=all ]

Simone Gianni updated COCOON-1804:
----------------------------------

    Attachment: javaflow-fomcocoon.diff

This patch solves the problem, also if not perfect I don't think it's so easy to do much more. 

What i've done is this :
- Created a new class FOM_SimpleCocoon
... It's a javascript host object
... Exposes request, response, session and context
... It does not (yet?) exposes log and parameters
... Does not have (obviously) the methods of the FOM_Cocoon object like sendPage etc..
- In JavascriptHelper, when a function is called :
... If there is not already a scope created by flowscript, getRootScope is called.
... I added the object model as a parameter of getRootScope.
... If an object model is specified, it's used to create a new instance of FOM_SimpleCocoon
... This instance is placed in a new scope, with the name "cocoon"
... The javascript function is explicity applied to this new scope

This way, the difference between a javascript snippet in a definition, wether using flowscript or javaflow, is smaller, since cocoon.request, cocoon.session, cocoon.response and cocoon.context are now available, and I don't think much more is needed. It would be nice to also have log and parameters, just to be more compatible with the complete FOM_Cocoon, but since i don't think they can be obtained from an ObjectModel, they should be added as new parameters in all the JavascripHelper calls.

> 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
>  Attachments: javaflow-fomcocoon.diff
>
> 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


[jira] Commented: (COCOON-1804) Javascript FOM_SCOPE issue when using Java as the flow engine - ReferenceError: "cocoon" is not defined

Posted by "Simone Gianni (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/COCOON-1804?page=comments#action_12412931 ] 

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

Hi Andrew, 
you can obtain this functionality :
- Patching your 2.1.9 installation (with the patch command, or with eclipse) using the patch here attached.
- Checkiung out 2.1.X (2.1.10 dev) from SVN
- Downloading a 2.1.X snapshot from here http://svn.apache.org/snapshots/cocoon-BRANCH_2_1_X/


> 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
>      Fix For: 2.1.10-dev (current SVN)
>  Attachments: javaflow-fomcocoon.diff
>
> 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


[jira] Commented: (COCOON-1804) Javascript FOM_SCOPE issue when using Java as the flow engine - ReferenceError: "cocoon" is not defined

Posted by "Simone Gianni (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/COCOON-1804?page=comments#action_12371979 ] 

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

I'm trying to solve this issue. The way I'm acting is the following :

- Implementing a lightweight FOM_SimpleCocoon as a javascript host object giving access to session, request etc..
- Passing the object model if present in JavascriptHelper.getRootScope (called if a script flow scope is not present)
- If there is an object model instantiate the FOM_SimpleCocoon object in a new scope and use that.

Everything is done, but i keep receiving a 

org.mozilla.javascript.PropertyException:
Constructor for "FOM_SimpleCocoon" not found.

I tried everything, from not declaring a costructor at all, declaring expliticly an empty constructor, declaring a costructor with a parameter and passing that parameter in the ctx.newObject method, declaring a jsConstructor method, but still can't understand where the problem is.

Does anyone have an idea? I followed this tutorial http://www.mozilla.org/rhino/tutorial.html#AddingCounter step by step but it keeps on giving the exception.

Please help!

> 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


[jira] Commented: (COCOON-1804) Javascript FOM_SCOPE issue when using Java as the flow engine - ReferenceError: "cocoon" is not defined

Posted by "Simone Gianni (JIRA)" <ji...@apache.org>.
    [ 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


[jira] Commented: (COCOON-1804) Javascript FOM_SCOPE issue when using Java as the flow engine - ReferenceError: "cocoon" is not defined

Posted by "Andrew Madu (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/COCOON-1804?page=comments#action_12371846 ] 

Andrew Madu commented on COCOON-1804:
-------------------------------------

Can you point me in the direction of the CustomBirthDateValidator <fd:java /> validation sample which accesses the CustomBirthDateValidator java class?

Andrew

> 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


[jira] Commented: (COCOON-1804) Javascript FOM_SCOPE issue when using Java as the flow engine - ReferenceError: "cocoon" is not defined

Posted by "Andrew Madu (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/COCOON-1804?page=comments#action_12412927 ] 

Andrew Madu commented on COCOON-1804:
-------------------------------------

Simone,
thanks for the work you did regarding this issue, much appreciated. I take it it can access this new functionality from the latest download of cocoon 2.1.9?

regards

Andrew

> 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
>      Fix For: 2.1.10-dev (current SVN)
>  Attachments: javaflow-fomcocoon.diff
>
> 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


[jira] Commented: (COCOON-1804) Javascript FOM_SCOPE issue when using Java as the flow engine - ReferenceError: "cocoon" is not defined

Posted by "Andrew Madu (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/COCOON-1804?page=comments#action_12371273 ] 

Andrew Madu commented on COCOON-1804:
-------------------------------------

Reinhard,
how do I implement the javascript validator as a Java class within the controller IIRC? Can you point me in the direction of any code?

Andrew

> 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


[jira] Commented: (COCOON-1804) Javascript FOM_SCOPE issue when using Java as the flow engine - ReferenceError: "cocoon" is not defined

Posted by "Andrew Madu (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/COCOON-1804?page=comments#action_12371268 ] 

Andrew Madu commented on COCOON-1804:
-------------------------------------

In addition to my earlier post  the version of cocoon I am using is 2.1.7

Andrew

> 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