cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From u..@apache.org
Subject cvs commit: cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/fom FOM_Cocoon.java
Date Tue, 02 Sep 2003 20:49:21 GMT
ugo         2003/09/02 13:49:21

  Modified:    src/java/org/apache/cocoon/components/flow/javascript/fom
                        FOM_Cocoon.java
  Log:
  Fix for FOM cocoon.request.getCookies()'s cookies can't be read.
  PR: 22526
  Submitted by: g.brand@interface-business.de (Gunnar Brand)
  
  Revision  Changes    Path
  1.11      +24 -5     cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/fom/FOM_Cocoon.java
  
  Index: FOM_Cocoon.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/fom/FOM_Cocoon.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- FOM_Cocoon.java	26 Aug 2003 09:05:52 -0000	1.10
  +++ FOM_Cocoon.java	2 Sep 2003 20:49:21 -0000	1.11
  @@ -71,6 +71,7 @@
   import org.apache.cocoon.environment.Request;
   import org.apache.cocoon.environment.Response;
   import org.apache.cocoon.environment.Session;
  +import org.mozilla.javascript.Context;
   import org.mozilla.javascript.JavaScriptException;
   import org.mozilla.javascript.Script;
   import org.mozilla.javascript.Scriptable;
  @@ -401,13 +402,31 @@
           
           public FOM_Cookie[] jsFunction_getCookies() {
               Cookie[] cookies = request.getCookies();
  -            FOM_Cookie[] FOM_cookies = new FOM_Cookie[cookies.length];
  -            for (int i = 0 ; i < cookies.length ; ++i) {
  -                FOM_cookies[i] = new FOM_Cookie(cookies[i]);
  +            FOM_Cookie[] FOM_cookies = new FOM_Cookie[cookies!=null ? cookies.length :
0];
  +            for (int i = 0 ; i < FOM_cookies.length ; ++i) {
  +                FOM_Cookie FOM_cookie = new FOM_Cookie(cookies[i]);
  +                FOM_cookie.setParentScope(getParentScope());
  +                FOM_cookie.setPrototype(getClassPrototype(this, FOM_cookie.getClassName()));
  +                FOM_cookies[i] = FOM_cookie;
               }
               return FOM_cookies;
           }
           
  +        public Scriptable jsGet_cookies() {
  +            return Context.getCurrentContext().newArray(getParentScope(), jsFunction_getCookies());
  +        }
  +            
  +        public FOM_Cookie jsFunction_getCookie(String name) {
  +            Object     cookie  = request.getCookieMap().get(name);
  +            FOM_Cookie fcookie = null;
  +            if ( cookie!=null ) {
  +                fcookie = new FOM_Cookie(cookie);
  +                fcookie.setParentScope(getParentScope());
  +                fcookie.setPrototype(getClassPrototype(this, fcookie.getClassName()));
  +            }
  +            return fcookie;
  +        }
  +        
           public String jsFunction_getHeader(String name) {
               return request.getHeader(name);
           }
  @@ -526,7 +545,7 @@
               FOM_Cookie result = 
                   new FOM_Cookie(response.createCookie(name, value));
               result.setParentScope(getParentScope());
  -            result.setPrototype(getClassPrototype(this, "FOM_Cookie"));
  +            result.setPrototype(getClassPrototype(this, result.getClassName()));
               return result;
           }
   
  
  
  

Mime
View raw message