You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Lionel Crine <cr...@4dconcept.fr> on 2003/07/28 09:36:59 UTC

trouble with session attribute

Hi,

I've some trouble with session attribute. Here is what I try :

The sitemap:
      <map:match pattern="addUser">
         <map:generate type="MyGenerator" src="user.xml" />
         <map:transform type=MyTransformerAddUser" />
         <map:select type="session_selector">
           <map:parameter name="attribute-name" value="errorUser" />
           <map:when test="UserAlready">
             <map:transform type="xslt" src="xsl/error_User.xsl">
               <map:parameter name="errorUser"
               value="{session-attr:errorUser}" />
             </map:transform>
           </map:when>
           <map:when test="UserOk">
             <map:transform type="xslt" src="xsl/error_User.xsl">
               <map:parameter name="errorUser"
               value="{session-attr:errorUser}" />
             </map:transform>
                  </map:when>
         </map:select>
         <map:serialize type="xml" />
       </map:match>



In MyTransformerAddUser,I manage the session like this :

public class IXIASOFTTransformerAddUser
extends AbstractDOMTransformer
implements Transformer, DOMBuilder.Listener, Composable, Disposable, 
Recyclable {

public void setup(SourceResolver resolver, Map objectModel, String src, 
Parameters par)
throws ProcessingException, SAXException, IOException {

...
this.session = null;
this.session = this.request.getSession();
...
}

private Document addUser(Document doc) {
...
if (!isUser) {
...
this.session.setAttribute("errorUser", "UserOk");
...
}
else {
this.session.setAttribute("errorUser", "UserAlready");
...
  }
...
}

In the transformer, all is working fine.
But from the sitemap, tha session attribute errorUser is one time late.
For example, if errorUser is UserAlready the first time, I have to go 
throught the transformer twice if I want to set errorUser to UserOk.


Any Idea what's going on.

PS : I use cocoon 2.0.4. My transformer do not use cache.

thanks
Lionel






Lionel CRINE
Société : 4DConcept
22 rue Etienne de Jouy 78353 JOUY EN JOSAS
Tel : 01.34.58.70.70 Fax : 01.39.58.70.70


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


Re: trouble with session attribute

Posted by Christian Haul <ha...@dvs1.informatik.tu-darmstadt.de>.
On 28.Jul.2003 -- 01:34 PM, Lionel Crine wrote:
> Thanks for the answer  :
> 
> 
> At 12:52 28/07/2003 +0200, you wrote:
> >Or your transformers need to
> >communicate inline through the data stream.
> 
> 
> Is there a way to do that ?

Sure. Your first transformer can add any XML to the data stream and
the second can act on it since it needs to read all XML anyway.

BTW you can access the session in your transformers since the object
model is passed at setup time to it -- you just may not pass the
session data through the sitemap to the second transformer! But
beware: both transformers *run in parallel* so if the first
transformer modifies the session at the end, the second sees the
change only very late in the process!

 t    G     T  T  T  S
 i    root-->-->-->-->
 m    h1---->-->-->-->
 e    /h1--->-->-->-->
 |    /root->-->-->-->
 V

	Chris.
-- 
C h r i s t i a n       H a u l
haul@informatik.tu-darmstadt.de
    fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

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


Re: trouble with session attribute

Posted by Lionel Crine <cr...@4dconcept.fr>.
Thanks for the answer  :


At 12:52 28/07/2003 +0200, you wrote:
>Or your transformers need to
>communicate inline through the data stream.


Is there a way to do that ?



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


Re: trouble with session attribute

Posted by Christian Haul <ha...@dvs1.informatik.tu-darmstadt.de>.
On 28.Jul.2003 -- 09:36 AM, Lionel Crine wrote:
> Hi,
> 
> I've some trouble with session attribute. Here is what I try :
> 
> The sitemap:
>      <map:match pattern="addUser">
>         <map:generate type="MyGenerator" src="user.xml" />
>         <map:transform type=MyTransformerAddUser" />
>         <map:select type="session_selector">
>           <map:parameter name="attribute-name" value="errorUser" />
>           <map:when test="UserAlready">
>             <map:transform type="xslt" src="xsl/error_User.xsl">
>               <map:parameter name="errorUser"
>               value="{session-attr:errorUser}" />
>             </map:transform>
>           </map:when>
>           <map:when test="UserOk">
>             <map:transform type="xslt" src="xsl/error_User.xsl">
>               <map:parameter name="errorUser"
>               value="{session-attr:errorUser}" />
>             </map:transform>
>                  </map:when>
>         </map:select>
>         <map:serialize type="xml" />
>       </map:match>
> 
> 
> 
> In MyTransformerAddUser,I manage the session like this :
> 
> public class IXIASOFTTransformerAddUser
> extends AbstractDOMTransformer
> implements Transformer, DOMBuilder.Listener, Composable, Disposable, 
> Recyclable {
> 
> public void setup(SourceResolver resolver, Map objectModel, String src, 
> Parameters par)
> throws ProcessingException, SAXException, IOException {
> 
> ...
> this.session = null;
> this.session = this.request.getSession();
> ...
> }
> 
> private Document addUser(Document doc) {
> ...
> if (!isUser) {
> ...
> this.session.setAttribute("errorUser", "UserOk");
> ...
> }
> else {
> this.session.setAttribute("errorUser", "UserAlready");
> ...
>  }
> ...
> }
> 
> In the transformer, all is working fine.
> But from the sitemap, tha session attribute errorUser is one time late.
> For example, if errorUser is UserAlready the first time, I have to go 
> throught the transformer twice if I want to set errorUser to UserOk.
> 
> 
> Any Idea what's going on.

The sitemap is executed *before* any of the sitemap pipeline
components. So, when your transformer sets the attribute, the sitemap
has already tried to read it in order to setup the other transformer.
Only when you do it with an action, the data would be available at
setup time for the transformer. Or your transformers need to
communicate inline through the data stream.

	Chris.
-- 
C h r i s t i a n       H a u l
haul@informatik.tu-darmstadt.de
    fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

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