cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h...@apache.org
Subject cvs commit: xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp XSPRequestHelper.java
Date Fri, 09 Aug 2002 08:29:43 GMT
haul        2002/08/09 01:29:43

  Modified:    src/java/org/apache/cocoon/components/language/markup/xsp
                        XSPRequestHelper.java
  Log:
    <action dev="CH" type="fix">
     Request logicsheet: Fix session tags.
    </action>
  
  Revision  Changes    Path
  1.13      +38 -1     xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp/XSPRequestHelper.java
  
  Index: XSPRequestHelper.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp/XSPRequestHelper.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- XSPRequestHelper.java	17 Jun 2002 02:27:16 -0000	1.12
  +++ XSPRequestHelper.java	9 Aug 2002 08:29:43 -0000	1.13
  @@ -53,6 +53,7 @@
   import org.apache.cocoon.Constants;
   import org.apache.cocoon.environment.ObjectModelHelper;
   import org.apache.cocoon.environment.Request;
  +import org.apache.cocoon.environment.Session;
   
   import org.xml.sax.ContentHandler;
   import org.xml.sax.SAXException;
  @@ -526,5 +527,41 @@
   
           uribuf.append(request.getRequestURI());
           return uribuf.toString();
  +    }
  +
  +    /**
  +     * Return the given session attribute value or a user-provided default if
  +     * none was specified.
  +     *
  +     * @param objectModel The Map objectModel
  +     * @param name The attribute name
  +     * @param defaultValue Value to substitute in absence of a attribute value
  +     */
  +    public static Object getSessionAttribute(Map objectModel, String name,
  +                                             Object defaultValue ) {
  +
  +        Session session = ObjectModelHelper.getRequest(objectModel).getSession();
  +        Object obj = session.getAttribute(name);
  +        return (obj != null ? obj : defaultValue );
  +    }
  +
  +    /**
  +     * Output the given session attribute value or a user-provided default if
  +     * none was specified.
  +     *
  +     * @param objectModel The Map objectModel
  +     * @param contentHandler The SAX content handler
  +     * @param name The attribute name
  +     * @param defaultValue Value to substitute in absence of an attribute value
  +     * @exception SAXException If a SAX error occurs
  +     */
  +    public static void getSessionAttribute(Map objectModel, ContentHandler contentHandler,
  +                                           String name, Object defaultValue)
  +        throws SAXException {
  +        AttributesImpl attr = new AttributesImpl();
  +        XSPObjectHelper.addAttribute(attr, "name", name);
  +
  +        XSPObjectHelper.elementData(URI, PREFIX, contentHandler, "parameter",
  +            getSessionAttribute(objectModel, name, defaultValue).toString(), attr);
       }
   }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message