cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From paint...@mc.duke.edu
Subject Re: populateDocument global variables
Date Fri, 27 Apr 2001 16:42:23 GMT

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>


Mime
View raw message