vgritsenko 02/05/30 05:58:13 Modified: src/documentation/xdocs/developing Tag: cocoon_2_0_3_branch sunshine-contexts.xml Log: fit into screen Revision Changes Path No revision No revision 1.2.2.2 +183 -154 xml-cocoon2/src/documentation/xdocs/developing/Attic/sunshine-contexts.xml Index: sunshine-contexts.xml =================================================================== RCS file: /home/cvs/xml-cocoon2/src/documentation/xdocs/developing/Attic/sunshine-contexts.xml,v retrieving revision 1.2.2.1 retrieving revision 1.2.2.2 diff -u -r1.2.2.1 -r1.2.2.2 --- sunshine-contexts.xml 24 May 2002 14:06:28 -0000 1.2.2.1 +++ sunshine-contexts.xml 30 May 2002 12:58:13 -0000 1.2.2.2 @@ -9,12 +9,12 @@ </header> <body> <s1 title="Introduction"> - <p>IMPORTANT: sunShine is part of the scratchpad area of Cocoon. This means it + <note><strong>IMPORTANT:</strong> sunShine is part of the scratchpad area of Cocoon. This means it is not officially released yet. The API and functionality might change before it is moved into the official release. Using this is at your own risk! If you want to catch the latest status of these components check out Cocoon from CVS! - </p> + </note> <p>A session is a data storage which resides on the server and records information about one single user. sunShine creates a session on demand and from that point of time the user is tracked and information can be stored @@ -109,31 +109,34 @@ data.</p> <source> <resource xmlns:sunshine="http://cocoon.apache.org/sunshine/1.0"> - <sunshine:createcontext name="trackdemo"/> - <!-- build context data --> - <sunshine:setxml context="trackdemo" path="/"> - <context> - <users> - <user id="1"> - <name>Carsten</name> - </user> - </users> - </context> - </sunshine:setxml> - <sunshine:mergexml context="trackdemo" path="/context"> - <users> - <user id="1"> - <name>Ziegeler</name> - <developer>true</developer> - </user> - <user id="2"> - <name>Walter</name> - </user> - </users> - </sunshine:mergexml> - <sunshine:getxml context="trackdemo" path="/"/> -</resource> -</source> + <sunshine:createcontext name="trackdemo"/> + + <!-- build context data --> + <sunshine:setxml context="trackdemo" path="/"> + <context> + <users> + <user id="1"> + <name>Carsten</name> + </user> + </users> + </context> + </sunshine:setxml> + + <sunshine:mergexml context="trackdemo" path="/context"> + <users> + <user id="1"> + <name>Ziegeler</name> + <developer>true</developer> + </user> + <user id="2"> + <name>Walter</name> + </user> + </users> + </sunshine:mergexml> + + <sunshine:getxml context="trackdemo" path="/"/> +</resource></source> + <p>In the above example, a context for storing data is added. Using the <em>setxml</em> command data is then stored into the context. The following <em>mergexml</em> command then changes the name of user-1 and adds a further @@ -211,76 +214,81 @@ <p>The complete context you can access via these commands has the following XML format:</p> <source> - <parameter> <-- All parameters: parameter names build the elements with the values as text node childs --> - <firstparameter>value of parameter</firstparameter> - <secondparameter>value of parameter</secondparameter> - </parameter> - - <querystring>the querystring with a leading '?' or empty<querystring> - (The querystring contains only parameters send by the GET method) - - <parametervalues> <-- All parameters. The tags are all inside the sunshine namespace. - The generated xml can be used without modification for the - sunshine:connection command. --> - - <sunshine:params> - <sunshine:param> - <sunshine:name>1st parameter name</sunshine:name> - <sunshine:value>1st parameter value</sunshine:value> - </sunshine:param> - ... - <sunshine:param> - <sunshine:name>2nd parameter name</sunshine:name> - <sunshine:value>2nd parameter value</sunshine:value> - </sunshine:param> - </sunshine:params> - - <!-- If a parameter has more than one value, for each value a - <sunshine:param> block is generated. --> - </parametervalues> - - <attributes> <!-- lists all attributes, attribute names build the elements - with the values as text node childs --> - </attributes> - - <headers> <!-- lists all headers, header names build the elements - with the values as text node childs --> - </headers> - - <cookies> <!-- lists all cookies --> - <cookie name="..."> - <value>the cookie value</value> - <name>the name of the cookie</name> - <comment>value</comment> - <domain>value</domain> - <path>value</path> - <maxAge>value</maxAge> - <secure>value</secure> - <version>value</version> - </cookie> - </cookies> - - <characterEncoding>value</characterEncoding> - <contentLength>value</contentLength> - <contentType>value</contentType> - <protocol>value</protocol> - <remoteAddress>value</remoteAddress> - <remoteHost>value</remoteHost> - <scheme>value</scheme> - <serverName>value</serverName> - <serverPort>value</serverPort> - <authType>value</authType> - <method>value</method> - <contextPath>value</contextPath> - <pathInfo>value</pathInfo> - <pathTranslated>value</pathTranslated> - <remoteUser>value</remoteUser> - <requestedSessionId>value</requestedSessionId> - <requestURI>value</requestURI> - <servletPath>value</servletPath> - <isRequestedSessionIdFromCookie>value</isRequestedSessionIdFromCookie> - <isRequestedSessionIdFromCookie>value</isRequestedSessionIdFromCookie> - <isRequestedSessionIdValid>value</isRequestedSessionIdValid> +<parameter> + <-- All parameters: parameter names build the elements + with the values as text node childs --> + <firstparameter>value of parameter</firstparameter> + <secondparameter>value of parameter</secondparameter> +</parameter> + +<-- The querystring contains only parameters send by the GET method --> +<querystring>the querystring with a leading '?' or empty<querystring> + +<-- All parameters. The tags are all inside the sunshine namespace. + The generated xml can be used without modification for the + sunshine:connection command. --> +<parametervalues> + <sunshine:params> + <sunshine:param> + <sunshine:name>1st parameter name</sunshine:name> + <sunshine:value>1st parameter value</sunshine:value> + </sunshine:param> + ... + <sunshine:param> + <sunshine:name>2nd parameter name</sunshine:name> + <sunshine:value>2nd parameter value</sunshine:value> + </sunshine:param> + </sunshine:params> + + <!-- If a parameter has more than one value, for each value a + <sunshine:param> block is generated. --> +</parametervalues> + +<!-- lists all attributes, attribute names build the elements + with the values as text node childs --> +<attributes> +</attributes> + +<!-- lists all headers, header names build the elements + with the values as text node childs --> +<headers> +</headers> + +<!-- lists all cookies --> +<cookies> + <cookie name="..."> + <value>the cookie value</value> + <name>the name of the cookie</name> + <comment>value</comment> + <domain>value</domain> + <path>value</path> + <maxAge>value</maxAge> + <secure>value</secure> + <version>value</version> + </cookie> +</cookies> + +<characterEncoding>value</characterEncoding> +<contentLength>value</contentLength> +<contentType>value</contentType> +<protocol>value</protocol> +<remoteAddress>value</remoteAddress> +<remoteHost>value</remoteHost> +<scheme>value</scheme> +<serverName>value</serverName> +<serverPort>value</serverPort> +<authType>value</authType> +<method>value</method> +<contextPath>value</contextPath> +<pathInfo>value</pathInfo> +<pathTranslated>value</pathTranslated> +<remoteUser>value</remoteUser> +<requestedSessionId>value</requestedSessionId> +<requestURI>value</requestURI> +<servletPath>value</servletPath> +<isRequestedSessionIdFromCookie>value</isRequestedSessionIdFromCookie> +<isRequestedSessionIdFromCookie>value</isRequestedSessionIdFromCookie> +<isRequestedSessionIdValid>value</isRequestedSessionIdValid> </source> </s2> <s2 title="The Response Context - Accessing the Environment, Part Two"> @@ -297,29 +305,33 @@ <em>appendxml</em>. If <em>setxml</em> is used, the header with the name gets the given value, regardless if the header had any value beforehand or not. If <em>appendxml</em> is used the value will be added.</p> - <source><sunshine:setxml context="response" path="/header/headername">The value</sunshine:setxml> + <source> +<sunshine:setxml context="response" + path="/header/headername">The value</sunshine:setxml> or -<sunshine:appendxml context="response" path="/header/headername">The value</sunshine:appendxml></source> +<sunshine:appendxml context="response" + path="/header/headername">The value</sunshine:appendxml></source> </s3> <s3 title="Adding cookies"> <p>Cookies can be added either by setxml or by appendxml. There is no difference between these commands.</p> - <source><sunshine:setxml context="response" path="/cookie"> - <!-- Now follows the cookie definition --> - <name>The cookie name</name> - <value>The value of the cookie</value> - - <!-- The following are optional --> - <path>value</path> - <domain>value</domain> - <secure>true or false</secure> - <comment>value</comment> - <maxAge>value</maxAge> - <version>value</version> -</sunshine:setxml> - </source> + <source> +<sunshine:setxml context="response" path="/cookie"> + <!-- Now follows the cookie definition --> + <name>The cookie name</name> + <value>The value of the cookie</value> + + <!-- The following are optional --> + <path>value</path> + <domain>value</domain> + <secure>true or false</secure> + <comment>value</comment> + <maxAge>value</maxAge> + <version>value</version> +</sunshine:setxml></source> + </s3> </s2> <s2 title="The Temporary Context"> @@ -350,48 +362,56 @@ <p>If you want to create a form with two values - forename and surname of the user, you could generate a base xml file with the information about this form:</p> - <source><page> - <form> - <action>form-handling-page</action> - <input name="forename" type="text"/> - <input name="surname" type="text"/> - </form> + <source> +<page> + <form> + <action>form-handling-page</action> + <input name="forename" type="text"/> + <input name="surname" type="text"/> + </form> </page></source> + <p>A stylesheet can transform this into valid html. The action tag indicates that the "form-handling-page" should be invoked by submitting the values.</p> <p>The "form-handling-page" is a pipeline which is declared in the sitemap and uses the sunShine transformer. It could also read the following xml:</p> - <source><page xmlns:sunshine="http://cocoon.apache.org/sunshine/1.0"> - <forename> - <sunshine:getxml context="request" path="/parameter/forename"/> - </forename> - <surname> - <sunshine:getxml context="request" path="/parameter/surname"/> - </surname> + <source> +<page xmlns:sunshine="http://cocoon.apache.org/sunshine/1.0"> + <forename> + <sunshine:getxml context="request" path="/parameter/forename"/> + </forename> + <surname> + <sunshine:getxml context="request" path="/parameter/surname"/> + </surname> </page></source> + <p>As the form values are appended to the request, <em>getxml</em> with specifying the path (which is the parameter name used for the input field) inserts the value submitted by the user into the xml stream.</p> <p>If you want to write the information in a session context, you must wrap the whole xml inside a setxml:</p> - <source><page xmlns:sunshine="http://cocoon.apache.org/sunshine/1.0"> + <source> +<page xmlns:sunshine="http://cocoon.apache.org/sunshine/1.0"> <sunshine:setxml context="userdata" path="/user"> <forename> - <sunshine:getxml context="request" path="/parameter/forename"/> + <sunshine:getxml context="request" path="/parameter/forename"/> </forename> <surname> - <sunshine:getxml context="request" path="/parameter/surname"/> + <sunshine:getxml context="request" path="/parameter/surname"/> </surname> </sunshine:setxml> </page></source> + <p>The user data is now stored inside the session context "userdata", so the context has the following content:</p> - <source><user> - <forename>Walter</forename> - <surname>Walterson</surname> + <source> +<user> + <forename>Walter</forename> + <surname>Walterson</surname> </user></source> + </s2> <s2 title="The sunShine approach"> <p>The previous chapter showed the common approach for handling form @@ -402,17 +422,19 @@ and in addition the information about where the submitted values should be stored inside the session.</p> <p>The example from the previous chapter could look like this:</p> - <source><page xmlns:sunshine="http://cocoon.apache.org/sunshine/1.0"> - <sunshine:form name="myform"> - <sunshine:action>the-next-page</sunshine:action> - <sunshine:content> - <sunshine:inputxml name="forename" type="text" - context="userdata" path="/user/forename"/> - <sunshine:inputxml name="surname" type="text" - context="userdata" path="/user/surname"/> - </sunshine:content> - </sunshine:form> + <source> +<page xmlns:sunshine="http://cocoon.apache.org/sunshine/1.0"> + <sunshine:form name="myform"> + <sunshine:action>the-next-page</sunshine:action> + <sunshine:content> + <sunshine:inputxml name="forename" type="text" + context="userdata" path="/user/forename"/> + <sunshine:inputxml name="surname" type="text" + context="userdata" path="/user/surname"/> + </sunshine:content> + </sunshine:form> </page></source> + <p>The form tag starts the form definition. The name attribute is required to distinct between different forms on the same page. The action tag defines the url invoked by the form and the content tag describes the content @@ -421,12 +443,14 @@ contains form values which should be stored in the specified context under the given path. The sunShine transformer transforms by removing the namespace and the context attribute:</p> - <source><page xmlns:sunshine="http://cocoon.apache.org/sunshine/1.0"> - <form action="the-next-page"> - <inputxml name="forename" type="text"/> - <inputxml name="surname" type="text"/> - </form> + <source> +<page xmlns:sunshine="http://cocoon.apache.org/sunshine/1.0"> + <form action="the-next-page"> + <inputxml name="forename" type="text"/> + <inputxml name="surname" type="text"/> + </form> </page></source> + <p>A stylesheet can now generate the appropriate html (or any other format). The main difference is, that the resource invoked by submitting the values has not to care about the form as sunShine maintains the form handling. @@ -437,17 +461,22 @@ <p>For editing values - if the context already contains information about the user - <em>inputxml</em> inserts the current value inside the tag. So the xml streamed would after a second run would look like this:</p> - <source><page xmlns:sunshine="http://cocoon.apache.org/sunshine/1.0"> - <form action="the-next-page"> - <inputxml name="forename" type="text">Walter</inputxml> - <inputxml name="surname" type="text">Walterson</inputxml> - </form> + <source> +<page xmlns:sunshine="http://cocoon.apache.org/sunshine/1.0"> + <form action="the-next-page"> + <inputxml name="forename" type="text">Walter</inputxml> + <inputxml name="surname" type="text">Walterson</inputxml> + </form> </page></source> + <p>Like <em>getxml</em> it is also possible to provide default values for the input field, if the context does not contain any information:</p> - <source><sunshine:inputxml name="forename" context="userdata" path="/user/forename"> - Defaultname + <source> +<sunshine:inputxml name="forename" context="userdata" + path="/user/forename"> + Defaultname </sunshine:xml></source> + </s2> </s1> </body>
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]