You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Donald Ball <ba...@webslingerZ.com> on 2001/04/18 03:24:20 UTC

[c2] problem with actions

okay, so i figured out and patched the problem i was having with the
DatabaseAddAction (old JDBC driver), so naturally i'm on to something new.
my sitemap has this rule:

<map:match pattern="add/work">
 <map:act type="add-work">
  <parameter name="form-descriptor" value="context://resources/forms/work.xml"/>
  <map:redirect-to uri="clients"/>
 </map:act>
</map:match>

the action works fine, but the redirect doesn't occur. i end up with the
good old 'Cocoon2 - Resource not found' error message. path-info is
"add/work", not "clients" or even "add/clients". any clues?

- donald


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


Re: [c2] problem with actions

Posted by Berin Loritsch <bl...@apache.org>.
Donald Ball wrote:
> 
> On Wed, 18 Apr 2001, Berin Loritsch wrote:
> 
> > > generaly nesting of actions is (as I understand it) something like
> > > if-then-else clause, "if-then" -> go deeper, "else" go to next element at the
> > > same level in the tree, am I wrong ??
> >
> > You've pretty much got the concept.
> 
> but it's not if/else - because the else branch is hit regardless, right?
> that is to say
> 
> <map:match pattern="something">
>  <map:act type="something">
>   if branch
>  </map:act>
>  else branch>
> </map:match>
> 
> if the something action return non-null, the if branch and the else branch
> are hit, otherwise just the else branch is hit. right? to do a real
> if/else branch, you have to use a selector, yes?

If you redirect, or completely specify a pipeline before reaching the next
element, then Cocoon will execute that.  Otherwise, the other execution will
happen regardless.

For real selection, then use a selector.

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


Re: [c2] problem with actions

Posted by giacomo <gi...@apache.org>.

On Wed, 18 Apr 2001, Donald Ball wrote:

> On Wed, 18 Apr 2001, Berin Loritsch wrote:
>
> > > generaly nesting of actions is (as I understand it) something like
> > > if-then-else clause, "if-then" -> go deeper, "else" go to next element at the
> > > same level in the tree, am I wrong ??
> >
> > You've pretty much got the concept.
>
> but it's not if/else - because the else branch is hit regardless, right?
> that is to say
>
> <map:match pattern="something">
>  <map:act type="something">
>   if branch
>  </map:act>
>  else branch>
> </map:match>
>
> if the something action return non-null, the if branch and the else branch
> are hit, otherwise just the else branch is hit. right? to do a real
> if/else branch, you have to use a selector, yes?

Yup.

Giacomo


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


Re: [c2] problem with actions

Posted by Donald Ball <ba...@webslingerZ.com>.
On Wed, 18 Apr 2001, Berin Loritsch wrote:

> > generaly nesting of actions is (as I understand it) something like
> > if-then-else clause, "if-then" -> go deeper, "else" go to next element at the
> > same level in the tree, am I wrong ??
>
> You've pretty much got the concept.

but it's not if/else - because the else branch is hit regardless, right?
that is to say

<map:match pattern="something">
 <map:act type="something">
  if branch
 </map:act>
 else branch>
</map:match>

if the something action return non-null, the if branch and the else branch
are hit, otherwise just the else branch is hit. right? to do a real
if/else branch, you have to use a selector, yes?

- donald


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


Re: [c2] problem with actions

Posted by Berin Loritsch <bl...@apache.org>.
Martin Man wrote:
> 
> On Wed, Apr 18, 2001 at 11:19:50AM -0400, Berin Loritsch wrote:
> > Martin Man wrote:
> 
> > [snip]
> >
> > What would you like to see returned?  The idea of the Map object is to have
> > variables that you want to react to in the sitemap.  If your sitemap entry
> > were re-oriented, we won't have to return a Map object at all:
> >
> > <map:match pattern="add/work">
> >   <map:act type="add-work">
> >     <parameter name="form-descriptor" value="context://resources/forms/work.xml"/>
> >   </map:act>
> >   <map:redirect-to uri="clients"/>
> > </map:match>
> >
> > Notice that I moved the redirect outside the action?
> 
> of course, know this behavior, but what if you want to nest several
> database-add actions together (not a very good exmple), then you need to
> return at least empty map to indicate that action invocation succedded, this
> I'm doing in SessionInvalidator action (maybe it is wasting of resources, but
> surely always returned null won't help either),
> 
> in my webapp-example available under cocoon/protected you can see this action
> chain
> 
> <map:act type="form-validator">
>         <map:act type="database-authenticator">
>                 whatever else
>         </map:act>
> </map:act>
> 
> generaly nesting of actions is (as I understand it) something like
> if-then-else clause, "if-then" -> go deeper, "else" go to next element at the
> same level in the tree, am I wrong ??

You've pretty much got the concept.

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


Re: [c2] problem with actions

