You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Klaus Drechsler <dr...@gmx.net> on 2001/02/11 03:39:41 UTC

Action ...

Hi,

I have tried to write my own action. it looks like this:

...
public class SessionAction extends ComposerAction {
     public void configure( Configuration configuration) throws 
ConfigurationException {}

     public Map act (EntityResolver resolver, Map objectModel, String src, 
Parameters par)
     	throws Exception {
     	temporaryMap = new HashMap(1);
	temporaryMap.put(new String("validSession"),new String ("true"));
	System.out.println(temporaryMap.get("validSession")); // -> prints always 
"true" out
         return temporaryMap;
     }
...


So as you can see. I return a HashMap to the Sitemap. In the sitemap I put 
the following:

    <map:match pattern="sm/*">
     <map:act set="mytest">
	<map:generate type="serverpages" src="abc/{1}.xsp"/>
     	<map:transform src="abc/sm-logicsheet.xsl"/>
     	<map:serialize type="html"/>
    </map:act>
    </map:match>


In the dos-window I always get "true" (as expected), so the Map Object is 
correct. But in the browser window
I get the error Message:
...
Can't read file: 
file:/C:/jakarta-tomcat-4.0-b1/webapps/cocoon/dbprakhouse/null.xsp
...
But cocoon should load "true.xsp"!

What am I doing wrong? Why is "{1}" substituted with "null"?

How do I access the returned Map Object within the Sitemap?

Pleas help!

Thanks in advice!

Bye,
  Klaus
-- 
Farewell! I will omit no opportunity
That may convey my greetings, love, to thee.
Romeo&Juliet
                         (Act III, Scene V)
---------------------------------------------
PGP-Key: http://pgp.kdnet.de (soon!)
---------------------------------------------


Re: Action ... (new question inside ;))

Posted by Giacomo Pati <gi...@apache.org>.
Klaus Drechsler wrote:
> Hi,
>
> At 17:22 11.02.2001, you wrote:
> >Here you try to get at the value of {1} from the Map returned by your
> > action. Unfortunately your map does not contain a member named "1". the
> > only one you have is "validSession".
>
> Thank you very much. That works now :-)
>
> But I have another question to you:
> Is it possible to to do something like an "if ... then ...else" with the
> results from an acion in the sitemap?.
> I mean something like this:
>
>     <map:match pattern="sm/*">
>      <map:act set="mytest">
>
>          <map:when {test}=true>   <!-- HOW DO I DO THIS? -->
>
>                  <map:generate type="serverpages"
> src="dbprakhouse/{test}.xsp"/>
>                  <map:transform src="dbprakhouse/sm-logicsheet.xsl"/>
>                  <map:serialize type="html"/>
>          </map:when>
>
>      </map:act>
>     </map:match>
>
> If this is possible, could you give me the correct syntax please? I tried
> to figure it out by myself, but that wasn´t very successful.

No, there is no such thing like what you are expecting. There was a 
Selector called CodedSelectorFactory but unfortunately I've missed the docs 
from Marcus Crafter. Maybe you'll find there what you are looking for. I 
think you can always use an action to do your checking and return an 
appropriate value to the sitemap to be used as a replacement for resources.

Marcus, did you post the docs for your Selector?

Giacomo

Re: Action ... (new question inside ;))

Posted by Klaus Drechsler <dr...@gmx.net>.
Hi,

At 17:22 11.02.2001, you wrote:
>Here you try to get at the value of {1} from the Map returned by your action.
>Unfortunately your map does not contain a member named "1". the only one you
>have is "validSession".


Thank you very much. That works now :-)

But I have another question to you:
Is it possible to to do something like an "if ... then ...else" with the 
results from an acion in the sitemap?.
I mean something like this:

    <map:match pattern="sm/*">
     <map:act set="mytest">

         <map:when {test}=true>   <!-- HOW DO I DO THIS? -->

                 <map:generate type="serverpages" 
src="dbprakhouse/{test}.xsp"/>
                 <map:transform src="dbprakhouse/sm-logicsheet.xsl"/>
                 <map:serialize type="html"/>
         </map:when>

     </map:act>
    </map:match>

If this is possible, could you give me the correct syntax please? I tried 
to figure it out by myself, but that wasn´t very successful.

