You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Tomas Garijo <tg...@surland.com> on 2006/09/19 09:25:22 UTC
Exception in cocoon
Hi!
I try to implement a custom error-hadle in cocoon.
We make this class es.clickonline.Exception.efacturaException with this code.
public class efacturaException extends Exception
{
private int errorCode;
public efacturaException(int errorCode, String message) {
super(message);
this.errorCode = errorCode;
}
public efacturaException(int errorCode) {
this.errorCode = errorCode;
}
public void setErrorCode(int errorCode) {
this.errorCode = errorCode;
}
public int getErrorCode() {
return this.errorCode;
}
}
How you see this class its very easy, extends of exception, in my application I do implement the pattern View-Model-Controller, my exceptios it´s generate in the class controller,
but the error-hadle it´s in the View.
Code controller.....
EfacturaDetailInvoiceResponseDocument docDetailInvoiceResponse;
docDetailInvoiceResponse = EfacturaDetailInvoiceResponseDocument.Factory.newInstance();
EfacturaDetailInvoiceResponse EfacturaDetailInvoiceResponse;
if (session.isNew())
{
try {
throw new efacturaException(1,"validation");
} catch (efacturaException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else
{
//Instancia a la clase driverDatabase Patron DAO
dDatabase = new driverDatabase ();
dDatabase.putsUser("XX");
dDatabase.putsPwd("XXXX");
try
{
this controller its calling from distpacher and dispatcher it´s calling from custom tranform.
My problem it´s that I sure that the exception calling it´s not to branch off error-hadle.
This is my sitemap.
<?xml version="1.0"?>
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
<map:components>
<map:selector name="exception" src="org.apache.cocoon.selection.ExceptionSelector">
<exception name="processing" class="ProcessingException" unroll="true"/>
<exception name="sax" class="SAXException"/>
<exception name="application" class="es.clickonline.Exception.efacturaException"/>
</map:selector>
<map:transformers default="xslt">
<!-- NOTE: This is the default XSLT processor. -->
<map:transformer logger="sitemap.transformer.xslt" name="xslt" pool-max="${xslt-transformer.pool-max}" src="org.apache.cocoon.transformation.TraxTransformer">
<use-request-parameters>false</use-request-parameters>
<use-session-parameters>false</use-session-parameters>
<use-cookie-parameters>false</use-cookie-parameters>
<xslt-processor-role>xalan</xslt-processor-role>
<check-includes>true</check-includes>
</map:transformer>
<map:transformer name="transformer" src="es.clickonline.transformation.Transformer"/>
<map:transformer logger="sitemap.transformer.html" name="html" src="org.apache.cocoon.transformation.HTMLTransformer"/>
<!--map:transformer name="pdf" mime-type="application/pdf" src="org.apache.cocoon.serialization.FOPSerializer" logger="sitemap.serializer.fo2pdf"/>
<map:transformer name="fo2pdf" mime-type="application/pdf" src="org.apache.cocoon.serialization.FOPSerializer"/-->
</map:transformers>
<!--
Para serializar en pdf, ademas de estas lineas, se necesitan los siguientes jar:
cocoon-html-block.jar
batik-all-1.6.jar
cocoon-batik-block.jar
cocoon-fop-block.jar
fop-0.20.5.jar
-->
<map:serializers default="html">
<map:serializer name="fo2pdf" mime-type="application/pdf" src="org.apache.cocoon.serialization.FOPSerializer"/>
</map:serializers>
</map:components>
<map:pipelines>
<map:pipeline>
<!--map:match pattern="*">
<map:generate type="exception" src="{1}"/>
<map:serialize/>
</map:match-->
<map:match pattern="index.html">
<map:read src="index.html" mime-type="text/html"/>
</map:match>
<map:match pattern="*.html">
<map:read src="html/{1}.html" mime-type="text/html"/>
</map:match>
<map:match pattern="*.jpg">
<map:read src="image/{1}.jpg" mime-type="image/jpeg"/>
</map:match>
<map:match pattern="*.gif">
<map:read src="image/{1}.gif" mime-type="image/gif"/>
</map:match>
<map:match pattern="*.css">
<map:read src="css/{1}.css"/>
</map:match>
<map:match pattern="Login">
<map:generate type="request"/>
<map:transform src="./xslt/efacturaRequest.xsl"/>
<map:transform type="transformer"/>
<map:transform src="./xslt/efacturaLoginResponse.xsl"/>
<map:serialize type="html"/>
</map:match>
<map:match pattern="detailInvoice">
<map:generate type="request"/>
<map:transform src="./xslt/efacturaRequest.xsl"/>
<map:transform type="transformer"/>
<map:transform src="./xslt/efacturaDetailInvoiceResponse.xsl"/>
<map:serialize type="fo2pdf"/>
<!--map:serialize type="xml"/-->
</map:match>
<map:handle-errors>
<map:select type="exception">
<!--map:when test="processing">...</map:when-->
<!--map:when test="sax">...</map:when-->
<map:when test="application">
<map:generate src="validation.html"/>
</map:when>
</map:select>
</map:handle-errors>
<map:match pattern="InvoiceSearch">
<map:generate type="request"/>
<map:transform src="./xslt/efacturaRequest.xsl"/>
<map:transform type="transformer"/>
<map:transform src="./xslt/efacturaInvoiceSearchResponse.xsl"/>
<map:serialize type="html"/>
</map:match>
</map:pipeline>
</map:pipelines>
</map:sitemap>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org