cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sylvain Wallez <sylvain.wal...@anyware-tech.com>
Subject Re: populateDocument global variables
Date Wed, 02 May 2001 16:31:57 GMT
Hey, you don't need that complexity ! Just include local variable
declarations in <xsp:logic> :

<xsp:page>
  <blah>
    <xsp:logic>
      int id_from =
((Integer)session.getAttribute("id_from")).intValue();
      ... other variables
    </xsp:logic>
    <p>The "from" value is <xsp:expr>id_from</xsp:expr></p>
...

paint007@mc.duke.edu a écrit :
> 
> Oskar,
> 
> I assume you mean you want to add in some variables and code near the top
> of the populateDocument() method, before any of your regular XSP code.  The
> only way I know to do this is with a taglib.  I've seen a couple of
> different approaches in the taglibs that come with Cocoon, but we are using
> this template in our logicsheets to put code in near the top of populate
> document (I think this example is similar to what you want):
> 
> <xsl:template match="xsp:page/*[not(starts-with(name(.), 'xsp:'))]">
>  <xsl:copy>
>   <xsl:apply-templates select="@*"/>
>   <xsp:logic>
>         HttpSession     swiftUserSession        = request.getSession();
>         String          swiftLoginName          = (String) swiftUserSession.getAttribute("loginName");
>   </xsp:logic>
>   <xsl:apply-templates/>
>  </xsl:copy>
> </xsl:template>
> 
> To make the request.getSession() have a true parameter, add in the
> create-session="true" attribute to the <xsp:page> element in your xml.
> 
> -Christopher
> 
> Subject:  populateDocument global variables
> 
> Hi everyone, I want to add to the "populateDocument" method, some
> global variables:
> 
>        public void populateDocument(
>          HttpServletRequest request,
>          HttpServletResponse response,
>          Document document
>        )
>          throws Exception
>        {
>          Node xspParentNode = null;
>          Node xspCurrentNode = document;
>          Stack xspNodeStack = new Stack();
>          HttpSession session = request.getSession(false);
> 
>          There I want to add something like that:
> 
>                         int id_from = ((Integer)session.getAttribute
> ("id_from")).intValue();
>                         int id_count = ((Integer)session.getAttribute
> ("id_count")).intValue();
>                         String language = (String)session.getAttribute
> ("language");
> 
>      And I also want the "getSession" to have true parameter.
> 
> Can anybody tell me if it is possible to do this, and if how to do it?
> (The purpose is to read parameters before the document is build)
> Thank you for your help!
> 
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
> 
> To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
> For additional commands, e-mail: <cocoon-users-help@xml.apache.org>

-- 
Sylvain Wallez
Anyware Technologies - http://www.anyware-tech.com

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>


Mime
View raw message