Thanks in advice!

Bye,
  Klaus
-- 
Farewell! I will omit no opportunity
That may convey my greetings, love, to thee.
Romeo&Juliet
                         (Act III, Scene V)
---------------------------------------------
PGP-Key: http://pgp.kdnet.de (soon!)
---------------------------------------------


Re: Action ...

Posted by Giacomo Pati <gi...@apache.org>.
Klaus Drechsler wrote:
> Hi,
>
> I have tried to write my own action. it looks like this:
>
> ....
> public class SessionAction extends ComposerAction {
>      public void configure( Configuration configuration) throws
> ConfigurationException {}
>
>      public Map act (EntityResolver resolver, Map objectModel, String src,
> Parameters par)
>      	throws Exception {
>      	temporaryMap = new HashMap(1);
> 	temporaryMap.put(new String("validSession"),new String ("true"));
> 	System.out.println(temporaryMap.get("validSession")); // -> prints always
> "true" out
>          return temporaryMap;
>      }
> ....

Your Map contains "validSession" => "true"

>
>
> So as you can see. I return a HashMap to the Sitemap. In the sitemap I put
> the following:
>
>     <map:match pattern="sm/*">
>      <map:act set="mytest">
> 	<map:generate type="serverpages" src="abc/{1}.xsp"/>

Here you try to get at the value of {1} from the Map returned by your action. 
Unfortunately your map does not contain a member named "1". the only one you 
have is "validSession".

So, replace your {1} with {validSession} and you'll get what you excpect.

Giacomo

>      	<map:transform src="abc/sm-logicsheet.xsl"/>
>      	<map:serialize type="html"/>
>     </map:act>
>     </map:match>
>
>
> In the dos-window I always get "true" (as expected), so the Map Object is
> correct. But in the browser window
> I get the error Message:
> ....
> Can't read file:
> file:/C:/jakarta-tomcat-4.0-b1/webapps/cocoon/dbprakhouse/null.xsp
> ....
> But cocoon should load "true.xsp"!
>
> What am I doing wrong? Why is "{1}" substituted with "null"?
>
> How do I access the returned Map Object within the Sitemap?
>
> Pleas help!
>
> Thanks in advice!
>
> Bye,
>   Klaus

Re: Action ...

Posted by Giacomo Pati <gi...@apache.org>.
Klaus Drechsler wrote:
> Hi,
>
> I have tried to write my own action. it looks like this:
>
> ....
> public class SessionAction extends ComposerAction {
>      public void configure( Configuration configuration) throws
> ConfigurationException {}
>
>      public Map act (EntityResolver resolver, Map objectModel, String src,
> Parameters par)
>      	throws Exception {
>      	temporaryMap = new HashMap(1);
> 	temporaryMap.put(new String("validSession"),new String ("true"));
> 	System.out.println(temporaryMap.get("validSession")); // -> prints always
> "true" out
>          return temporaryMap;
>      }
> ....

Your Map contains "validSession" => "true"

>
>
> So as you can see. I return a HashMap to the Sitemap. In the sitemap I put
> the following:
>
>     <map:match pattern="sm/*">
>      <map:act set="mytest">
> 	<map:generate type="serverpages" src="abc/{1}.xsp"/>

Here you try to get at the value of {1} from the Map returned by your action. 
Unfortunately your map does not contain a member named "1". the only one you 
have is "validSession".

So, replace your {1} with {validSession} and you'll get what you excpect.

Giacomo

>      	<map:transform src="abc/sm-logicsheet.xsl"/>
>      	<map:serialize type="html"/>
>     </map:act>
>     </map:match>
>
>
> In the dos-window I always get "true" (as expected), so the Map Object is
> correct. But in the browser window
> I get the error Message:
> ....
> Can't read file:
> file:/C:/jakarta-tomcat-4.0-b1/webapps/cocoon/dbprakhouse/null.xsp
> ....
> But cocoon should load "true.xsp"!
>
> What am I doing wrong? Why is "{1}" substituted with "null"?
>
> How do I access the returned Map Object within the Sitemap?
>
> Pleas help!
>
> Thanks in advice!
>
> Bye,
>   Klaus