thanks.
It should help! ;)

On Tue, 2005-07-05 at 16:57 +0200, Leszek Gawron wrote:
> Arsen A. Gutsal wrote:
> > What's the best way to handle conditions in sitemap?
> > I'd prefer sitemap, not flowscipt.
> > 
> > So, I've the script, which store user to database.
> > After user is successfully stored, email should be sent to him with his
> > login/password and operation status. Everything works fine except I
> > can't catch session attribute set to ERROR and do not send email in that
> > case.
> > 
> > Sitemap looks like:
> > 
> > <map:match pattern="*-success">
> >         <!-- flow-attribute:customer should be set! -->
> >         <map:generate type="xquery" src="xq/update_customer.xq">
> >                 <map:parameter name="id"
> > value="{flow-attribute:customer/*/@id}"/>
> >                 <map:parameter name="email"
> > value="{flow-attribute:customer/*/email}"/>
> >                 <map:parameter name="pin"
> > value="{flow-attribute:customer/@pin}"/>
> >         </map:generate>
> >         
> >         <!-- some condition should be here -->
> >         <map:call resource="sendMail">
> >                 <map:parameter name="from"
> > value="{global:registrator-email}"/>
> >                 <map:parameter name="to" value="{global:admin-email}"/>
> >                 <map:parameter name="subject" value="New user has been
> > registered"/>
> >                 <map:parameter name="src"
> > value="cocoon:/registration_email.jx"/>
> >         </map:call>
> > </map:match>
> > 
> > So, email should *not* be sent if record was not added to DB in xquery
> > generator (some session attribute was set to ERROR). I tried to put
> > map:select with parameter-selector-test and check "ERROR" value, but it
> > does not work.
> > Of course I can move sendmail action to another pipeline and then call
> > it from XSLT (when generating the page). So, if error was set I'll not
> > call this pipeline. But this is an incorrect way I guess (to mix
> > visualizing with actioning).  
> > 
> The best way is to use flow (apples, flowscript anything).
> 
> if not you have to implement an action that will check for your 
> condition and fail if it detects an error. You can use ServerPagesAction 
> if you do not want to code in java.
> 
> Here is a sample:
> 
> <map:match pattern="login">
>       <map:act type="serverpages" src="system/login.xsp">
>               <!-- this is run when action succeeds -->
>               <map:generate src="xml/login-ok.xml"/>
>               <map:serialize/>
>       </map:act>
>       <!-- here is the 'failed' path -->
>       <map:generate src="xml/login-error.xml"/>
>       <map:serialize/>
> </map:match>
> 
> the action source:
> 
> > <?xml version="1.0" encoding="UTF-8"?>
> > <xsp:page   language="java"
> >                     xmlns:xsp="http://apache.org/xsp";
> >                     xmlns:xsp-request="http://apache.org/xsp/request/2.0";
> >                     xmlns:xsp-session="http://apache.org/xsp/session/2.0";
> >                     xmlns:action="http://apache.org/cocoon/action/1.0";
> >                     xmlns:esql="http://apache.org/cocoon/SQL/v2";
> >                     xmlns:log="http://apache.org/xsp/log/2.0";
> >                     >
> > <page>
> >     <action:set-failure/>
> >     <xsp:logic>
> >             String username = <xsp-request:get-parameter name="username"/>;
> >             if ( username == null ) {
> >                     <xsp-session:invalidate/>
> >                     return;
> >             }
> >     </xsp:logic>
> >     <action:set-success/>
> > </page>
> > </xsp:page>
> 
> 
> the most important hwre is to declare a action namespace: 
> xmlns:action="http://apache.org/cocoon/action/1.0";
> and use action:set-failure or action:set-success tags.
> 
-- 
Sincerely,
Arsen A. Gutsal
SOFTSKY Ltd CEO/Executive
SOFTSKY - Cost effective Software Development


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to