cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nicola Ken Barozzi <nicola...@apache.org>
Subject Re: Allow redirects inside error handling
Date Wed, 30 Apr 2003 06:36:33 GMT


Björn Lütkemeier wrote, On 30/04/2003 8.08:
> Hi,
> 
> 
>>-----Original Message-----
>>From: Nicola Ken Barozzi [mailto:nicolaken@apache.org]
>>Sent: Tuesday, April 29, 2003 6:38 PM
>>To: cocoon-dev@xml.apache.org
>>Subject: Re: Allow redirects inside error handling
>>
>>
>>
>>Björn Lütkemeier wrote, On 29/04/2003 16.42:
>>...
>>
>>>Sorry, but I did not find any convincing argument in the discussion why
>>>redirects should be impossible.
>>
>>Tell me why you need them, maybe I can understand.
>>
>>--
>>Nicola Ken Barozzi                   nicolaken@apache.org
>>             - verba volant, scripta manent -
>>    (discussions get forgotten, just code remains)
>>---------------------------------------------------------------------
>>
> 
> 
> It's quite simple to explain. We have a customer, that has to do the
> following within his web application:
> 
> <map:pipeline>
<> 	<map:match pattern="showForm">
> 		<!-- show a web form -->
> 	</map:match>
> 	<map:handle-errors>
> 		<map:select type="exception">
> 			<map:when test="x">
> 				<map:redirect-to uri="cocoon:/x-error"/>
> 			</map:when>
> 			<map:when test="y">
> 				<map:redirect-to uri="cocoon:/y-error"/>
> 			</map:when>
> 		</map:select>
> 	</map:handle-errors>
> </map:pipeline>
> 
> <map:pipeline>
> 	<map:match pattern="formSubmitted">
> 		<!-- process form values -->
> 	</map:match>
> 	<map:handle-errors>
> 		<map:select type="exception">
> 			<map:when test="validationFailed">
> 				<map:redirect-to uri="cocoon:/showForm"/> <!-- redisplay form -->
> 			</map:when>
> 			<map:when test="x">
> 				<map:redirect-to uri="cocoon:/x-error"/>
> 			</map:when>
> 			<map:when test="z">
> 				<map:redirect-to uri="cocoon:/z-error"/>
> 			</map:when>
> 		</map:select>
> 	</map:handle-errors>
> </map:pipeline>
> 
> <map:pipeline>
> 	<map:match pattern="x-error">
> 		...
> 	</map:match>
> 	<map:match pattern="y-error">
> 		...
> 	</map:match>
> 	<map:match pattern="z-error">
> 		...
> 	</map:match>
> </map:pipeline>

Ok, this does the same without redirects *except* in the

  <map:when test="validationFailed">... <!-- redisplay form -->

part. This is wrong, because handle-errors in *not* to be used for 
programming logic. This shows it clearly that we cannot allow redirects 
in there, because the first thing that happens is misuse.

Sylvain, please revert the change.


Here is the example.

  <map:resources>
     <map:resource name="x-error">
   		...
     </map:resource>
     <map:resource name="y-error">
   		...
     </map:resource>
     <map:resource name="z-error">
   		...
     </map:resource>
   </map:resources>

<map:pipelines>
  <map:pipeline>
  	<map:match pattern="showForm">
  		<!-- show a web form -->
  	</map:match>
  	<map:handle-errors>
  		<map:select type="exception">
  			<map:when test="x">
  				<map:call resource="x-error"/>
  			</map:when>
  			<map:when test="y">
  				<map:call resource="y-error"/>
  			</map:when>
  		</map:select>
  	</map:handle-errors>
  </map:pipeline>

  <map:pipeline>
  	<map:match pattern="formSubmitted">
  	     <!-- process form values -->

              <!-- use an action that checks the
                   forms and also handles the
                   *programmatically defined* errors -->

  	</map:match>
  	<map:handle-errors>
  		<map:select type="exception">
  			<map:when test="x">
  				<map:call resource="x-error"/>
  			</map:when>
  			<map:when test="z">
  				<map:call resource="z-error"/>
  			</map:when>
  		</map:select>
  	</map:handle-errors>
  </map:pipeline>




-- 
Nicola Ken Barozzi                   nicolaken@apache.org
             - verba volant, scripta manent -
    (discussions get forgotten, just code remains)
---------------------------------------------------------------------


Mime
View raw message