Posted by Martin Man <Ma...@seznam.cz>.
On Wed, Apr 18, 2001 at 11:19:50AM -0400, Berin Loritsch wrote:
> Martin Man wrote:

> [snip]
> 
> What would you like to see returned?  The idea of the Map object is to have
> variables that you want to react to in the sitemap.  If your sitemap entry
> were re-oriented, we won't have to return a Map object at all:
> 
> <map:match pattern="add/work">
>   <map:act type="add-work">
>     <parameter name="form-descriptor" value="context://resources/forms/work.xml"/>
>   </map:act>
>   <map:redirect-to uri="clients"/>
> </map:match>
> 
> Notice that I moved the redirect outside the action?

of course, know this behavior, but what if you want to nest several
database-add actions together (not a very good exmple), then you need to
return at least empty map to indicate that action invocation succedded, this
I'm doing in SessionInvalidator action (maybe it is wasting of resources, but
surely always returned null won't help either), 

in my webapp-example available under cocoon/protected you can see this action
chain

<map:act type="form-validator">
	<map:act type="database-authenticator">
		whatever else
	</map:act>
</map:act>

generaly nesting of actions is (as I understand it) something like
if-then-else clause, "if-then" -> go deeper, "else" go to next element at the
same level in the tree, am I wrong ??

> 
> If you need to react to specific information returned from the action, then
> it makes sense to enclose the <map:redirect-to/> element in the <map:act/>
> element.
see above

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

-- 
-------------------------------------------------------------------------------
"Only dead fish swims with a stream"
gpg_key_available: http://globales.cz/~mman/martin.man.gpg
gpg_key_fingerprint: 2CC0 4AF6 92DA 5CBF 5F09  7BCB 6202 7024 6E06 0223

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


Re: [c2] problem with actions

Posted by Berin Loritsch <bl...@apache.org>.
Martin Man wrote:
> 
> On Wed, Apr 18, 2001 at 08:36:47AM -0400, Berin Loritsch wrote:
> > Donald Ball wrote:
> > >
> > > okay, so i figured out and patched the problem i was having with the
> > > DatabaseAddAction (old JDBC driver), so naturally i'm on to something new.
> > > my sitemap has this rule:
> > >
> > > <map:match pattern="add/work">
> > >  <map:act type="add-work">
> > >   <parameter name="form-descriptor" value="context://resources/forms/work.xml"/>
> > >   <map:redirect-to uri="clients"/>
> > >  </map:act>
> > > </map:match>
> > >
> > > the action works fine, but the redirect doesn't occur. i end up with the
> > > good old 'Cocoon2 - Resource not found' error message. path-info is
> > > "add/work", not "clients" or even "add/clients". any clues?
> >
> > Does the Action return a Map object?  If not anything inside the Act
> > declaration is skipped.
> that's exactly the problem, DatabaseAddAction returns null no matter what the
> result was, shouldn't this be changed somhow ???

What would you like to see returned?  The idea of the Map object is to have
variables that you want to react to in the sitemap.  If your sitemap entry
were re-oriented, we won't have to return a Map object at all:

<map:match pattern="add/work">
  <map:act type="add-work">
    <parameter name="form-descriptor" value="context://resources/forms/work.xml"/>
  </map:act>
  <map:redirect-to uri="clients"/>
</map:match>

Notice that I moved the redirect outside the action?

If you need to react to specific information returned from the action, then
it makes sense to enclose the <map:redirect-to/> element in the <map:act/>
element.

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


Re: [c2] problem with actions

Posted by Martin Man <Ma...@seznam.cz>.
On Wed, Apr 18, 2001 at 08:36:47AM -0400, Berin Loritsch wrote:
> Donald Ball wrote:
> > 
> > okay, so i figured out and patched the problem i was having with the
> > DatabaseAddAction (old JDBC driver), so naturally i'm on to something new.
> > my sitemap has this rule:
> > 
> > <map:match pattern="add/work">
> >  <map:act type="add-work">
> >   <parameter name="form-descriptor" value="context://resources/forms/work.xml"/>
> >   <map:redirect-to uri="clients"/>
> >  </map:act>
> > </map:match>
> > 
> > the action works fine, but the redirect doesn't occur. i end up with the
> > good old 'Cocoon2 - Resource not found' error message. path-info is
> > "add/work", not "clients" or even "add/clients". any clues?
> 
> Does the Action return a Map object?  If not anything inside the Act
> declaration is skipped.
that's exactly the problem, DatabaseAddAction returns null no matter what the
result was, shouldn't this be changed somhow ???

berin ???

martin man
-- 
-------------------------------------------------------------------------------
"Only dead fish swims with a stream"
gpg_key_available: http://globales.cz/~mman/martin.man.gpg
gpg_key_fingerprint: 2CC0 4AF6 92DA 5CBF 5F09  7BCB 6202 7024 6E06 0223

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


Re: [c2] problem with actions

