cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "SANSONE, AARON M [Non-Pharmacia/1000]" <aaron.m.sans...@monsanto.com>
Subject SessionParamAction or Updated RequestParamAction?
Date Thu, 18 Oct 2001 16:31:31 GMT
Hi everyone,

I needed to make some session attributes available to the sitemap.  Looking
through the Cocoon API, I can't find such an action.  The RequestParamAction
is the closest to what I need but it is only for the Request object.  I have
written a SessionParamAction that mirrors what the RequestParamAction does
except that it works for the session.  

My question is, should I contribute this to the Project?  Secondly, if this
is to be contributed, I am in a quandary as to where this code belongs.
Currently the existing RequestParamAction places the Request Parameters into
the Map only if the "parameters" value is set to true:

<map:act type="request">
  <map:parameter name="parameters" value="true"/>
  <map:generate src="users/menu-{id}.xml"/>
</map:act>

A new SessionParamAction could make the previous code look like:

<map:act type="request">
  <map:act type="session">
    <map:parameter name="parameters" value="true"/>
    <map:generate src="{sessionpath}/users/menu-{id}.xml"/>
  </map:act>  
</map:act>

 I could easily refactor the RequestParamAction to take a separate parameter
for the session attributes thus simplifying the previous code to:

<map:act type="request">
  <map:parameter name="parameters" value="true"/>
  <map:parameter name="session_attributes" value="true"/>
  <map:generate src="{sessionpath}/users/menu-{id}.xml"/>
</map:act>

Or create a new Action (RequestSessionParamAction)

<map:act type="request-session">
  <map:parameter name="parameters" value="true"/>
  <map:parameter name="attributes" value="true"/>
  <map:generate src="{sessionpath}/users/menu-{id}.xml"/>
</map:act>

One issue with either approach is the precedence of request values vs.
session values of the same name.  I believe that in the case where the
request and session actions are separated, the precedence is dependant on
which action is specified last.  For example if request has a parameter
name=Aaron and the session has an attribute name=Michael then if the session
is specified after the request, the substitution of the {name} would yield
Michael from the session action.

This is predictable and easily changed if you wish to have the request take
precedence over the session by switching the order in the sitemap.  If it is
refactored to a single Action that doesn't replace the RequestParamAction
(i.e. RequestSessionParameterAction) an additional parameter would need to
be provided to change the order of precedence (assuming some default).

What would be the best solution?

This is a similar question to one that I just read from Paolo. 

Thanks,
Aaron

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Mime
View raw message