vgritsenko 02/02/28 06:53:41 Modified: . changes.xml src/webapp cocoon.xconf src/webapp/docs/samples sample-xsp.xml Added: src/webapp/docs/samples/xsp-js session.xsp src/java/org/apache/cocoon/components/language/markup/xsp/javascript session.xsl Log: Added session XSP logichseet in Javascript, document changes. Revision Changes Path 1.113 +4 -1 xml-cocoon2/changes.xml Index: changes.xml =================================================================== RCS file: /home/cvs/xml-cocoon2/changes.xml,v retrieving revision 1.112 retrieving revision 1.113 diff -u -r1.112 -r1.113 --- changes.xml 27 Feb 2002 14:48:16 -0000 1.112 +++ changes.xml 28 Feb 2002 14:53:41 -0000 1.113 @@ -4,7 +4,7 @@ <!-- History of Cocoon changes - $Id: changes.xml,v 1.112 2002/02/27 14:48:16 stefano Exp $ + $Id: changes.xml,v 1.113 2002/02/28 14:53:41 vgritsenko Exp $ --> <changes title="History of Changes"> @@ -32,6 +32,9 @@ </devs> <release version="@version@" date="@date@"> + <action dev="VG" type="add"> + Request, response, and session XSP logicsheets in Javascript language are added. + </action> <action dev="SM" type="add" due-to="Andreas Hartmann" due-to-email="[EMAIL PROTECTED]"> Added Cocoon link page. </action> 1.31 +7 -1 xml-cocoon2/src/webapp/cocoon.xconf Index: cocoon.xconf =================================================================== RCS file: /home/cvs/xml-cocoon2/src/webapp/cocoon.xconf,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- cocoon.xconf 18 Feb 2002 13:29:51 -0000 1.30 +++ cocoon.xconf 28 Feb 2002 14:53:41 -0000 1.31 @@ -259,7 +259,7 @@ XML interface to most methods of the HttpSession object (see the Java Servlet API Specification, version 2.2 ) for more information. --> <builtin-logicsheet> - <parameter name="prefix" value="session"/> + <parameter name="prefix" value="xsp-session"/> <parameter name="uri" value="http://apache.org/xsp/session/2.0"/> <parameter name="href" value="resource://org/apache/cocoon/components/language/markup/xsp/java/session.xsl"/> </builtin-logicsheet> @@ -353,6 +353,12 @@ <parameter name="prefix" value="xsp-response"/> <parameter name="uri" value="http://apache.org/xsp/response/2.0"/> <parameter name="href" value="resource://org/apache/cocoon/components/language/markup/xsp/javascript/response.xsl"/> + </builtin-logicsheet> + + <builtin-logicsheet> + <parameter name="prefix" value="xsp-session"/> + <parameter name="uri" value="http://apache.org/xsp/session/2.0"/> + <parameter name="href" value="resource://org/apache/cocoon/components/language/markup/xsp/javascript/session.xsl"/> </builtin-logicsheet> </target-language> 1.4 +6 -3 xml-cocoon2/src/webapp/docs/samples/sample-xsp.xml Index: sample-xsp.xml =================================================================== RCS file: /home/cvs/xml-cocoon2/src/webapp/docs/samples/sample-xsp.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- sample-xsp.xml 21 Feb 2002 03:02:09 -0000 1.3 +++ sample-xsp.xml 28 Feb 2002 14:53:41 -0000 1.4 @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- CVS: $Id: sample-xsp.xml,v 1.3 2002/02/21 03:02:09 vgritsenko Exp $ --> +<!-- CVS: $Id: sample-xsp.xml,v 1.4 2002/02/28 14:53:41 vgritsenko Exp $ --> <samples xmlns:xlink="http://www.w3.org/1999/xlink"> @@ -73,10 +73,13 @@ Another simple XSP example. </sample> <sample name="Request" href="xsp-js/request" xlink:role="dynamic"> - Request logicsheet tests - same as before, but in Javascript. + Request logicsheet tests (same as in Java). </sample> <sample name="Response" href="xsp-js/response" xlink:role="dynamic"> - Response logicsheet tests - same as before, but in Javascript. + Response logicsheet tests (same as in Java). + </sample> + <sample name="Session" href="xsp-js/session" xlink:role="dynamic"> + Session logicsheet tests (same as in Java). </sample> </group> </samples> 1.1 xml-cocoon2/src/webapp/docs/samples/xsp-js/session.xsp Index: session.xsp =================================================================== <?xml version="1.0" encoding="iso-8859-1"?> <!-- CVS: $Id: session.xsp,v 1.1 2002/02/28 14:53:41 vgritsenko Exp $ --> <xsp:page language="java" xmlns:xsp="http://apache.org/xsp" xmlns:xsp-session="http://apache.org/xsp/session/2.0"> <page> <p>Adding attribute attr1='Test Value!'.</p> <xsp-session:set-attribute name="attr1">Test value!</xsp-session:set-attribute> <p>Set max inactive interval to 500</p> <xsp-session:set-max-inactive-interval interval="500"/> <h1>xsp-session logicsheet output</h1> <table border="1"> <tr> <th>Logicsheet tag</th><th>Output</th></tr> <tr> <td>get-session-id</td><td><xsp-session:get-session-id/></td></tr> <tr> <td>get-attribute</td><td><xsp-session:get-attribute name="attr1"/></td></tr> <tr> <td>get-attribute-names</td><td><xsp:expr><xsp-session:get-attribute-names as="array"/></xsp:expr></td></tr> <tr> <td>get-creation-time</td><td><xsp-session:get-creation-time/></td></tr> <tr> <td>get-creation-time (string)</td><td><xsp-session:get-creation-time as="string"/></td></tr> <tr> <td>get-id</td><td><xsp-session:get-id/></td></tr> <tr> <td>get-last-accessed-time</td><td><xsp-session:get-last-accessed-time/></td></tr> <tr> <td>get-last-accessed-time (string)</td><td><xsp-session:get-last-accessed-time as="string"/></td></tr> <tr> <td>get-max-inactive-interval</td><td><xsp-session:get-max-inactive-interval/></td></tr> <tr> <td>is-new</td><td><xsp-session:is-new/></td></tr> </table> <h1>xsp-session logicsheet output (as xml)</h1> <textarea cols="100" rows="20"> get-session-id <xsp-session:get-session-id as="xml"/> get-attribute <xsp-session:get-attribute name="attr1" as="xml"/> get-attribute-names <xsp-session:get-attribute-names as="xml"/> get-creation-time <xsp-session:get-creation-time as="xml"/> get-id <xsp-session:get-id as="xml"/> get-last-accessed-time <xsp-session:get-last-accessed-time as="xml"/> get-max-inactive-interval <xsp-session:get-max-inactive-interval as="xml"/> is-new <xsp-session:is-new as="xml"/> encode-url <xsp-session:encode-url href="../" as="xml"/> form-encode-url <xsp-session:form-encode-url href="../"/> </textarea> <p>Removing attribute attr1</p> <xsp-session:remove-attribute name="attr1"/> <p>Invalidating session</p> <xsp-session:invalidate/> </page> </xsp:page> 1.1 xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp/javascript/session.xsl Index: session.xsl =================================================================== <?xml version="1.0"?> <!-- $Id: session.xsl,v 1.1 2002/02/28 14:53:41 vgritsenko Exp $--> <!-- ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact [EMAIL PROTECTED] 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. --> <!-- * XSP Session logicsheet for the Javascript language * * @author <a href="mailto:[EMAIL PROTECTED]>Ricardo Rocha</a> * @author ported by <a href="mailto:[EMAIL PROTECTED]>Berin Loritsch</a> * @author ported by <a href="mailto:[EMAIL PROTECTED]>Vadim Gritsenko</a> * @version CVS $Revision: 1.1 $ $Date: 2002/02/28 14:53:41 $ --> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsp="http://apache.org/xsp" xmlns:xsp-session="http://apache.org/xsp/session/2.0"> <!-- *** ServletSession Templates *** --> <xsl:template match="xsp-session:get-session-id"> <xsl:variable name="as"> <xsl:call-template name="value-for-as"> <xsl:with-param name="default" select="'string'"/> </xsl:call-template> </xsl:variable> <xsl:choose> <xsl:when test="$as = 'string'"> <xsp:expr> (request.getSession().getId()) </xsp:expr> </xsl:when> <xsl:when test="$as = 'xml'"> <!-- <xsp-session:session-id> --> <xsp:element name="xsp-session:session-id"> <xsp:expr> (request.getSession().getId()) </xsp:expr> </xsp:element> </xsl:when> </xsl:choose> </xsl:template> <xsl:template match="xsp-session:get-attribute"> <xsl:variable name="name"> <xsl:call-template name="value-for-name"/> </xsl:variable> <xsl:variable name="as"> <xsl:call-template name="value-for-as"> <xsl:with-param name="default" select="'object'"/> </xsl:call-template> </xsl:variable> <xsl:variable name="default"> <xsl:call-template name="value-for-default"> </xsl:call-template> </xsl:variable> <xsl:choose> <xsl:when test="$as = 'xml'"> <xsp:element name="xsp-session:attribute"> <xsp:expr> page.getSessionAttribute(String(<xsl:copy-of select="$name"/>), <xsl:copy-of select="$default"/>) </xsp:expr> </xsp:element> </xsl:when> <xsl:when test="$as = 'object'"> <xsp:expr> page.getSessionAttribute(String(<xsl:copy-of select="$name"/>), <xsl:copy-of select="$default"/>) </xsp:expr> </xsl:when> </xsl:choose> </xsl:template> <xsl:template match="xsp-session:get-attribute-names"> <xsl:variable name="as"> <xsl:call-template name="value-for-as"> <xsl:with-param name="default" select="'array'"/> </xsl:call-template> </xsl:variable> <xsl:choose> <xsl:when test="$as = 'xml'"> <xsp:logic> _session_attribute_names_ = page.getSessionAttributeNames(); </xsp:logic> <xsp:element name="xsp-session:attribute-names"> <xsp:logic> for (i = 0; i < _session_attribute_names_.length; i++) { <xsp:element name="xsp-session:attribute-name"> <xsp:expr>_session_attribute_names_[i]</xsp:expr> </xsp:element> } </xsp:logic> </xsp:element> </xsl:when> <xsl:when test="$as = 'array'"> <xsp:expr> page.getSessionAttributeNames() </xsp:expr> </xsl:when> </xsl:choose> </xsl:template> <xsl:template match="xsp-session:get-creation-time"> <xsl:variable name="as"> <xsl:call-template name="value-for-as"> <xsl:with-param name="default" select="'long'"/> </xsl:call-template> </xsl:variable> <xsl:choose> <xsl:when test="$as = 'xml'"> <xsp:element name="xsp-session:creation-time"> <xsp:expr> Date(request.getSession().getCreationTime()) </xsp:expr> </xsp:element> </xsl:when> <xsl:when test="$as = 'string'"> <xsp:expr> Date(request.getSession().getCreationTime()) </xsp:expr> </xsl:when> <xsl:when test="$as = 'long'"> <xsp:expr> request.getSession().getCreationTime() </xsp:expr> </xsl:when> </xsl:choose> </xsl:template> <xsl:template match="xsp-session:get-id"> <xsl:variable name="as"> <xsl:call-template name="value-for-as"> <xsl:with-param name="default" select="'string'"/> </xsl:call-template> </xsl:variable> <xsl:choose> <xsl:when test="$as = 'xml'"> <xsp:element name="xsp-session:id"> <xsp:expr>request.getSession().getId()</xsp:expr> </xsp:element> </xsl:when> <xsl:when test="$as = 'string'"> <xsp:expr>request.getSession().getId()</xsp:expr> </xsl:when> </xsl:choose> </xsl:template> <xsl:template match="xsp-session:get-last-accessed-time"> <xsl:variable name="as"> <xsl:call-template name="value-for-as"> <xsl:with-param name="default" select="'long'"/> </xsl:call-template> </xsl:variable> <xsl:choose> <xsl:when test="$as = 'xml'"> <xsp:element name="xsp-session:last-accessed-time"> <xsp:expr> Date(request.getSession().getLastAccessedTime()) </xsp:expr> </xsp:element> </xsl:when> <xsl:when test="$as = 'string'"> <xsp:expr> Date(request.getSession().getLastAccessedTime()) </xsp:expr> </xsl:when> <xsl:when test="$as = 'long'"> <xsp:expr> request.getSession().getLastAccessedTime() </xsp:expr> </xsl:when> </xsl:choose> </xsl:template> <xsl:template match="xsp-session:get-max-inactive-interval"> <xsl:variable name="as"> <xsl:call-template name="value-for-as"> <xsl:with-param name="default" select="'int'"/> </xsl:call-template> </xsl:variable> <xsl:choose> <xsl:when test="$as = 'xml'"> <xsp:element name="xsp-session:max-inactive-interval"> <xsp:expr> request.getSession().getMaxInactiveInterval() </xsp:expr> </xsp:element> </xsl:when> <xsl:when test="$as = 'string'"> <xsp:expr> String(request.getSession().getMaxInactiveInterval()) </xsp:expr> </xsl:when> <xsl:when test="$as = 'int'"> <xsp:expr> request.getSession().getMaxInactiveInterval() </xsp:expr> </xsl:when> </xsl:choose> </xsl:template> <xsl:template match="xsp-session:invalidate"> <xsp:logic> request.getSession().invalidate(); </xsp:logic> </xsl:template> <xsl:template match="xsp-session:is-new"> <xsl:variable name="as"> <xsl:call-template name="value-for-as"> <xsl:with-param name="default" select="'boolean'"/> </xsl:call-template> </xsl:variable> <xsp:expr> <xsl:choose> <xsl:when test="$as = 'xml'"> <xsp:element name="xsp-session:is-new"> <xsp:expr>request.getSession().isNew()</xsp:expr> </xsp:element> </xsl:when> <xsl:when test="$as = 'string'"> <xsp:expr>String(request.getSession().isNew())</xsp:expr> </xsl:when> <xsl:when test="$as = 'boolean'"> <xsp:expr>request.getSession().isNew()</xsp:expr> </xsl:when> </xsl:choose> </xsp:expr> </xsl:template> <xsl:template match="xsp-session:remove-attribute"> <xsl:variable name="name"> <xsl:call-template name="value-for-name"/> </xsl:variable> <xsp:logic> request.getSession().removeAttribute(String(<xsl:copy-of select="$name"/>)); </xsp:logic> </xsl:template> <xsl:template match="xsp-session:set-attribute"> <xsl:variable name="name"> <xsl:call-template name="value-for-name"/> </xsl:variable> <xsl:variable name="content"> <xsl:call-template name="get-nested-content"> <xsl:with-param name="content" select="."/> </xsl:call-template> </xsl:variable> <xsp:logic> request.getSession().setAttribute( String(<xsl:copy-of select="$name"/>), <xsl:copy-of select="$content"/>); </xsp:logic> </xsl:template> <xsl:template match="xsp-session:set-max-inactive-interval"> <xsl:variable name="interval"> <xsl:choose> <xsl:when test="@interval">"<xsl:value-of select="@interval"/>"</xsl:when> <xsl:when test="xsp-session:interval"> <xsl:call-template name="get-nested-content"> <xsl:with-param name="content" select="xsp-session:interval"/> </xsl:call-template> </xsl:when> </xsl:choose> </xsl:variable> <xsp:logic> request.getSession().setMaxInactiveInterval(String(<xsl:copy-of select="$interval"/>)); </xsp:logic> </xsl:template> <!-- encode an URL with the session ID --> <xsl:template match="xsp-session:encode-url"> <xsl:variable name="href">"<xsl:value-of select="@href"/>"</xsl:variable> <xsp:element name="a"> <xsp:attribute name="href"> <xsp:expr> response.encodeURL(String(<xsl:copy-of select="$href"/>)) </xsp:expr> </xsp:attribute> <xsl:value-of select="."/> </xsp:element> </xsl:template> <!-- encode an URL with the session ID as a form--> <xsl:template match="xsp-session:form-encode-url"> <xsl:variable name="action">"<xsl:value-of select="@action"/>"</xsl:variable> <xsl:variable name="method">"<xsl:value-of select="@method"/>"</xsl:variable> <xsl:variable name="onsubmit">"<xsl:value-of select="@onsubmit"/>"</xsl:variable> <xsp:element name="form"> <xsp:attribute name="action"> <xsp:expr> response.encodeURL(String(<xsl:copy-of select="$action"/>)) </xsp:expr> </xsp:attribute> <xsp:attribute name="method"> <xsp:expr><xsl:copy-of select="$method"/></xsp:expr> </xsp:attribute> <xsp:attribute name="onsubmit"> <xsp:expr><xsl:copy-of select="$onsubmit"/></xsp:expr> </xsp:attribute> <xsl:apply-templates/> </xsp:element> </xsl:template> <xsl:template name="value-for-name"> <xsl:choose> <xsl:when test="@name">"<xsl:value-of select="@name"/>"</xsl:when> <xsl:when test="xsp-session:name"> <xsl:call-template name="get-nested-content"> <xsl:with-param name="content" select="xsp-session:name"/> </xsl:call-template> </xsl:when> </xsl:choose> </xsl:template> <xsl:template name="get-nested-content"> <xsl:param name="content"/> <xsl:choose> <xsl:when test="$content/xsp:text">"<xsl:value-of select="$content"/>"</xsl:when> <xsl:when test="$content/*"> <xsl:apply-templates select="$content/*"/> </xsl:when> <xsl:otherwise>"<xsl:value-of select="$content"/>"</xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name="value-for-as"> <xsl:param name="default"/> <xsl:choose> <xsl:when test="@as"><xsl:value-of select="@as"/></xsl:when> <xsl:otherwise><xsl:value-of select="$default"/></xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name="value-for-default"> <xsl:choose> <xsl:when test="@default">"<xsl:value-of select="@default"/>"</xsl:when> <xsl:otherwise>""</xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="@*|*|text()|processing-instruction()"> <xsl:copy> <xsl:apply-templates select="@*|*|text()|processing-instruction()"/> </xsl:copy> </xsl:template> </xsl:stylesheet>
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]