Posted by Berin Loritsch <bl...@apache.org>.
Donald Ball wrote:
> 
> On Wed, 18 Apr 2001, Berin Loritsch wrote:
> 
> > > okay, so i figured out and patched the problem i was having with the
> > > DatabaseAddAction (old JDBC driver), so naturally i'm on to something new.
> > > my sitemap has this rule:
> > >
> > > <map:match pattern="add/work">
> > >  <map:act type="add-work">
> > >   <parameter name="form-descriptor" value="context://resources/forms/work.xml"/>
> > >   <map:redirect-to uri="clients"/>
> > >  </map:act>
> > > </map:match>
> > >
> > > the action works fine, but the redirect doesn't occur. i end up with the
> > > good old 'Cocoon2 - Resource not found' error message. path-info is
> > > "add/work", not "clients" or even "add/clients". any clues?
> >
> > Does the Action return a Map object?  If not anything inside the Act
> > declaration is skipped.
> 
> uh, it's your database add action, i'd think you'd know. ;) well, hmm,
> just looked in the source, and it always returns null. how were you
> planning on reporting success or failure?

There is no option for failure....

Exceptions are logged--I implemented this in a frenzy because I needed something
that worked for a web app I was supposed to be done with a week ago.  I never
imagined using it to optionally execute portions of code based on success or
failure.  PS I am still working on the webapp.... :)

If you want to edit the Action to return a Map on success, I don't have any
problems with that.

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


Re: [c2] problem with actions

Posted by Donald Ball <ba...@webslingerZ.com>.
On Wed, 18 Apr 2001, Berin Loritsch wrote:

> > okay, so i figured out and patched the problem i was having with the
> > DatabaseAddAction (old JDBC driver), so naturally i'm on to something new.
> > my sitemap has this rule:
> >
> > <map:match pattern="add/work">
> >  <map:act type="add-work">
> >   <parameter name="form-descriptor" value="context://resources/forms/work.xml"/>
> >   <map:redirect-to uri="clients"/>
> >  </map:act>
> > </map:match>
> >
> > the action works fine, but the redirect doesn't occur. i end up with the
> > good old 'Cocoon2 - Resource not found' error message. path-info is
> > "add/work", not "clients" or even "add/clients". any clues?
>
> Does the Action return a Map object?  If not anything inside the Act
> declaration is skipped.

uh, it's your database add action, i'd think you'd know. ;) well, hmm,
just looked in the source, and it always returns null. how were you
planning on reporting success or failure?

- donald


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


Re: [c2] problem with actions

Posted by giacomo <gi...@apache.org>.

On Wed, 18 Apr 2001, Berin Loritsch wrote:

> Donald Ball wrote:
> >
> > okay, so i figured out and patched the problem i was having with the
> > DatabaseAddAction (old JDBC driver), so naturally i'm on to something new.
> > my sitemap has this rule:
> >
> > <map:match pattern="add/work">
> >  <map:act type="add-work">
> >   <parameter name="form-descriptor" value="context://resources/forms/work.xml"/>
> >   <map:redirect-to uri="clients"/>
> >  </map:act>
> > </map:match>
> >
> > the action works fine, but the redirect doesn't occur. i end up with the
> > good old 'Cocoon2 - Resource not found' error message. path-info is
> > "add/work", not "clients" or even "add/clients". any clues?

Does it work if you use an absolute uri?

Giacomo



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


Re: [c2] problem with actions

Posted by Berin Loritsch <bl...@apache.org>.
Donald Ball wrote:
> 
> okay, so i figured out and patched the problem i was having with the
> DatabaseAddAction (old JDBC driver), so naturally i'm on to something new.
> my sitemap has this rule:
> 
> <map:match pattern="add/work">
>  <map:act type="add-work">
>   <parameter name="form-descriptor" value="context://resources/forms/work.xml"/>
>   <map:redirect-to uri="clients"/>
>  </map:act>
> </map:match>
> 
> the action works fine, but the redirect doesn't occur. i end up with the
> good old 'Cocoon2 - Resource not found' error message. path-info is
> "add/work", not "clients" or even "add/clients". any clues?

Does the Action return a Map object?  If not anything inside the Act
declaration is skipped.

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


Re: [c2] problem with actions

Posted by giacomo <gi...@apache.org>.

On Tue, 17 Apr 2001, Donald Ball wrote:

> okay, so i figured out and patched the problem i was having with the
> DatabaseAddAction (old JDBC driver), so naturally i'm on to something new.
> my sitemap has this rule:
>
> <map:match pattern="add/work">
>  <map:act type="add-work">
>   <parameter name="form-descriptor" value="context://resources/forms/work.xml"/>
>   <map:redirect-to uri="clients"/>
>  </map:act>
> </map:match>
>
> the action works fine, but the redirect doesn't occur. i end up with the
> good old 'Cocoon2 - Resource not found' error message. path-info is
> "add/work", not "clients" or even "add/clients". any clues?

What is the "add-work" action returning to the sitemap?

Giacomo


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