You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Markus Locher, ASK Keller GmbH" <ma...@as-support.com> on 2002/05/21 10:54:21 UTC

Still no requests readable in xsp file

Hi All,

I still have problems transfering request-attributes from an action over sitemap to a xsp-file. I tried all the answers from the list (Thanks Volker!), but I still got always a null as value. 

Is there any known bug for such cases using actions? In the sitemap I played successfully with the parameters that come from the action. Can I give Request-Attributes to a redirect in the sitemap or will they go lost on the redirect?

Regards Markus

-------- Main Message ----------------------

Hello,

I added a self-developed action to org/apache/cocoon with a path from there
like ask/auth. Under auth I have created a servlet called Login.java. You
guessed!.. I am trying to create a login-action for internal use (I know
there is a sample, but that doesn´t fit our needs).

The Login-Servlet gives me a Map back (nothing new) and it sets an attribute
to a Request like ...

   Request.setAttribute("hello","world");

as in the docs from Cocoon!!! "Creating and Using Actions".

The value of the Map is read successfully in the sitemap.xmap, but the
request values can't be read out within an xsp-page. Got only null.

What's wrong?
--------------------------------Login.java----------------
package org.apache.cocoon.ask.auth;

import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.acting.AbstractAction;
import org.apache.cocoon.Constants;
import java.util.Map;
import java.util.HashMap;
import org.apache.cocoon.environment.*;
import org.xml.sax.EntityResolver;

public class Login extends  AbstractAction
     implements  ThreadSafe {

  public Map act (Redirector   redirector,
                  SourceResolver resolver,
                  Map     objectModel,
                  String   source,
                  Parameters   params
   ) {

    Map  sitemapParams  = new HashMap();

    Request  request = (Request) objectModel.get (Constants.REQUEST_OBJECT);

if (request != null) {
      request.setAttribute("hello", "Request arrived! Success!");
      sitemapParams.put("authArt", "login");
} else {
       sitemapParams.put("authArt", "test");
 }

   return sitemapParams;
  }
}
--------------------------------login.xsp----------------
...
<para><xsp-request:get-attribute name="hello"/></para>
...
The rest of xsp-page is correct.
--------------------------------login.xsl----------------
...
 <p><xsl:value-of select="//para"/></p> <br/>
... Rest OK.
--------------------------------sitemap.xmap----------------
...
<map:actions>
     <map:action name = "xifs-login"
        src  = "org.apache.cocoon.ask.auth.Login"/>
  </map:actions>
... within a pipeline!!!
<!-- SERVLETS -->
  <map:match pattern="auth/login">
      <!-- Performe login ... -->
      <map:act type="xifs-login">


    <map:generate type="serverpages" src="../xsp/login.xsp"/>
    <map:transform src="../styles/login.xsl"/>
     <map:serialize/>

     </map:act>

      <!-- If all fails ...-->
      <map:redirect-to uri="../welcome"/>

   </map:match>

...

Thanks for any help.

Regards Markus
mailto:markus@as-support.com