cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From KOZLOV Roman <r-koz...@opencascade.com>
Subject Session attribute change within aggregation
Date Tue, 02 Apr 2002 16:11:22 GMT
Hi,

Is it possible in Cocoon 2.01 to set session attribute within
aggregation so that the change would be in a first part (xsp) and next
part could use the new value of the changed attribute. It seems that the
new value is not available for the rest parts of aggregation within the
same request.
If it is true, then how is it possible to make a branch comparing a
request parameter's value with some session attribute's value?
In particular, I'd like to store some parameter as a session attribute
and if it is not changed then read query results stored as DOM in a
session before, otherwise update query results. My xsp part of
aggregation is the following:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsp:page
   language="java"
   xmlns:xsp="http://apache.org/xsp"
   xmlns:xsp-request="http://apache.org/xsp/request/2.0"
   xmlns:session="http://apache.org/xsp/session/2.0"
   xmlns:util="http://apache.org/xsp/util/2.0"
   create-session="true">
 <page>
   <xsp:logic>
     String idList = (String)<xsp-request:get-parameter name="idList"
default=""/>;
     String idListOld = (String)<session:get-attribute name="idList"
default=""/>;
     String isChanged = (idList.equals(idListOld))?"no":"yes";
   </xsp:logic>
   <session:set-attribute
name="idList"><xsp:logic><xsp:expr>idList</xsp:expr></xsp:logic></session:set-attribute>

   <session:set-attribute
name="isChanged"><xsp:logic><xsp:expr>isChanged</xsp:expr></xsp:logic></session:set-attribute>


<idList><xsp:logic><util:expr><xsp:expr>idList</xsp:expr></util:expr></xsp:logic></idList>


<isChanged><xsp:logic><util:expr><xsp:expr>isChanged</xsp:expr></util:expr></xsp:logic></isChanged>

   </page>
</xsp:page>

The second part of aggregation calls the following via cocoon://
protocol:

<map:match pattern="read_filtered_results">
  <map:match type="sessionstate" pattern="yes">
      <map:parameter name="attribute-name" value="isChanged"/>
      <!-- Update filtered result -->
      <map:generate src="cocoon://read_query_results"/>
      <map:serialize type="xml"/>
  </map:match>
  <!-- if idList is not changed try to read stored filtered result -->
  <map:match type="sessionstate" pattern="**">
      <map:parameter name="attribute-name" value="filtered_results"/>
      <!-- Read filtered result if it was already stored -->
      <map:generate src="data/null.xml"/>
      <map:transform type="readDOMsession">
          <map:parameter name="dom-name" value="filtered_results"/>
          <map:parameter name="trigger-element" value="null"/>
          <map:parameter name="position" value="in"/>
      </map:transform>
      <map:serialize type="xml"/>
  </map:match>
  <!-- Create filtered result if it was not stored before -->
  <map:generate src="cocoon://read_query_results"/>
  <map:serialize type="xml"/>
</map:match>

So the problem is that after changing idList parameter I have to call
the aggregating pipeline twice (i.e. to make two requests from browser
with the same idList parameter) to get an updated query result.

Thank you very much for any advice.
    Roman


---------------------------------------------------------------------
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