Re: Ajax Exception Handling - How to use alerts component instead of different page.

2015-06-02 Thread Lance Java
This sounds quite specific to a single page, I'd use an event handler

public void onException(Throwable cause)

You can @Inject AlertManager to add alerts
You can @Inject Request to test request.isXhr()
You can @Inject AjaxResponseRenderer to update zones.


Ajax Exception Handling - How to use alerts component instead of different page.

2015-06-01 Thread Sumanth
Hi All,

 I would like to know how to use the  component to show
exceptions when "any" ajax related operation results in uncaught exception.

Also is it possible to refresh all/selected zones in the page if the ajax
operation resulted in exception?


I'm trying to use the "Override Exception Reporting using the decorator" as
mentioned in the tapestry site  but not sure how i can reference my "alerts
component" here and use this to be the exception reporter.


Thanks in advance.


Re: Error Exception Handling

2014-06-13 Thread Tsvetelin Saykov
Hi Shaikh

Also you might want to check at www.jexbox.com

This is an exception logging and management service with very
straightforward integration with Tapestry using RequestExceptionHandler
decoration (https://jexbox.com/connectors)

Best wishes

Tsvetelin


On Wed, Jun 11, 2014 at 3:15 PM, Shaikh, Shahid 
wrote:

> I am trying to have the Exception page shown in Tapestry when my
> GridDataSource throws an exception. How do i catch a
> ComponentEventException and have Tapestry redirect to the Exception page.
>
> Your help is much appreciated!
>
> Here is the logs..
> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
> Caused by: org.apache.tapestry5.runtime.ComponentEventException [at
> classpath:com/navicure/ui/admin/pages/incoming/IncomingFilesPage.tml, line
> 67] at
> org.apache.tapestry5.internal.structure.ComponentPageElementImpl.processEventTriggering(ComponentPageElementImpl.java:1141)
> at
> org.apache.tapestry5.internal.structure.ComponentPageElementImpl.access$3100(ComponentPageElementImpl.java:61)
> at
> org.apache.tapestry5.internal.structure.ComponentPageElementImpl$5.invoke(ComponentPageElementImpl.java:1062)
> at
> org.apache.tapestry5.internal.structure.ComponentPageElementImpl$5.invoke(ComponentPageElementImpl.java:1059)
> at
> org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:74)
> ... 100 more Caused by: java.lang.NullPointerException at
> com.navicure.ui.admin.tables.FragmentDataSource.getAvailableRows(FragmentDataSource.java:91)
> at
> org.got5.tapestry5.jquery.internal.DefaultDataTableModel.getResponse(DefaultDataTableModel.java:243)
> at
> org.got5.tapestry5.jquery.internal.DefaultDataTableModel.sendResponse(DefaultDataTableModel.java:375)
> at
> org.got5.tapestry5.jquery.components.DataTable.onData(DataTable.java:128)
> at
> org.got5.tapestry5.jquery.components.DataTable.dispatchComponentEvent(DataTable.java)
> at
> org.apache.tapestry5.internal.structure.ComponentPageElementImpl.dispatchEvent(ComponentPageElementImpl.java:940)
> at
> org.apache.tapestry5.internal.structure.ComponentPageElementImpl.processEventTriggering(ComponentPageElementImpl.java:1117)
> ... 104 more
>
> Here is my object that implements ExceptionReporter
>
> package com.navicure.ui.admin.pages;
>
> import java.io.PrintWriter;
> import java.io.StringWriter;
> import java.util.Date;
>
> import org.apache.log4j.Logger;
> import org.apache.tapestry5.annotations.Log;
> import org.apache.tapestry5.annotations.Property;
> import org.apache.tapestry5.ioc.annotations.Inject;
> import org.apache.tapestry5.services.ExceptionReporter;
> import org.apache.tapestry5.services.ajax.AjaxResponseRenderer;
> import org.apache.tapestry5.services.ajax.JavaScriptCallback;
> import org.apache.tapestry5.services.javascript.JavaScriptSupport;
>
> public class ExceptionReport implements ExceptionReporter {
>
> private static Logger log = Logger.getLogger(ExceptionReport.class);
>
>
> @Property
> private Date filterToDate;
>
> @Property
> private Throwable exception;
>
> @Inject
> private AjaxResponseRenderer ajaxResponseRenderer;
>
> @Property
> private String messageStackTrace;
>
> @Override
> public void reportException(Throwable exception) {
> this.exception = exception;
> log.error(exception);
> this.messageStackTrace = this.getStackMessageTrace();
> }
>
>
> private String getStackMessageTrace()
> {
> StringWriter errors = new StringWriter();
> exception.printStackTrace(new PrintWriter(errors));
> return errors.toString();
> }
>
>
> }
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


Re: Error Exception Handling

2014-06-11 Thread George Christman
I'm using 5.4 and I believe all you need to do is add the following code to
your AppModule and it will handle redirection to an error page when ever
you have an exception in production mode.

@Match("RequestExceptionHandler")
@Order("after:requestExceptionHandler")
public RequestExceptionHandler decorateProductionExceptionHandler(
final Logger logger,
final ResponseRenderer renderer,
final ComponentSource componentSource,
@Symbol(SymbolConstants.PRODUCTION_MODE) boolean productionMode,
Object service) {
if ( !productionMode ) {
return null;
}
return new RequestExceptionHandler() {
@Override
public void handleRequestException(Throwable exception) throws
IOException {
logger.error("Unexpected runtime exception: " +
exception.getMessage(), exception);
ExceptionReporter index = (ExceptionReporter)
componentSource.getPage("ErrorReport");
index.reportException(exception);
renderer.renderPageMarkupResponse("ErrorReport");
}
};
}


public class ErrorReport implements ExceptionReporter {

@Override
public void reportException(Throwable exception) {
}

}


On Wed, Jun 11, 2014 at 8:15 AM, Shaikh, Shahid 
wrote:

> I am trying to have the Exception page shown in Tapestry when my
> GridDataSource throws an exception. How do i catch a
> ComponentEventException and have Tapestry redirect to the Exception page.
>
> Your help is much appreciated!
>
> Here is the logs..
> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
> Caused by: org.apache.tapestry5.runtime.ComponentEventException [at
> classpath:com/navicure/ui/admin/pages/incoming/IncomingFilesPage.tml, line
> 67] at
> org.apache.tapestry5.internal.structure.ComponentPageElementImpl.processEventTriggering(ComponentPageElementImpl.java:1141)
> at
> org.apache.tapestry5.internal.structure.ComponentPageElementImpl.access$3100(ComponentPageElementImpl.java:61)
> at
> org.apache.tapestry5.internal.structure.ComponentPageElementImpl$5.invoke(ComponentPageElementImpl.java:1062)
> at
> org.apache.tapestry5.internal.structure.ComponentPageElementImpl$5.invoke(ComponentPageElementImpl.java:1059)
> at
> org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:74)
> ... 100 more Caused by: java.lang.NullPointerException at
> com.navicure.ui.admin.tables.FragmentDataSource.getAvailableRows(FragmentDataSource.java:91)
> at
> org.got5.tapestry5.jquery.internal.DefaultDataTableModel.getResponse(DefaultDataTableModel.java:243)
> at
> org.got5.tapestry5.jquery.internal.DefaultDataTableModel.sendResponse(DefaultDataTableModel.java:375)
> at
> org.got5.tapestry5.jquery.components.DataTable.onData(DataTable.java:128)
> at
> org.got5.tapestry5.jquery.components.DataTable.dispatchComponentEvent(DataTable.java)
> at
> org.apache.tapestry5.internal.structure.ComponentPageElementImpl.dispatchEvent(ComponentPageElementImpl.java:940)
> at
> org.apache.tapestry5.internal.structure.ComponentPageElementImpl.processEventTriggering(ComponentPageElementImpl.java:1117)
> ... 104 more
>
> Here is my object that implements ExceptionReporter
>
> package com.navicure.ui.admin.pages;
>
> import java.io.PrintWriter;
> import java.io.StringWriter;
> import java.util.Date;
>
> import org.apache.log4j.Logger;
> import org.apache.tapestry5.annotations.Log;
> import org.apache.tapestry5.annotations.Property;
> import org.apache.tapestry5.ioc.annotations.Inject;
> import org.apache.tapestry5.services.ExceptionReporter;
> import org.apache.tapestry5.services.ajax.AjaxResponseRenderer;
> import org.apache.tapestry5.services.ajax.JavaScriptCallback;
> import org.apache.tapestry5.services.javascript.JavaScriptSupport;
>
> public class ExceptionReport implements ExceptionReporter {
>
> private static Logger log = Logger.getLogger(ExceptionReport.class);
>
>
> @Property
> private Date filterToDate;
>
> @Property
> private Throwable exception;
>
> @Inject
> private AjaxResponseRenderer ajaxResponseRenderer;
>
> @Property
> private String messageStackTrace;
>
> @Override
> public void reportException(Throwable exception) {
> this.exception = exception;
> log.error(exception);
> this.messageStackTrace = this.getStackMessageTrace();
> }
>
>
> private String getStackMessageTrace()
> {
> StringWriter errors = new StringWriter();
> exception.printStackTrace(new PrintWriter(errors));
> return errors.toString();
> }
>
>
> }
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


-- 
George Christman
www.CarDaddy.com
P.O. Box 735
Johnstown, New York


Error Exception Handling

2014-06-11 Thread Shaikh, Shahid
I am trying to have the Exception page shown in Tapestry when my GridDataSource 
throws an exception. How do i catch a ComponentEventException and have Tapestry 
redirect to the Exception page.

Your help is much appreciated!

Here is the logs.. 
org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582) 
Caused by: org.apache.tapestry5.runtime.ComponentEventException [at 
classpath:com/navicure/ui/admin/pages/incoming/IncomingFilesPage.tml, line 67] 
at 
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.processEventTriggering(ComponentPageElementImpl.java:1141)
 at 
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.access$3100(ComponentPageElementImpl.java:61)
 at 
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$5.invoke(ComponentPageElementImpl.java:1062)
 at 
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$5.invoke(ComponentPageElementImpl.java:1059)
 at 
org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:74)
 ... 100 more Caused by: java.lang.NullPointerException at 
com.navicure.ui.admin.tables.FragmentDataSource.getAvailableRows(FragmentDataSource.java:91)
 at 
org.got5.tapestry5.jquery.internal.DefaultDataTableModel.getResponse(DefaultDataTableModel.java:243)
 at 
org.got5.tapestry5.jquery.internal.DefaultDataTableModel.sendResponse(DefaultDataTableModel.java:375)
 at org.got5.tapestry5.jquery.components.DataTable.onData(DataTable.java:128) 
at 
org.got5.tapestry5.jquery.components.DataTable.dispatchComponentEvent(DataTable.java)
 at 
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.dispatchEvent(ComponentPageElementImpl.java:940)
 at 
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.processEventTriggering(ComponentPageElementImpl.java:1117)
 ... 104 more

Here is my object that implements ExceptionReporter

package com.navicure.ui.admin.pages;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Date;

import org.apache.log4j.Logger;
import org.apache.tapestry5.annotations.Log;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.ExceptionReporter;
import org.apache.tapestry5.services.ajax.AjaxResponseRenderer;
import org.apache.tapestry5.services.ajax.JavaScriptCallback;
import org.apache.tapestry5.services.javascript.JavaScriptSupport;

public class ExceptionReport implements ExceptionReporter {

private static Logger log = Logger.getLogger(ExceptionReport.class);


@Property
private Date filterToDate;

@Property
private Throwable exception;

@Inject
private AjaxResponseRenderer ajaxResponseRenderer;

@Property
private String messageStackTrace;

@Override
public void reportException(Throwable exception) {
this.exception = exception;
log.error(exception);
this.messageStackTrace = this.getStackMessageTrace();
}


private String getStackMessageTrace()
{
StringWriter errors = new StringWriter();
exception.printStackTrace(new PrintWriter(errors));
return errors.toString();
}


}


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Exception Handling

2014-06-10 Thread Shaikh, Shahid
I am trying to have the Exception page shown in Tapestry when my GridDataSource 
throws an exception. How do i catch a ComponentEventException nad have Tapestry 
redirect to the Exception page.

Your help is much appreciated!

Here is the logs.. 
org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582) 
Caused by: org.apache.tapestry5.runtime.ComponentEventException [at 
classpath:com/navicure/ui/admin/pages/incoming/IncomingFilesPage.tml, line 67] 
at 
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.processEventTriggering(ComponentPageElementImpl.java:1141)
 at 
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.access$3100(ComponentPageElementImpl.java:61)
 at 
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$5.invoke(ComponentPageElementImpl.java:1062)
 at 
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$5.invoke(ComponentPageElementImpl.java:1059)
 at 
org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:74)
 ... 100 more Caused by: java.lang.NullPointerException at 
com.navicure.ui.admin.tables.FragmentDataSource.getAvailableRows(FragmentDataSource.java:91)
 at 
org.got5.tapestry5.jquery.internal.DefaultDataTableModel.getResponse(DefaultDataTableModel.java:243)
 at 
org.got5.tapestry5.jquery.internal.DefaultDataTableModel.sendResponse(DefaultDataTableModel.java:375)
 at org.got5.tapestry5.jquery.components.DataTable.onData(DataTable.java:128) 
at 
org.got5.tapestry5.jquery.components.DataTable.dispatchComponentEvent(DataTable.java)
 at 
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.dispatchEvent(ComponentPageElementImpl.java:940)
 at 
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.processEventTriggering(ComponentPageElementImpl.java:1117)
 ... 104 more

Here is my object that implements ExceptionReporter

package com.navicure.ui.admin.pages;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Date;

import org.apache.log4j.Logger;
import org.apache.tapestry5.annotations.Log;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.ExceptionReporter;
import org.apache.tapestry5.services.ajax.AjaxResponseRenderer;
import org.apache.tapestry5.services.ajax.JavaScriptCallback;
import org.apache.tapestry5.services.javascript.JavaScriptSupport;

public class ExceptionReport implements ExceptionReporter {

private static Logger log = Logger.getLogger(ExceptionReport.class);


@Property
private Date filterToDate;

@Property
private Throwable exception;

@Inject
private AjaxResponseRenderer ajaxResponseRenderer;

@Property
private String messageStackTrace;

@Override
public void reportException(Throwable exception) {
this.exception = exception;
log.error(exception);
this.messageStackTrace = this.getStackMessageTrace();
}


private String getStackMessageTrace()
{
StringWriter errors = new StringWriter();
exception.printStackTrace(new PrintWriter(errors));
return errors.toString();
}


}


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: component event exception, handling in page with onException method

2014-02-14 Thread Chris Mylonas
g'day,

please ignore the previous email.
everything is working as expected now.
a sleep, reboot and relocation to a more relaxing setting seems to be the
way to fix this issue :)

chris


On Fri, Feb 14, 2014 at 8:53 PM, Chris Mylonas  wrote:

> hi users,
>
> i'm having trouble catching a component event exception.  it's on a zone
> update.
>
> at this stage in development, i want to catch it and just reload the page
>
> Object onException(Throwable cause) {
> String message = cause.getMessage();
> logger.info("BASTARD");
> return this;
> }
>
> I'm not seeing my "BASTARD" message in the server log, and i'm not getting
> the page reload.
>
> I am just seeing the javscript pop up exception (for the zone update)
>
> This is with tapestry 5.3.7
>
> Any pointers appreciated.
>
> The exception is coming from an EJB.  Something doesn't exist in this zone
> update preview mode e.g. the user wants a sneaky look behind door number 3,
> when door number 3 doesn't exit."
>
> Cheers
> Chris
>


component event exception, handling in page with onException method

2014-02-14 Thread Chris Mylonas
hi users,

i'm having trouble catching a component event exception.  it's on a zone
update.

at this stage in development, i want to catch it and just reload the page

Object onException(Throwable cause) {
String message = cause.getMessage();
logger.info("BASTARD");
return this;
}

I'm not seeing my "BASTARD" message in the server log, and i'm not getting
the page reload.

I am just seeing the javscript pop up exception (for the zone update)

This is with tapestry 5.3.7

Any pointers appreciated.

The exception is coming from an EJB.  Something doesn't exist in this zone
update preview mode e.g. the user wants a sneaky look behind door number 3,
when door number 3 doesn't exit."

Cheers
Chris


Re: How to implement simple error/exception handling

2013-08-22 Thread Martin Kersten
This is outside the scope of Tapestry (or at least as far as I am aware
off). Take a look at this example:

http://jumpstart.doublenegative.com.au/jumpstart/together/easycrud/persons

If you hit the Delete on any row it opens a modal dialog asking you whether
or not the item should be really deleted. In your case you need a info box
with a meaningful Information message explaining the error to the user.

You can use jQuery UI for this (check the jQuery for Tapestry modul) or use
what they used in the above example. The Keypart is confirm.js here.

If you need a tapestry only usage you might want to consider a component /
mixin that is returned in case of a XHR request (ajax) and opens the
infobox and vanishes (removes itself from the DOM) after the ok button was
clicked. I dont know if such a component exist and the use would be limited
to zone updates and alike. Also I am not aware of Tapestry providing such a
component (or something similar).

Lets wait what the Tapestry Pros come up with.


2013/8/22 nn kk 

>  Hi,
> I read about exceptions and error handling in tapestry, but still can not
> find the best way, to send messages to front-end. I want to be able to send
> exception messages and error codes, as I can do it in jquary ajax success
> or error blocks. When I throw some custom exception I don't want to
> redirect to the exception page, but to show the message in pop-up to the
> user. Or to send different completion messages and to display them in
> dialogs. I managed to open dialogs with callbacks of ajax object as here:
>  ajaxResponseRenderer.addCallback(new
> JavaScriptCallback() {
>
> @Override
> public void run(JavaScriptSupport
> javaScriptSupport) {
>
> javaScriptSupport.addScript("showErrorModal();");
> }
> })
>
> , but still can not make it enough generic. And it is not working working
> when I submit the whole page.
>
> -
> Само сега спечели смартфон SAMSUNG и още много награди!виж
> http://www.specheli.eu/specheli-textgbg.php
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


How to implement simple error/exception handling

2013-08-22 Thread nn kk
 Hi,
I read about exceptions and error handling in tapestry, but still can not find 
the best way, to send messages to front-end. I want to be able to send 
exception messages and error codes, as I can do it in jquary ajax success or 
error blocks. When I throw some custom exception I don't want to redirect to 
the exception page, but to show the message in pop-up to the user. Or to send 
different completion messages and to display them in dialogs. I managed to open 
dialogs with callbacks of ajax object as here:
 ajaxResponseRenderer.addCallback(new JavaScriptCallback() {

@Override
public void run(JavaScriptSupport 
javaScriptSupport) {

javaScriptSupport.addScript("showErrorModal();");
}
})

, but still can not make it enough generic. And it is not working working when 
I submit the whole page.

-
Само сега спечели смартфон SAMSUNG и още много награди!виж
http://www.specheli.eu/specheli-textgbg.php

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: exception handling

2013-08-21 Thread Thiago H de Paula Figueiredo

On Wed, 21 Aug 2013 10:47:35 -0300, nn kk  wrote:


 Hi,


Hi!

I want to create my custom exception handling, I saw there are a few  
ways to replace the Exception Report Page or override the  
RequestExceptionHandler and again replace the default page. But is it  
possible to handle only specific type of exceptions, or exceptions from  
specific pages or forms, and to leave the rest to the default?


Advise or decorate RequestExceptionHandler using Tapestry-IoC instead of  
overriding.


--
Thiago H. de Paula Figueiredo

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: exception handling

2013-08-21 Thread Lenny Primak
Take a look at Tynamo tapestry-exceptionpage module.
http://docs.codehaus.org/display/TYNAMO/tapestry-exceptionpage+guide

On Aug 21, 2013, at 9:47 AM, nn kk wrote:

> Hi,
> I want to create my custom exception handling, I saw there are a few ways to 
> replace the Exception Report Page or override the RequestExceptionHandler and 
> again replace the default page. But is it possible to handle only specific 
> type of exceptions, or exceptions from specific pages or forms, and to leave 
> the rest to the default? It will be best if it can be done to redirect 
> diferent exceptions to different pages again depending on the concrete page 
> or form where the exception is thrown
> 
> Best Regards!
> 
> -
> Само сега спечели смартфон SAMSUNG и още много награди!виж
> http://www.specheli.eu/specheli-textgbg.php
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
> 


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



exception handling

2013-08-21 Thread nn kk
 Hi,
I want to create my custom exception handling, I saw there are a few ways to 
replace the Exception Report Page or override the RequestExceptionHandler and 
again replace the default page. But is it possible to handle only specific type 
of exceptions, or exceptions from specific pages or forms, and to leave the 
rest to the default? It will be best if it can be done to redirect diferent 
exceptions to different pages again depending on the concrete page or form 
where the exception is thrown

Best Regards!

-
Само сега спечели смартфон SAMSUNG и още много награди!виж
http://www.specheli.eu/specheli-textgbg.php

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: graceful exception handling - user interface

2013-03-23 Thread Bryan Lewis
It sounds like this might be helpful:
http://tapestry.apache.org/overriding-exception-reporting.html


On Sat, Mar 23, 2013 at 9:34 AM, Ken in Nashua  wrote:

> I guess I am wondering if i can catch these exceptions in a centralized
> place and just present the most meaningful text in a popup dialog for the
> user to acknowledge and keep the page user interface intact.
>
>


RE: graceful exception handling - user interface

2013-03-23 Thread Ken in Nashua
I guess I am wondering if i can catch these exceptions in a centralized place 
and just present the most meaningful text in a popup dialog for the user to 
acknowledge and keep the page user interface intact.

  

graceful exception handling - user interface

2013-03-22 Thread Ken in Nashua
Hi Folks,

Well I am about to embark on going public with a hockey league web site and I 
wanted to reformat these intimidating (well not for developers) for 
end-users... stack traces when an exception occurs. And its nice to be able to 
use tapestry in such a fashionable way now and the supported frameworks. Nice 
Job... well done. Its come a  long way since the version 3. I hope it will fair 
another decade or two (could sure use some feedback on that topic of 
longevity... will tapestry be around 20 years from now ? ) Java guys need to 
stick together.

I had a couple questions
Do any of these exceptions require the web server to be rebooted? I guess I am 
wondering if there are certain crashes in tapestry that would warrant a reboot 
of the webserver, restart of the webapp... or even a reboot of the operating 
system. None I hope but I had to ask.Is there a user interface available that 
will present these exceptions in a nice friendly format for the end-user? Maybe 
an optional dialogue instead of the whole page being taken out. 
 

Re: Joining tapestry exception handling

2012-05-12 Thread Felix Gonschorek
you have to pay attention not to let your log4j smtp logger append in
"sync" mode - your system will stall, until the logging message has been
sent (which could be a few seconds, depending how you send your mail).
your have to use an async logger. this is an example configuration i use
in my system. only "error" level logging events will be sent by mail,
all other stuff is logged to a regular file:



http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd";>

http://jakarta.apache.org/log4j/";>



















































%X{requestedUrl} is a MDC log4j variable and i store the requested URL
in it. it helps a lot when you have to debug requests (often crawlers
and bots send requests with invalid characters in the url - this way you
can easily detect this). to store the requested url in the MDC i
implemented a wrapper around the TapestryFilter which stores the
requested url before the filtered request get's handled by tapestry.


private static final Logger log   =
LoggerFactory.getLogger(MyFilter.class);

private TapestryFilter  tapFilter = null;

@Override
public final void doFilter(ServletRequest request, ServletResponse
response, FilterChain chain) throws IOException,

   ServletException {
try {
MDC.put("requestedUrl", this.getRequestedUrl(request));
if (this.tapFilter != null) {
this.tapFilter.doFilter(request, response, chain);
}
else {
chain.doFilter(request, response);
}
}
finally {
MDC.clear();
}
}

private String getRequestedUrl(ServletRequest request) {
try {
StringBuilder buffer = new StringBuilder();
if (request instanceof HttpServletRequest) {
HttpServletRequest httpServletRequest =
(HttpServletRequest) request;
buffer.append(httpServletRequest.getRequestURL());
}
return buffer.toString();
}
catch (Exception exception) {
return null;
}
}

@Override
public final void destroy() {
if (this.tapFilter != null) {
this.tapFilter.destroy();
}
}

@Override
public final void init(FilterConfig filterConfig) throws
ServletException {
log.debug("Initializing Tapestry filter");
this.tapFilter = new TapestryFilter();
this.tapFilter.init(filterConfig);
log.debug("Tapestry Filter initialized!");
}




Am 12.05.2012 14:51, schrieb Bob Harner:
> You couldd also have the logging system send the emails. Log4j can handle
> this quite easily.
> On May 11, 2012 7:35 AM, "Dmitry Gusev"  wrote:
> 
>> Try this:
>>
>> http://tapestry.apache.org/overriding-exception-reporting.html
>>
>> On Fri, May 11, 2012 at 3:21 PM, jeczmien >> wrote:
>>
>>> I need advice how to execute my code during tapestry exception handling.
>>>
>>>
>>> Current:
>>> 1. Something wrong has happen and tapestry shows exception page
>>> 2. error is logged in container' log
>>>
>>> My use case:
>>> 1. Something wrong has happen and tapestry shows exception page
>>> 2. error is logged in container' log
>>> 3. my method sends email notification to system operator containing
>>> exception log, or eventually exception page generated when application
>>> PRODUCTION_MODE is false.
>>>
>>> is there any contribute method for this?
>>>
>>> --
>>> View this message in context:
>>>
>> http://tapestry.1045711.n5.nabble.com/Joining-tapestry-exception-handling-tp5702797.html
>>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>>
>>> -
>>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>>
>>>
>>
>>
>> --
>> Dmitry Gusev
>>
>> AnjLab Team
>> http://anjlab.com
>>
> 


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Joining tapestry exception handling

2012-05-12 Thread Bob Harner
You couldd also have the logging system send the emails. Log4j can handle
this quite easily.
On May 11, 2012 7:35 AM, "Dmitry Gusev"  wrote:

> Try this:
>
> http://tapestry.apache.org/overriding-exception-reporting.html
>
> On Fri, May 11, 2012 at 3:21 PM, jeczmien  >wrote:
>
> > I need advice how to execute my code during tapestry exception handling.
> >
> >
> > Current:
> > 1. Something wrong has happen and tapestry shows exception page
> > 2. error is logged in container' log
> >
> > My use case:
> > 1. Something wrong has happen and tapestry shows exception page
> > 2. error is logged in container' log
> > 3. my method sends email notification to system operator containing
> > exception log, or eventually exception page generated when application
> > PRODUCTION_MODE is false.
> >
> > is there any contribute method for this?
> >
> > --
> > View this message in context:
> >
> http://tapestry.1045711.n5.nabble.com/Joining-tapestry-exception-handling-tp5702797.html
> > Sent from the Tapestry - User mailing list archive at Nabble.com.
> >
> > -
> > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> > For additional commands, e-mail: users-h...@tapestry.apache.org
> >
> >
>
>
> --
> Dmitry Gusev
>
> AnjLab Team
> http://anjlab.com
>


Re: Joining tapestry exception handling

2012-05-11 Thread Dmitry Gusev
Try this:

http://tapestry.apache.org/overriding-exception-reporting.html

On Fri, May 11, 2012 at 3:21 PM, jeczmien wrote:

> I need advice how to execute my code during tapestry exception handling.
>
>
> Current:
> 1. Something wrong has happen and tapestry shows exception page
> 2. error is logged in container' log
>
> My use case:
> 1. Something wrong has happen and tapestry shows exception page
> 2. error is logged in container' log
> 3. my method sends email notification to system operator containing
> exception log, or eventually exception page generated when application
> PRODUCTION_MODE is false.
>
> is there any contribute method for this?
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Joining-tapestry-exception-handling-tp5702797.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


-- 
Dmitry Gusev

AnjLab Team
http://anjlab.com


Joining tapestry exception handling

2012-05-11 Thread jeczmien
I need advice how to execute my code during tapestry exception handling.


Current:
1. Something wrong has happen and tapestry shows exception page 
2. error is logged in container' log

My use case:
1. Something wrong has happen and tapestry shows exception page 
2. error is logged in container' log
3. my method sends email notification to system operator containing
exception log, or eventually exception page generated when application
PRODUCTION_MODE is false.

is there any contribute method for this?

--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Joining-tapestry-exception-handling-tp5702797.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Exception handling in Tomcat 6.0.33

2012-01-31 Thread Kalle Korhonen
Good thing, that's one way to set things up and I've used it myself
but it only goes half way. The even better idea (if I say so myself)
is to use Tynamo's (and in the future core Tapestry)
tapestry-exceptionpage module for mapping exceptions directly to error
pages (see http://tynamo.org/tapestry-exceptionpage+guide).

Kalle


On Tue, Jan 31, 2012 at 8:41 AM, Brian Long  wrote:
> Hi Kalle,
>
> yes I managed finally track down the answer after searching through
> pages of search results, unfortunately my original search query
> included the terms "tomcat", "tapestry" and "error" which produces
> reams of result (most of them irrelevant)!
>
> Like you mentioned in your reply I needed to add an error dispatcher
> (like example here: http://tapestry.apache.org/error-page-recipe.html)
>
>    
>        app
>        /*
>        FORWARD
>        REQUEST
>        ERROR
>    
>
> I then mapped error codes to tapestry URLs
>
>    
>        500
>        /ExceptionReport
>    
>    
>        404
>        /ExceptionReport
>    
>
> Tomcat then started to redirect these error types to my Exception
> Report page like Jetty already does. Hopefully this answer will be
> found by the next person looking into this issue.
>
> Thanks for the link explaining why the tapestry exception report
> filter works in Jetty but not in Tomcat . . .
>
> Regards, Brian.
>
> On 31 January 2012 16:18, Kalle Korhonen  wrote:
>> Are you setting an error code to your response? You haven't configured
>> the filter to handle error dispatches:
>>        
>>                app
>>                /*
>>                REQUEST
>>                ERROR
>>        
>>
>> Error handling in Jetty and Tomcat differ, see
>> http://www.cacoethes.co.uk/blog/software/a-tomcat-gotcha for more
>> info.
>>
>> Kalle
>>
>>
>> On Tue, Jan 31, 2012 at 2:50 AM, Brian Long  wrote:
>>> Hi all,
>>>
>>> I'm sure I'm not the first person to experience this issue but can't
>>> seem to find any answers in the mail archive or on the web. I have an
>>> ExceptionReport page implementing ExceptionReporter so any nasty
>>> surprises like NPE's result in a nice and friendly "We experiencing
>>> technical difficulties" page being presented to the user, this works
>>> fine in jetty but when I deploy my war file to tomcat 6, the
>>> exceptions are not caught by the ExceptionReporter and the stacktrace
>>> is shown to the user?
>>>
>>> If anyone know what setting in tomcat needs to change so I can get
>>> this to work as it does in jetty I appreciate it.
>>>
>>> Regards, Brian.
>>>
>>>
>>>
>>> -
>>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>
>> -
>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Exception handling in Tomcat 6.0.33

2012-01-31 Thread Brian Long
Hi Kalle,

yes I managed finally track down the answer after searching through
pages of search results, unfortunately my original search query
included the terms "tomcat", "tapestry" and "error" which produces
reams of result (most of them irrelevant)!

Like you mentioned in your reply I needed to add an error dispatcher
(like example here: http://tapestry.apache.org/error-page-recipe.html)


app
/*
FORWARD
REQUEST
ERROR


I then mapped error codes to tapestry URLs


500
/ExceptionReport


404
/ExceptionReport


Tomcat then started to redirect these error types to my Exception
Report page like Jetty already does. Hopefully this answer will be
found by the next person looking into this issue.

Thanks for the link explaining why the tapestry exception report
filter works in Jetty but not in Tomcat . . .

Regards, Brian.

On 31 January 2012 16:18, Kalle Korhonen  wrote:
> Are you setting an error code to your response? You haven't configured
> the filter to handle error dispatches:
>        
>                app
>                /*
>                REQUEST
>                ERROR
>        
>
> Error handling in Jetty and Tomcat differ, see
> http://www.cacoethes.co.uk/blog/software/a-tomcat-gotcha for more
> info.
>
> Kalle
>
>
> On Tue, Jan 31, 2012 at 2:50 AM, Brian Long  wrote:
>> Hi all,
>>
>> I'm sure I'm not the first person to experience this issue but can't
>> seem to find any answers in the mail archive or on the web. I have an
>> ExceptionReport page implementing ExceptionReporter so any nasty
>> surprises like NPE's result in a nice and friendly "We experiencing
>> technical difficulties" page being presented to the user, this works
>> fine in jetty but when I deploy my war file to tomcat 6, the
>> exceptions are not caught by the ExceptionReporter and the stacktrace
>> is shown to the user?
>>
>> If anyone know what setting in tomcat needs to change so I can get
>> this to work as it does in jetty I appreciate it.
>>
>> Regards, Brian.
>>
>>
>>
>> -
>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>> For additional commands, e-mail: users-h...@tapestry.apache.org
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Exception handling in Tomcat 6.0.33

2012-01-31 Thread Kalle Korhonen
Are you setting an error code to your response? You haven't configured
the filter to handle error dispatches:

app
/*
REQUEST
ERROR


Error handling in Jetty and Tomcat differ, see
http://www.cacoethes.co.uk/blog/software/a-tomcat-gotcha for more
info.

Kalle


On Tue, Jan 31, 2012 at 2:50 AM, Brian Long  wrote:
> Hi all,
>
> I'm sure I'm not the first person to experience this issue but can't
> seem to find any answers in the mail archive or on the web. I have an
> ExceptionReport page implementing ExceptionReporter so any nasty
> surprises like NPE's result in a nice and friendly "We experiencing
> technical difficulties" page being presented to the user, this works
> fine in jetty but when I deploy my war file to tomcat 6, the
> exceptions are not caught by the ExceptionReporter and the stacktrace
> is shown to the user?
>
> If anyone know what setting in tomcat needs to change so I can get
> this to work as it does in jetty I appreciate it.
>
> Regards, Brian.
>
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Exception handling in Tomcat 6.0.33

2012-01-31 Thread Brian Long
Hi all,

I'm sure I'm not the first person to experience this issue but can't
seem to find any answers in the mail archive or on the web. I have an
ExceptionReport page implementing ExceptionReporter so any nasty
surprises like NPE's result in a nice and friendly "We experiencing
technical difficulties" page being presented to the user, this works
fine in jetty but when I deploy my war file to tomcat 6, the
exceptions are not caught by the ExceptionReporter and the stacktrace
is shown to the user?

If anyone know what setting in tomcat needs to change so I can get
this to work as it does in jetty I appreciate it.

Regards, Brian.


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Re: [TYNAMO] Exception Handling

2011-11-24 Thread Nicolas Barrera
got it,

same as me.

Nicolás.-


Re: [TYNAMO] Exception Handling

2011-11-24 Thread Lenny Primak
**
   **  THIS IS A WARNING MESSAGE ONLY  **
   **  YOU DO NOT NEED TO RESEND YOUR MESSAGE  **
   **

The original message was received at Wed, 22 Jun 2011 08:26:07 -0400
from user-0cdfs5f.cable.mindspring.com [24.215.240.175]

  - Transcript of session follows -
... while talking to mail.codehaus.org.:
>>> RCPT To:
<<< 451 IP 66.114.74.12 is UCEPROTECT-Level 1 listed. See 
http://www.uceprotect.net/rblcheck.php?ipr=66.114.74.12
... Deferred: 451 IP 66.114.74.12 is UCEPROTECT-Level 
1 listed. See http://www.uceprotect.net/rblcheck.php?ipr=66.114.74.12
Warning: message still undelivered after 4 hours
Will keep trying until message is 5 days old
Reporting-MTA: dns; mail1.aceinnovative.com
Arrival-Date: Wed, 22 Jun 2011 08:26:07 -0400

Final-Recipient: RFC822; u...@tynamo.codehaus.org
Action: delayed
Status: 4.3.0
Remote-MTA: DNS; mail.codehaus.org
Diagnostic-Code: SMTP; 451 IP 66.114.74.12 is UCEPROTECT-Level 1 listed. See
http://www.uceprotect.net/rblcheck.php?ipr=66.114.74.12
Last-Attempt-Date: Wed, 22 Jun 2011 12:38:23 -0400

From: Lenny Primak 
Date: June 22, 2011 8:26:06 AM EDT
To: "u...@tynamo.codehaus.org" 
Subject: Re: [tynamo-user] Re: Maven Checksum Failure with Tynamo JPA / Security



On Nov 24, 2011, at 1:39 PM, Lenny Primak wrote:

> The Tynamo list has never worked for me.  It seems that it works for some
> users and not others.  I get a bounced E-mail when I send it to the tynamo 
> list.


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: [TYNAMO] Exception Handling

2011-11-24 Thread Lenny Primak
The Tynamo list has never worked for me.  It seems that it works for some
users and not others.  I get a bounced E-mail when I send it to the tynamo list.

On Nov 24, 2011, at 1:36 PM, Nicolas Barrera wrote:

> Hi Ale,
> 
> thanks for the help, so you say that tynamo's mailing list should be
> working alright but just for moment to moment is down? then i 'll be
> retrying to post there.
> 
> About what you answered me...
> 
> i 've finally avoided the problem overriding the isAllowRemove method
> calling one of the bean's specific method which tells me if it has children
> relationship, then instead of the delete link I print a "you can't delete"
> message.
> 
> About what you suggested... I can file a Jira issue no problem (and post
> the patch if I can), but let me be sure that I understand your proposal...,
> 
> 
> You 'd like to modify Tynamo's Show page's method onActionFromDelete
> catching up a JDBCBatchException or something like that?
> 
> I was thinking about that and I would catch an HibernateException and
> return a link to the same page..., what I 'm not sure is about the way to
> report the error to the end user...
> is there any component which shows an overlay/modal with the error message?
> Anyway the HibernateException could be any error not only this kind of
> database error.
> 
> well about the second error on my second mail, it was something else I was
> doing wrong that I could solve, and the difference between Locality and
> Sucursal was just me trying to translate my class names :S
> 
> 
> if the tynamo list is up, then i will continue this thread there,
> 
> thanks again, and I 'll wait for your comments on my ideas about the patch.
> 
> cheers,
> 
> Nicolás.-
> 
> 
> On Thu, Nov 24, 2011 at 1:54 PM, Alejandro Scandroli <
> alejandroscandr...@gmail.com> wrote:
> 
>> Hi Nicolás
>> 
>>> 
>>> - Am I obliged to make a custom page in order to catch up that exception
>>> and show the user a friendly message? (something like "hey!, you can't
>>> delete this locality as it's referenced by other persons")
>>> 
>> 
>>   No really, you can catch the exception in your own Show.java page
>> overriding (onActionFromDelete). You can also try some other (weird
>> bidirectional) mapping alternatives, but I think the cleanest option
>> is the custom page.
>>  I think this could be a nice thing to add by default, since it
>> could be a very common issue. Do you mind filing a JIRA issue for it?
>> (a patch would be wonderful btw)
>> 
>>> - I 've read about the tynamo-exceptionpage module which I think it will
>>> catch up the error, but will show a generic error message per exception I
>>> register am I right?
>>> 
>> 
>>   That's exactly right!
>> 
>>> (….)
>>> the result is that after I create a new Locality, it forwards to the show
>>> locality page but before rendering this error shows up:
>>> 
>>> org.apache.tapestry5.internal.services.RenderQueueException
>> 
>> I don't know what could be wrong here. I need for info.
>> The only thing weird I see is that if the page name is LocalityShow,
>> the getType() method should return Class instead of
>> Class
>> 
>> 
>> BTW, you are not the first reporting problems with tynamo's user list,
>> but still can figure out why sometimes doesn't work. I will try
>> (again) to send a test email later.
>> 
>> Thanks and welcome.
>> 
>> Saludos.
>> Alejandro.
>> 
>> -
>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>> For additional commands, e-mail: users-h...@tapestry.apache.org
>> 
>> 


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: [TYNAMO] Exception Handling

2011-11-24 Thread Nicolas Barrera
Hi Ale,

thanks for the help, so you say that tynamo's mailing list should be
working alright but just for moment to moment is down? then i 'll be
retrying to post there.

About what you answered me...

i 've finally avoided the problem overriding the isAllowRemove method
calling one of the bean's specific method which tells me if it has children
relationship, then instead of the delete link I print a "you can't delete"
message.

About what you suggested... I can file a Jira issue no problem (and post
the patch if I can), but let me be sure that I understand your proposal...,


You 'd like to modify Tynamo's Show page's method onActionFromDelete
catching up a JDBCBatchException or something like that?

I was thinking about that and I would catch an HibernateException and
return a link to the same page..., what I 'm not sure is about the way to
report the error to the end user...
is there any component which shows an overlay/modal with the error message?
Anyway the HibernateException could be any error not only this kind of
database error.

well about the second error on my second mail, it was something else I was
doing wrong that I could solve, and the difference between Locality and
Sucursal was just me trying to translate my class names :S


if the tynamo list is up, then i will continue this thread there,

thanks again, and I 'll wait for your comments on my ideas about the patch.

cheers,

Nicolás.-


On Thu, Nov 24, 2011 at 1:54 PM, Alejandro Scandroli <
alejandroscandr...@gmail.com> wrote:

> Hi Nicolás
>
> >
> > - Am I obliged to make a custom page in order to catch up that exception
> > and show the user a friendly message? (something like "hey!, you can't
> > delete this locality as it's referenced by other persons")
> >
>
>No really, you can catch the exception in your own Show.java page
> overriding (onActionFromDelete). You can also try some other (weird
> bidirectional) mapping alternatives, but I think the cleanest option
> is the custom page.
>   I think this could be a nice thing to add by default, since it
> could be a very common issue. Do you mind filing a JIRA issue for it?
> (a patch would be wonderful btw)
>
> > - I 've read about the tynamo-exceptionpage module which I think it will
> > catch up the error, but will show a generic error message per exception I
> > register am I right?
> >
>
>That's exactly right!
>
> > (….)
> > the result is that after I create a new Locality, it forwards to the show
> > locality page but before rendering this error shows up:
> >
> > org.apache.tapestry5.internal.services.RenderQueueException
>
> I don't know what could be wrong here. I need for info.
> The only thing weird I see is that if the page name is LocalityShow,
> the getType() method should return Class instead of
> Class
>
>
> BTW, you are not the first reporting problems with tynamo's user list,
> but still can figure out why sometimes doesn't work. I will try
> (again) to send a test email later.
>
> Thanks and welcome.
>
> Saludos.
> Alejandro.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


Re: [TYNAMO] Exception Handling

2011-11-24 Thread Alejandro Scandroli
Hi Nicolás

>
> - Am I obliged to make a custom page in order to catch up that exception
> and show the user a friendly message? (something like "hey!, you can't
> delete this locality as it's referenced by other persons")
>

   No really, you can catch the exception in your own Show.java page
overriding (onActionFromDelete). You can also try some other (weird
bidirectional) mapping alternatives, but I think the cleanest option
is the custom page.
   I think this could be a nice thing to add by default, since it
could be a very common issue. Do you mind filing a JIRA issue for it?
(a patch would be wonderful btw)

> - I 've read about the tynamo-exceptionpage module which I think it will
> catch up the error, but will show a generic error message per exception I
> register am I right?
>

   That's exactly right!

> (….)
> the result is that after I create a new Locality, it forwards to the show
> locality page but before rendering this error shows up:
>
> org.apache.tapestry5.internal.services.RenderQueueException

I don't know what could be wrong here. I need for info.
The only thing weird I see is that if the page name is LocalityShow,
the getType() method should return Class instead of
Class


BTW, you are not the first reporting problems with tynamo's user list,
but still can figure out why sometimes doesn't work. I will try
(again) to send a test email later.

Thanks and welcome.

Saludos.
Alejandro.

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: [TYNAMO] Exception Handling

2011-11-23 Thread Nicolas Barrera
Hi, I went for customizing the Location page,

generated a pages/show/LocalityShow.java and .tml

the tml I copied it from the Show.tml file

and the .java I overrided the following methods:

public Class getType() {
> public Link onActionFromDelete() {
> public boolean isAllowRemove() {
>

the result is that after I create a new Locality, it forwards to the show
locality page but before rendering this error shows up:

org.apache.tapestry5.internal.services.RenderQueueException
>
> Render queue error in
> SetupRender[tynamo/PropertyDisplayBlocks:composition]: Failure reading
> parameter 'owner' of component tynamo/PropertyDisplayBlocks:composition:
> Class org.apache.tapestry5.corelib.components.BeanDisplay does not contain
> a property named 'null'.
>


sorry but I can't figure out what this is about... :S

Would be glad if someone threw some invoice here,

thanks!

Nicolás.-


On Wed, Nov 23, 2011 at 9:19 AM, Nicolas Barrera  wrote:

> Hi all, (sorry I 'm asking about tynamo on Tapestry's user list but I
> tried to use us...@tynamo.codehaus.org but mailer said it wasn't working)
>
> Here goes a newbie question runner up...:
>
> I got a tynamo app working using the archetype and then modifying it, I
> got two model classes
>
> - Person
> - Locality
>
> so that a person lives in a locality, then it has a reference to it.
>
> When I try deleting a Locality (one that some Person is still
> referencing)  using the delete link on the generic Show page I got an 
> org.hibernate.exception.ConstraintViolationException,
> that's fine it sounds logical as I ain't got any cascade configured.
>
> But my question is...,
>
> - Am I obliged to make a custom page in order to catch up that exception
> and show the user a friendly message? (something like "hey!, you can't
> delete this locality as it's referenced by other persons")
> - I 've read about the tynamo-exceptionpage module which I think it will
> catch up the error, but will show a generic error message per exception I
> register am I right?
>
> I hope you could help me on my tynamo baptism...
>
> cheers and thanks in advance!
>
> Nicolás.-


[TYNAMO] Exception Handling

2011-11-23 Thread Nicolas Barrera
Hi all, (sorry I 'm asking about tynamo on Tapestry's user list but I tried
to use us...@tynamo.codehaus.org but mailer said it wasn't working)

Here goes a newbie question runner up...:

I got a tynamo app working using the archetype and then modifying it, I got
two model classes

- Person
- Locality

so that a person lives in a locality, then it has a reference to it.

When I try deleting a Locality (one that some Person is still referencing)
using the delete link on the generic Show page I got an
org.hibernate.exception.ConstraintViolationException,
that's fine it sounds logical as I ain't got any cascade configured.

But my question is...,

- Am I obliged to make a custom page in order to catch up that exception
and show the user a friendly message? (something like "hey!, you can't
delete this locality as it's referenced by other persons")
- I 've read about the tynamo-exceptionpage module which I think it will
catch up the error, but will show a generic error message per exception I
register am I right?

I hope you could help me on my tynamo baptism...

cheers and thanks in advance!

Nicolás.-


Re: tynamo exception handling doesn't work in setupRender?

2010-08-31 Thread Kalle Korhonen
File a (Tynamo) issue and I'll take a look.

Kalle


On Tue, Aug 31, 2010 at 6:31 PM, Paul Stanton  wrote:
> I'm using the Tynamo tapestry-exception module, and for the most part it
> works great, however I've noticed that it doesn't seem to work for
> exceptions thrown during a 'setupRender' event handler. These exceptions are
> wrapped in a 'RenderQueueException' and load in the normal tapestry
> exception page.
>
> Is this a known issue within Tynamo? Should it work/be fixed?
>
> Regards, Paul.
>
> public class AppModule
> {
>   public void contributeExceptionHandler(MappedConfiguration,
> Class> configuration)
>   {
>       configuration.add(MyException.class, MyExceptionPage.class);
>   }
> }
>
> public class Start
> {
>   public void onActivate()
>   {
>       if (new Random().nextBoolean())
>           throw new MyException("onActivate");
>   }
>
>   public void setupRender()
>   {
>       if (new Random().nextBoolean())
>           throw new MyException("setupRender");
>   }
> }
>

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



tynamo exception handling doesn't work in setupRender?

2010-08-31 Thread Paul Stanton
I'm using the Tynamo tapestry-exception module, and for the most part it 
works great, however I've noticed that it doesn't seem to work for 
exceptions thrown during a 'setupRender' event handler. These exceptions 
are wrapped in a 'RenderQueueException' and load in the normal tapestry 
exception page.


Is this a known issue within Tynamo? Should it work/be fixed?

Regards, Paul.

public class AppModule
{
   public void contributeExceptionHandler(MappedConfiguration, 
Class> configuration)

   {
   configuration.add(MyException.class, MyExceptionPage.class);
   }
}

public class Start
{
   public void onActivate()
   {
   if (new Random().nextBoolean())
   throw new MyException("onActivate");
   }

   public void setupRender()
   {
   if (new Random().nextBoolean())
   throw new MyException("setupRender");
   }
}

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Blog post about T5 exception handling on GAE

2010-08-27 Thread Dmitry Gusev
Have you looked at the link I've posted in my first message? :)

I know I can override the error page. But I like the default one. I just
don't like its default behavior which only relies on PRODUCTION_MODE
symbol.
What I suggest is to change this behavior and analyze if the user that get
this exception is a local user.
And if its a local user show him error page just like it was in
non-production mode. This is what RemoteOnly mode means in ASP.NET.

On Fri, Aug 27, 2010 at 16:19, Thiago H. de Paula Figueiredo <
thiag...@gmail.com> wrote:

> On Fri, 27 Aug 2010 09:13:41 -0300, Dmitry Gusev 
> wrote:
>
>  Yes, I should say test.
>> I didn't mean running java debugger.
>> I mean trying to reproduce some test case using browser and getting
>> exception page.
>>
>
> You can override the error page (which I recommend, anyway), use the logic
> you want for showing or not the stack trace and use the ExceptionDisplay
> component to show the exception.
>
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
> and instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> http://www.arsmachina.com.br
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


-- 
Dmitry Gusev

AnjLab Team
http://anjlab.com


Re: Blog post about T5 exception handling on GAE

2010-08-27 Thread Thiago H. de Paula Figueiredo
On Fri, 27 Aug 2010 09:13:41 -0300, Dmitry Gusev   
wrote:



Yes, I should say test.
I didn't mean running java debugger.
I mean trying to reproduce some test case using browser and getting
exception page.


You can override the error page (which I recommend, anyway), use the logic  
you want for showing or not the stack trace and use the ExceptionDisplay  
component to show the exception.


--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor

Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Blog post about T5 exception handling on GAE

2010-08-27 Thread Dmitry Gusev
Yes, I should say test.
I didn't mean running java debugger.
I mean trying to reproduce some test case using browser and getting
exception page.

On Fri, Aug 27, 2010 at 16:10, Thiago H. de Paula Figueiredo <
thiag...@gmail.com> wrote:

> On Fri, 27 Aug 2010 08:50:16 -0300, Dmitry Gusev 
> wrote:
>
>  There might be another issue though, what if I need to debug application
>> behavior in production mode?
>>
>
> I can't think why you cannot debug the application in production mode in
> the same way you do in non-production mode. Debugging is a JVM matter, not a
> Tapestry one.
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
> and instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> http://www.arsmachina.com.br
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


-- 
Dmitry Gusev

AnjLab Team
http://anjlab.com


Re: Blog post about T5 exception handling on GAE

2010-08-27 Thread Thiago H. de Paula Figueiredo
On Fri, 27 Aug 2010 08:50:16 -0300, Dmitry Gusev   
wrote:



There might be another issue though, what if I need to debug application
behavior in production mode?


I can't think why you cannot debug the application in production mode in  
the same way you do in non-production mode. Debugging is a JVM matter, not  
a Tapestry one.


--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor

Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Blog post about T5 exception handling on GAE

2010-08-27 Thread Dmitry Gusev
Thanks Jim, this might be a solution for most cases.

There might be another issue though, what if I need to debug application
behavior in production mode?
In this mode some services may work different way.
In this case there's no way to see detailed exception report on my
development machine.
But RemoteOnly behavior I noted before will be exactly what I wanted.

On Fri, Aug 27, 2010 at 12:31, Jim O'Callaghan wrote:

> Dmitry,
>
> From an example in an earlier post on this list,  I use the approach of
> having:
>
> configuration.add(SymbolConstants.PRODUCTION_MODE, "true");
>
> in my AppModule, so that by default production mode is always set to true
> for deployments, and then for any run/debug configurations in the
> developer's IDE, just override that setting with the VM argument:
>
> -Dtapestry.production-mode=false
>
> This means you will never need to set it for a release as the default is
> "true".  Hope this helps.
>
> Regards,
> Jim.
>
> -Original Message-
> From: Dmitry Gusev [mailto:dmitry.gu...@gmail.com]
> Sent: 27 August 2010 08:54
> To: Tapestry users
> Subject: Blog post about T5 exception handling on GAE
>
> FYI
>
>
> http://dmitrygusev.blogspot.com/2010/08/gae-and-tapestry5-exception-handling
> .html
>
> One thing I'd like T5 have though is something like in RemoteOnly mode in
> ASP.NET.
>
> http://msdn.microsoft.com/en-us/library/h0hfz6fc.aspx
>
> RemoteOnly Specifies that custom errors are shown only to the remote
> > clients, and that ASP.NET errors are shown to the local host. This is
> the
> > default value.
>
>
> So that even if I debug application in production mode I could get detailed
> exception report and not production one.
> Now I have to use development mode to debug (or consult with logs), but
> then
> I often forgetting to switch back to production mode prior to deploy.
> Can anybody share his practice of switching production mode on/off during
> development cycle?
>
> --
> Dmitry Gusev
>
> AnjLab Team
> http://anjlab.com
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


-- 
Dmitry Gusev

AnjLab Team
http://anjlab.com


RE: Blog post about T5 exception handling on GAE

2010-08-27 Thread Jim O'Callaghan
Dmitry,

>From an example in an earlier post on this list,  I use the approach of
having:

configuration.add(SymbolConstants.PRODUCTION_MODE, "true");

in my AppModule, so that by default production mode is always set to true
for deployments, and then for any run/debug configurations in the
developer's IDE, just override that setting with the VM argument:

-Dtapestry.production-mode=false

This means you will never need to set it for a release as the default is
"true".  Hope this helps.

Regards,
Jim.

-Original Message-
From: Dmitry Gusev [mailto:dmitry.gu...@gmail.com] 
Sent: 27 August 2010 08:54
To: Tapestry users
Subject: Blog post about T5 exception handling on GAE

FYI

http://dmitrygusev.blogspot.com/2010/08/gae-and-tapestry5-exception-handling
.html

One thing I'd like T5 have though is something like in RemoteOnly mode in
ASP.NET.

http://msdn.microsoft.com/en-us/library/h0hfz6fc.aspx

RemoteOnly Specifies that custom errors are shown only to the remote
> clients, and that ASP.NET errors are shown to the local host. This is the
> default value.


So that even if I debug application in production mode I could get detailed
exception report and not production one.
Now I have to use development mode to debug (or consult with logs), but then
I often forgetting to switch back to production mode prior to deploy.
Can anybody share his practice of switching production mode on/off during
development cycle?

-- 
Dmitry Gusev

AnjLab Team
http://anjlab.com


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Blog post about T5 exception handling on GAE

2010-08-27 Thread Dmitry Gusev
FYI

http://dmitrygusev.blogspot.com/2010/08/gae-and-tapestry5-exception-handling.html

One thing I'd like T5 have though is something like in RemoteOnly mode in
ASP.NET.

http://msdn.microsoft.com/en-us/library/h0hfz6fc.aspx

RemoteOnly Specifies that custom errors are shown only to the remote
> clients, and that ASP.NET errors are shown to the local host. This is the
> default value.


So that even if I debug application in production mode I could get detailed
exception report and not production one.
Now I have to use development mode to debug (or consult with logs), but then
I often forgetting to switch back to production mode prior to deploy.
Can anybody share his practice of switching production mode on/off during
development cycle?

-- 
Dmitry Gusev

AnjLab Team
http://anjlab.com


Re: Exception handling

2010-03-08 Thread Peter Stavrinides
This is not what I am asking Thiago, I already have my own error page.

Thanks,
Peter

-- 
If you are not an intended recipient of this e-mail, please notify the sender, 
delete it and do not read, act upon, print, disclose, copy, retain or 
redistribute it. Please visit http://www.albourne.com/email.html for important 
additional terms relating to this e-mail.

- Original Message -
From: "Thiago H. de Paula Figueiredo" 
To: "Tapestry users" 
Sent: Monday, 8 March, 2010 15:21:45 GMT +02:00 Athens, Beirut, Bucharest, 
Istanbul
Subject: Re: Exception handling

On Mon, 08 Mar 2010 05:40:50 -0300, Peter Stavrinides  
 wrote:

> Hi everyone,

Hi!

> So my question is what approach can I take to intercept *only these  
> exceptions that don't make it to the page.

Create your own error page. It must implement the ExceptionReporter  
interface. Set the tapestry.exception-report-page configuration symbol to  
the logical name of your error page.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da  
Informação Ltda.
http://www.arsmachina.com.br

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Exception handling

2010-03-08 Thread Thiago H. de Paula Figueiredo
On Mon, 08 Mar 2010 05:40:50 -0300, Peter Stavrinides  
 wrote:



Hi everyone,


Hi!

So my question is what approach can I take to intercept *only these  
exceptions that don't make it to the page.


Create your own error page. It must implement the ExceptionReporter  
interface. Set the tapestry.exception-report-page configuration symbol to  
the logical name of your error page.


--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da  
Informação Ltda.

http://www.arsmachina.com.br

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Exception handling

2010-03-08 Thread Peter Stavrinides
Hi everyone,

I am having a problem with the following scenario:

- A page renders a grid with a number of links
- Clicking one of those links causes the page to re-render, but it breaks with 
the following exception:

 ERROR com.test.CoreModule.SiteRequestExceptionHandler Render queue error in 
BeforeRenderTemplate[hf/Fund:select]: Failure reading parameter 'encoder' of 
component hf/Fund:select: It is not permitted to add duplicate elements to a 
BeanListModel 
org.apache.tapestry5.internal.services.RenderQueueException: Render queue error 
in BeforeRenderTemplate[hf/Fund:select]: Failure reading parameter 'encoder' of 
component hf/Fund:select: It is not permitted to add duplicate elements to a 
BeanListModel [at classpath:com/test/pages/hf/Fund.tml, line 186]
at 
org.apache.tapestry5.internal.services.RenderQueueImpl.run(RenderQueueImpl.java:86)
at 
org.apache.tapestry5.internal.services.PageRenderQueueImpl.render(PageRenderQueueImpl.java:121)
at 
$PageRenderQueue_1273cc4eea2.render($PageRenderQueue_1273cc4eea2.java)
at 
$PageRenderQueue_1273cc4ee99.render($PageRenderQueue_1273cc4ee99.java)
at 
org.apache.tapestry5.internal.services.MarkupRendererTerminator.renderMarkup(MarkupRendererTerminator.java:37)
at 
org.apache.tapestry5.services.TapestryModule$27.renderMarkup(TapestryModule.java:1748)
 
...

- What caused this error was my bean, which threw it when a problem occurred 
sorting the primary keys, this is all fine so far.
- The trouble is it breaks before re-rendering the page in 
BeforeRenderTemplate, which means the page never gets a chance to recover / 
report the exception (i.e.: onException is never invoked)

So my question is what approach can I take to intercept *only these exceptions 
that don't make it to the page. I rely heavily on onException at the moment, so 
I don't want to stop using it if possible, the ideal would be to have a new way 
of intercepting and dealing with these cases, perhaps two distinct mechanisms:
1. For exceptions that don't reach the page / component - taken care of by some 
new system (sub-system A)
2. Exceptions that do reach the page - remains as is, handled by onException() 
handler (sub-system B)

Is this possible, any ideas? 

Thanks,
Peter



-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Exception handling after violation of unique constraint

2009-09-13 Thread Geoff Callender
Agreed. Any number of exceptions can occur when you commit, regardless  
of what queries you've run in the same transaction.  That's the nature  
of multi-user systems, unless of course you want to set the  
transaction isolation level to serialize (not usually recommended).


As for using onValidate() versus onSuccess(), I'd avoid doing anything  
but page navigation in onSuccess() because ionSuccess() can't report  
exceptions properly (https://issues.apache.org/jira/browse/ 
TAPESTRY-1972).



On 13/09/2009, at 4:13 PM, Hilco Wijbenga wrote:


2009/9/12 Thiago H. de Paula Figueiredo :
Em Sat, 12 Sep 2009 17:38:43 -0300, Bruno Santos  


escreveu:


Well, even if i do:

league = new League();
league.setName("repeated name");


Unique constraints like this should be checked by you *before*  
sending an

insert or update to the database.


Would that not simply create a race condition? Thread A checks XYZ,
thread B (checks and) writes XYZ, thread A tries to write XYZ and
BOOM.

Shouldn't database constraint checking be a job for the database, not
for the application? The right tool for the job and all that. :-)

(That doesn't mean you can't check prior to inserting/updating but you
should never *rely* on it.)

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org





Re: Exception handling after violation of unique constraint

2009-09-12 Thread Hilco Wijbenga
2009/9/12 Thiago H. de Paula Figueiredo :
> Em Sat, 12 Sep 2009 17:38:43 -0300, Bruno Santos 
> escreveu:
>
>> Well, even if i do:
>>
>> league = new League();
>> league.setName("repeated name");
>
> Unique constraints like this should be checked by you *before* sending an
> insert or update to the database.

Would that not simply create a race condition? Thread A checks XYZ,
thread B (checks and) writes XYZ, thread A tries to write XYZ and
BOOM.

Shouldn't database constraint checking be a job for the database, not
for the application? The right tool for the job and all that. :-)

(That doesn't mean you can't check prior to inserting/updating but you
should never *rely* on it.)

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Exception handling after violation of unique constraint

2009-09-12 Thread Thiago H. de Paula Figueiredo
Em Sat, 12 Sep 2009 17:38:43 -0300, Bruno Santos   
escreveu:



Well, even if i do:

league = new League();
league.setName("repeated name");


Unique constraints like this should be checked by you *before* sending an  
insert or update to the database.


--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Exception handling after violation of unique constraint

2009-09-12 Thread Bruno Santos
Well, even if i do:

league = new League();
league.setName("repeated name");

I still have same problem, even without that piece of code.

Everything works fine with Create/Update of entity if saveorupdate
doesn't violate any constraint.


On Sat, Sep 12, 2009 at 7:34 PM, Kalle Korhonen
 wrote:
> Yes, but the problem originates from this:
>               if (entity.getId().longValue() == 0l) {
>                       league.setId(null);
>               }
> You can't make that league object a new entity just by nullifying it's
> id. Try creating a new league if you need to. Later on, since the
> saveOrUpdate failed, the null id causes the problem in
> DefaultHibernateDAO because that object is already Hibernate's
> session.
>
> Kalle
>
> On Sat, Sep 12, 2009 at 8:47 AM, Bruno Santos  wrote:
>> The question is i'm not trying to flush anything, i do (through DAO)
>> session.saveOrUpdate, catch the exception and the only thing i do
>> besides registering the error on the form is returning this (the page
>> i'm at) wich causes (i guess) tapestry to query database to fill data
>> for selectmodels. And, at this point i think tapestry uses the same
>> session it used for the saveorupdate and "list" trys to flush if
>> there's "dirty data".
>>
>> On Sat, Sep 12, 2009 at 3:02 AM, Kalle Korhonen
>>  wrote:
>>> I'm using the plain hibernate Session (shadow) and the pattern works
>>> great for me. But I think your problem is actually in "(don't flush
>>> the
>>> Session after an exception occurs)". You are doing something odd since
>>> you need to nullify the id. For a new object, the id should normally
>>> be null. Tapestry is already thinking it's a previously persisted
>>> entity.
>>>
>>> Kalle
>>>
>>>
>>> On Fri, Sep 11, 2009 at 2:30 PM, Bruno Santos  wrote:
 Hello,

 Well, the reason should be that with persist in validate() i validate
 that the entity that's inserted doesn't conflict with any database
 constraint like in this case and the onsucess isn't fired wich in the
 case a constraint is violated it doesn't seem to make sense.

 Anyway, even if i use the code on the onSucess method it comes down to
 the same issue, the exception is thrown whenever i try to do any
 operation that requires hibernate (problem should be in
 hibernatesessionmanager, not being "clean").

 One way i guess it could solve the problem is discarding the current
 hibernatesessionmanager, invalidate it somehow, but i don't know if
 that's possible.

 Thanks

 On Fri, Sep 11, 2009 at 10:15 PM, Sven Homburg  
 wrote:
> what is your reason, that you want to persist the enity
> in the validation event?
>
> i think its more clear to persist it in the onSuccess event method
>
> with regards
> Sven Homburg
> Founder of the Chenille Kit Project
> http://www.chenillekit.org
>
>
>
>
> 2009/9/11 Bruno Santos 
>
>> Thanks for your answer, i learned a bit more of tapestry.
>>
>> Now i have one more problem, not exactly related but in the same area.
>>
>> I have
>>
>>        void onValidateForm() {
>>                if (entity.getId().longValue() == 0l) {
>>                        league.setId(null);
>>                }
>>
>>                System.out.println("OnValidateForm");
>>                try {
>>                _entityDAO.persist(entity);
>>                } catch (RuntimeException ex) {
>>                        leagueForm.recordError("error"); // EXCEPTION IS
>> THROWN - THE TEST
>> I'M DOING HITS THE UNIQUE CONSTRAINT
>>                }
>>
>>        }
>>
>>        void onFailure() {
>>                _entityDAO.abort();
>>                System.out.println("onFailure");
>>        }
>>
>> And this is working except it doesn't refresh the form with the errors
>> i added on the onValidate
>>
>> When i use:
>>
>>        Object onFailure() {
>>                _entityDAO.abort();
>>                System.out.println("onFailure");
>>                return this;
>>        }
>>
>> The following exception is thrown:
>>
>> Caused by: org.apache.tapestry5.ioc.internal.util.TapestryException:
>> null id in pt.hi.asianconnect.entities.League entry (don't flush the
>> Session after an exception occurs) [at
>> classpath:pt/hi/asianconnect/components/generated/CreateUpdateLeague.tml,
>> line 12]
>>        at
>> org.apache.tapestry5.internal.bindings.PropBinding.get(PropBinding.java:62)
>>        at
>> org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl$1.read(InternalComponentResourcesImpl.java:510)
>>        ... 119 more
>> Caused by: org.hibernate.AssertionFailure: null id in
>> pt.hi.asianconnect.entities.League entry (don't flush the Session
>> after an exception occurs)
>>        at

Re: Exception handling after violation of unique constraint

2009-09-12 Thread Kalle Korhonen
Yes, but the problem originates from this:
   if (entity.getId().longValue() == 0l) {
   league.setId(null);
   }
You can't make that league object a new entity just by nullifying it's
id. Try creating a new league if you need to. Later on, since the
saveOrUpdate failed, the null id causes the problem in
DefaultHibernateDAO because that object is already Hibernate's
session.

Kalle

On Sat, Sep 12, 2009 at 8:47 AM, Bruno Santos  wrote:
> The question is i'm not trying to flush anything, i do (through DAO)
> session.saveOrUpdate, catch the exception and the only thing i do
> besides registering the error on the form is returning this (the page
> i'm at) wich causes (i guess) tapestry to query database to fill data
> for selectmodels. And, at this point i think tapestry uses the same
> session it used for the saveorupdate and "list" trys to flush if
> there's "dirty data".
>
> On Sat, Sep 12, 2009 at 3:02 AM, Kalle Korhonen
>  wrote:
>> I'm using the plain hibernate Session (shadow) and the pattern works
>> great for me. But I think your problem is actually in "(don't flush
>> the
>> Session after an exception occurs)". You are doing something odd since
>> you need to nullify the id. For a new object, the id should normally
>> be null. Tapestry is already thinking it's a previously persisted
>> entity.
>>
>> Kalle
>>
>>
>> On Fri, Sep 11, 2009 at 2:30 PM, Bruno Santos  wrote:
>>> Hello,
>>>
>>> Well, the reason should be that with persist in validate() i validate
>>> that the entity that's inserted doesn't conflict with any database
>>> constraint like in this case and the onsucess isn't fired wich in the
>>> case a constraint is violated it doesn't seem to make sense.
>>>
>>> Anyway, even if i use the code on the onSucess method it comes down to
>>> the same issue, the exception is thrown whenever i try to do any
>>> operation that requires hibernate (problem should be in
>>> hibernatesessionmanager, not being "clean").
>>>
>>> One way i guess it could solve the problem is discarding the current
>>> hibernatesessionmanager, invalidate it somehow, but i don't know if
>>> that's possible.
>>>
>>> Thanks
>>>
>>> On Fri, Sep 11, 2009 at 10:15 PM, Sven Homburg  
>>> wrote:
 what is your reason, that you want to persist the enity
 in the validation event?

 i think its more clear to persist it in the onSuccess event method

 with regards
 Sven Homburg
 Founder of the Chenille Kit Project
 http://www.chenillekit.org




 2009/9/11 Bruno Santos 

> Thanks for your answer, i learned a bit more of tapestry.
>
> Now i have one more problem, not exactly related but in the same area.
>
> I have
>
>        void onValidateForm() {
>                if (entity.getId().longValue() == 0l) {
>                        league.setId(null);
>                }
>
>                System.out.println("OnValidateForm");
>                try {
>                _entityDAO.persist(entity);
>                } catch (RuntimeException ex) {
>                        leagueForm.recordError("error"); // EXCEPTION IS
> THROWN - THE TEST
> I'M DOING HITS THE UNIQUE CONSTRAINT
>                }
>
>        }
>
>        void onFailure() {
>                _entityDAO.abort();
>                System.out.println("onFailure");
>        }
>
> And this is working except it doesn't refresh the form with the errors
> i added on the onValidate
>
> When i use:
>
>        Object onFailure() {
>                _entityDAO.abort();
>                System.out.println("onFailure");
>                return this;
>        }
>
> The following exception is thrown:
>
> Caused by: org.apache.tapestry5.ioc.internal.util.TapestryException:
> null id in pt.hi.asianconnect.entities.League entry (don't flush the
> Session after an exception occurs) [at
> classpath:pt/hi/asianconnect/components/generated/CreateUpdateLeague.tml,
> line 12]
>        at
> org.apache.tapestry5.internal.bindings.PropBinding.get(PropBinding.java:62)
>        at
> org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl$1.read(InternalComponentResourcesImpl.java:510)
>        ... 119 more
> Caused by: org.hibernate.AssertionFailure: null id in
> pt.hi.asianconnect.entities.League entry (don't flush the Session
> after an exception occurs)
>        at
> org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:78)
>        at
> org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(DefaultFlushEntityEventListener.java:187)
>        at
> org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:143)
>        at
> org.hibernate.event.def.Abstrac

Re: Exception handling after violation of unique constraint

2009-09-12 Thread Bruno Santos
The question is i'm not trying to flush anything, i do (through DAO)
session.saveOrUpdate, catch the exception and the only thing i do
besides registering the error on the form is returning this (the page
i'm at) wich causes (i guess) tapestry to query database to fill data
for selectmodels. And, at this point i think tapestry uses the same
session it used for the saveorupdate and "list" trys to flush if
there's "dirty data".

On Sat, Sep 12, 2009 at 3:02 AM, Kalle Korhonen
 wrote:
> I'm using the plain hibernate Session (shadow) and the pattern works
> great for me. But I think your problem is actually in "(don't flush
> the
> Session after an exception occurs)". You are doing something odd since
> you need to nullify the id. For a new object, the id should normally
> be null. Tapestry is already thinking it's a previously persisted
> entity.
>
> Kalle
>
>
> On Fri, Sep 11, 2009 at 2:30 PM, Bruno Santos  wrote:
>> Hello,
>>
>> Well, the reason should be that with persist in validate() i validate
>> that the entity that's inserted doesn't conflict with any database
>> constraint like in this case and the onsucess isn't fired wich in the
>> case a constraint is violated it doesn't seem to make sense.
>>
>> Anyway, even if i use the code on the onSucess method it comes down to
>> the same issue, the exception is thrown whenever i try to do any
>> operation that requires hibernate (problem should be in
>> hibernatesessionmanager, not being "clean").
>>
>> One way i guess it could solve the problem is discarding the current
>> hibernatesessionmanager, invalidate it somehow, but i don't know if
>> that's possible.
>>
>> Thanks
>>
>> On Fri, Sep 11, 2009 at 10:15 PM, Sven Homburg  
>> wrote:
>>> what is your reason, that you want to persist the enity
>>> in the validation event?
>>>
>>> i think its more clear to persist it in the onSuccess event method
>>>
>>> with regards
>>> Sven Homburg
>>> Founder of the Chenille Kit Project
>>> http://www.chenillekit.org
>>>
>>>
>>>
>>>
>>> 2009/9/11 Bruno Santos 
>>>
 Thanks for your answer, i learned a bit more of tapestry.

 Now i have one more problem, not exactly related but in the same area.

 I have

        void onValidateForm() {
                if (entity.getId().longValue() == 0l) {
                        league.setId(null);
                }

                System.out.println("OnValidateForm");
                try {
                _entityDAO.persist(entity);
                } catch (RuntimeException ex) {
                        leagueForm.recordError("error"); // EXCEPTION IS
 THROWN - THE TEST
 I'M DOING HITS THE UNIQUE CONSTRAINT
                }

        }

        void onFailure() {
                _entityDAO.abort();
                System.out.println("onFailure");
        }

 And this is working except it doesn't refresh the form with the errors
 i added on the onValidate

 When i use:

        Object onFailure() {
                _entityDAO.abort();
                System.out.println("onFailure");
                return this;
        }

 The following exception is thrown:

 Caused by: org.apache.tapestry5.ioc.internal.util.TapestryException:
 null id in pt.hi.asianconnect.entities.League entry (don't flush the
 Session after an exception occurs) [at
 classpath:pt/hi/asianconnect/components/generated/CreateUpdateLeague.tml,
 line 12]
        at
 org.apache.tapestry5.internal.bindings.PropBinding.get(PropBinding.java:62)
        at
 org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl$1.read(InternalComponentResourcesImpl.java:510)
        ... 119 more
 Caused by: org.hibernate.AssertionFailure: null id in
 pt.hi.asianconnect.entities.League entry (don't flush the Session
 after an exception occurs)
        at
 org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:78)
        at
 org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(DefaultFlushEntityEventListener.java:187)
        at
 org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:143)
        at
 org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:219)
        at
 org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:99)
        at
 org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:58)
        at
 org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:996)
        at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1589)
        at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306)
        at DefaultHibe

Re: Exception handling after violation of unique constraint

2009-09-11 Thread Kalle Korhonen
On Fri, Sep 11, 2009 at 7:26 PM, Thiago H. de Paula Figueiredo
 wrote:
> Em Fri, 11 Sep 2009 23:11:59 -0300, Kalle Korhonen
>  escreveu:
> I think onValidate() is for validation, the data store should only be
> changed (or attepted to be changed) when validation succeeds and controller
> classes (business rules tier) should deal with transactions, not
> Tapestry-related code (nor any UI code). I write code following the
> three-tiers architecture and the separation of concerns philosphy strictly.

Ok I see where you are coming from. I'm not a purist - I typically do
the least amount of work up front and try to avoid the extra layer of
indirection whenever possible. Tapestry offers a fairly clean
separation of logic and UI concerns straight-up and unless I need a
separate business layer (say if I had a completely different interface
to the same data), I don't add it in automatically. But I totally
understand your point of view - it's more in line of JEE/EJB
architecture and offers its own benefits.

Kalle

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Exception handling after violation of unique constraint

2009-09-11 Thread Thiago H. de Paula Figueiredo
Em Fri, 11 Sep 2009 23:11:59 -0300, Kalle Korhonen  
 escreveu:



Interesting - I happen to think it's a great pattern to follow. You
try to save and then roll back if it didn't work out - that's what the
transaction management is for and Tapestry gives you a very nice way
to accomplish this easily.


I think onValidate() is for validation, the data store should only be  
changed (or attepted to be changed) when validation succeeds and  
controller classes (business rules tier) should deal with transactions,  
not Tapestry-related code (nor any UI code). I write code following the  
three-tiers architecture and the separation of concerns philosphy strictly.



If you only save in onSuccess you have to
decide yourself whether you want to commit or abort,especially if
multiple objects are involved and can't easily communicate back to the
user what the error was (if he was trying to submit a form). How would
you do this?


My approach is to write code to check any consistence error before sending  
data to the store. This way, the only errors left are not recoverable (not  
related to business logic)and a generic error message is shown. I love  
checks buit int the database, but I don't use them to do validation, just  
to make sure no inconsistent data is written.


--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Exception handling after violation of unique constraint

2009-09-11 Thread Kalle Korhonen
On Fri, Sep 11, 2009 at 3:05 PM, Thiago H. de Paula Figueiredo
 wrote:
> Em Fri, 11 Sep 2009 18:30:34 -0300, Bruno Santos 
> IMHO, you have to write code to do that (query the database if needed)

Well that doesn't do anything else except merely lowers the probability.

> intead of sending data to the database and expect it to raise erros to you.
> IMHO, you should never write to your datastore in onValidate().

Interesting - I happen to think it's a great pattern to follow. You
try to save and then roll back if it didn't work out - that's what the
transaction management is for and Tapestry gives you a very nice way
to accomplish this easily. If you only save in onSuccess you have to
decide yourself whether you want to commit or abort, especially if
multiple objects are involved and can't easily communicate back to the
user what the error was (if he was trying to submit a form). How would
you do this?

Kalle

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Exception handling after violation of unique constraint

2009-09-11 Thread Kalle Korhonen
I'm using the plain hibernate Session (shadow) and the pattern works
great for me. But I think your problem is actually in "(don't flush
the
Session after an exception occurs)". You are doing something odd since
you need to nullify the id. For a new object, the id should normally
be null. Tapestry is already thinking it's a previously persisted
entity.

Kalle


On Fri, Sep 11, 2009 at 2:30 PM, Bruno Santos  wrote:
> Hello,
>
> Well, the reason should be that with persist in validate() i validate
> that the entity that's inserted doesn't conflict with any database
> constraint like in this case and the onsucess isn't fired wich in the
> case a constraint is violated it doesn't seem to make sense.
>
> Anyway, even if i use the code on the onSucess method it comes down to
> the same issue, the exception is thrown whenever i try to do any
> operation that requires hibernate (problem should be in
> hibernatesessionmanager, not being "clean").
>
> One way i guess it could solve the problem is discarding the current
> hibernatesessionmanager, invalidate it somehow, but i don't know if
> that's possible.
>
> Thanks
>
> On Fri, Sep 11, 2009 at 10:15 PM, Sven Homburg  
> wrote:
>> what is your reason, that you want to persist the enity
>> in the validation event?
>>
>> i think its more clear to persist it in the onSuccess event method
>>
>> with regards
>> Sven Homburg
>> Founder of the Chenille Kit Project
>> http://www.chenillekit.org
>>
>>
>>
>>
>> 2009/9/11 Bruno Santos 
>>
>>> Thanks for your answer, i learned a bit more of tapestry.
>>>
>>> Now i have one more problem, not exactly related but in the same area.
>>>
>>> I have
>>>
>>>        void onValidateForm() {
>>>                if (entity.getId().longValue() == 0l) {
>>>                        league.setId(null);
>>>                }
>>>
>>>                System.out.println("OnValidateForm");
>>>                try {
>>>                _entityDAO.persist(entity);
>>>                } catch (RuntimeException ex) {
>>>                        leagueForm.recordError("error"); // EXCEPTION IS
>>> THROWN - THE TEST
>>> I'M DOING HITS THE UNIQUE CONSTRAINT
>>>                }
>>>
>>>        }
>>>
>>>        void onFailure() {
>>>                _entityDAO.abort();
>>>                System.out.println("onFailure");
>>>        }
>>>
>>> And this is working except it doesn't refresh the form with the errors
>>> i added on the onValidate
>>>
>>> When i use:
>>>
>>>        Object onFailure() {
>>>                _entityDAO.abort();
>>>                System.out.println("onFailure");
>>>                return this;
>>>        }
>>>
>>> The following exception is thrown:
>>>
>>> Caused by: org.apache.tapestry5.ioc.internal.util.TapestryException:
>>> null id in pt.hi.asianconnect.entities.League entry (don't flush the
>>> Session after an exception occurs) [at
>>> classpath:pt/hi/asianconnect/components/generated/CreateUpdateLeague.tml,
>>> line 12]
>>>        at
>>> org.apache.tapestry5.internal.bindings.PropBinding.get(PropBinding.java:62)
>>>        at
>>> org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl$1.read(InternalComponentResourcesImpl.java:510)
>>>        ... 119 more
>>> Caused by: org.hibernate.AssertionFailure: null id in
>>> pt.hi.asianconnect.entities.League entry (don't flush the Session
>>> after an exception occurs)
>>>        at
>>> org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:78)
>>>        at
>>> org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(DefaultFlushEntityEventListener.java:187)
>>>        at
>>> org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:143)
>>>        at
>>> org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:219)
>>>        at
>>> org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:99)
>>>        at
>>> org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:58)
>>>        at
>>> org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:996)
>>>        at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1589)
>>>        at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306)
>>>        at DefaultHibernateDAO.findByCriteria(DefaultHibernateDAO.java:104)
>>>
>>>
>>> The abort method from DAO was an experiment of mine wich calls
>>> hibernatesessionmanager.abort(). From what i understand, what happens
>>> is when the page is to be renderered, the hibernatesessionmanager
>>> that's used has "dirty" data that's why it uses
>>> SessionImpl.autoFlushIfRequired when i'm fetching data to refill the
>>> page, hence my experiment on calling the abort from
>>> hibernatesessionmanger, still this doesn't do it and i don't know how
>>> to "clean" data from the sessionmanager.
>>>
>>> Ideas anyone?
>>>
>>> One import

Fwd: Exception handling after violation of unique constraint

2009-09-11 Thread Bruno Santos
Hit wrong button i guess, sent message only to Sven. Sorry


-- Forwarded message --
From: Bruno Santos
Date: Fri, Sep 11, 2009 at 11:19 PM
Subject: Re: Exception handling after violation of unique constraint


First i like to thank you (both) for your patience and help.

Well, not the solution i was looking for but i guess it solves some
issues, totally agree with it and certainly will use it.

However, It doesn't solved non checked exceptions hibernate might
throw, like constraints that are forgotten, or other DML issues. And,
production wise, what happens is user just staring to the page waiting
for it to do something, giving some feedback and nothing happens.
Isn't there a "catch all exception and present user some feedback
option"? Or an option like "don't use this hibernatesessionmanager
because it's invalid option"?

Regards

On Fri, Sep 11, 2009 at 10:58 PM, Sven Homburg  wrote:
> i think a good way for prevent doublettes
> in you database is by using an Example-Query:
> http://docs.jboss.org/hibernate/stable/core/reference/en/html/querycriteria.html#querycriteria-examples
>
>
> with regards
> Sven Homburg
> Founder of the Chenille Kit Project
> http://www.chenillekit.org
>
>
>
>
> 2009/9/11 Bruno Santos 
>>
>> Hello,
>>
>> Well, the reason should be that with persist in validate() i validate
>> that the entity that's inserted doesn't conflict with any database
>> constraint like in this case and the onsucess isn't fired wich in the
>> case a constraint is violated it doesn't seem to make sense.
>>
>> Anyway, even if i use the code on the onSucess method it comes down to
>> the same issue, the exception is thrown whenever i try to do any
>> operation that requires hibernate (problem should be in
>> hibernatesessionmanager, not being "clean").
>>
>> One way i guess it could solve the problem is discarding the current
>> hibernatesessionmanager, invalidate it somehow, but i don't know if
>> that's possible.
>>
>> Thanks
>>
>> On Fri, Sep 11, 2009 at 10:15 PM, Sven Homburg 
>> wrote:
>> > what is your reason, that you want to persist the enity
>> > in the validation event?
>> >
>> > i think its more clear to persist it in the onSuccess event method
>> >
>> > with regards
>> > Sven Homburg
>> > Founder of the Chenille Kit Project
>> > http://www.chenillekit.org
>> >
>> >
>> >
>> >
>> > 2009/9/11 Bruno Santos 
>> >
>> >> Thanks for your answer, i learned a bit more of tapestry.
>> >>
>> >> Now i have one more problem, not exactly related but in the same area.
>> >>
>> >> I have
>> >>
>> >>        void onValidateForm() {
>> >>                if (entity.getId().longValue() == 0l) {
>> >>                        league.setId(null);
>> >>                }
>> >>
>> >>                System.out.println("OnValidateForm");
>> >>                try {
>> >>                _entityDAO.persist(entity);
>> >>                } catch (RuntimeException ex) {
>> >>                        leagueForm.recordError("error"); // EXCEPTION IS
>> >> THROWN - THE TEST
>> >> I'M DOING HITS THE UNIQUE CONSTRAINT
>> >>                }
>> >>
>> >>        }
>> >>
>> >>        void onFailure() {
>> >>                _entityDAO.abort();
>> >>                System.out.println("onFailure");
>> >>        }
>> >>
>> >> And this is working except it doesn't refresh the form with the errors
>> >> i added on the onValidate
>> >>
>> >> When i use:
>> >>
>> >>        Object onFailure() {
>> >>                _entityDAO.abort();
>> >>                System.out.println("onFailure");
>> >>                return this;
>> >>        }
>> >>
>> >> The following exception is thrown:
>> >>
>> >> Caused by: org.apache.tapestry5.ioc.internal.util.TapestryException:
>> >> null id in pt.hi.asianconnect.entities.League entry (don't flush the
>> >> Session after an exception occurs) [at
>> >>
>> >> classpath:pt/hi/asianconnect/components/generated/CreateUpdateLeague.tml,
>> >> line 12]
>> >

Re: Exception handling after violation of unique constraint

2009-09-11 Thread Thiago H. de Paula Figueiredo
Em Fri, 11 Sep 2009 18:30:34 -0300, Bruno Santos   
escreveu:



Hello,


Hi!


Well, the reason should be that with persist in validate() i validate
that the entity that's inserted doesn't conflict with any database
constraint like in this case and the onsucess isn't fired wich in the
case a constraint is violated it doesn't seem to make sense.


IMHO, you have to write code to do that (query the database if needed)  
intead of sending data to the database and expect it to raise erros to you.

IMHO, you should never write to your datastore in onValidate().

--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Exception handling after violation of unique constraint

2009-09-11 Thread Bruno Santos
Hello,

Well, the reason should be that with persist in validate() i validate
that the entity that's inserted doesn't conflict with any database
constraint like in this case and the onsucess isn't fired wich in the
case a constraint is violated it doesn't seem to make sense.

Anyway, even if i use the code on the onSucess method it comes down to
the same issue, the exception is thrown whenever i try to do any
operation that requires hibernate (problem should be in
hibernatesessionmanager, not being "clean").

One way i guess it could solve the problem is discarding the current
hibernatesessionmanager, invalidate it somehow, but i don't know if
that's possible.

Thanks

On Fri, Sep 11, 2009 at 10:15 PM, Sven Homburg  wrote:
> what is your reason, that you want to persist the enity
> in the validation event?
>
> i think its more clear to persist it in the onSuccess event method
>
> with regards
> Sven Homburg
> Founder of the Chenille Kit Project
> http://www.chenillekit.org
>
>
>
>
> 2009/9/11 Bruno Santos 
>
>> Thanks for your answer, i learned a bit more of tapestry.
>>
>> Now i have one more problem, not exactly related but in the same area.
>>
>> I have
>>
>>        void onValidateForm() {
>>                if (entity.getId().longValue() == 0l) {
>>                        league.setId(null);
>>                }
>>
>>                System.out.println("OnValidateForm");
>>                try {
>>                _entityDAO.persist(entity);
>>                } catch (RuntimeException ex) {
>>                        leagueForm.recordError("error"); // EXCEPTION IS
>> THROWN - THE TEST
>> I'M DOING HITS THE UNIQUE CONSTRAINT
>>                }
>>
>>        }
>>
>>        void onFailure() {
>>                _entityDAO.abort();
>>                System.out.println("onFailure");
>>        }
>>
>> And this is working except it doesn't refresh the form with the errors
>> i added on the onValidate
>>
>> When i use:
>>
>>        Object onFailure() {
>>                _entityDAO.abort();
>>                System.out.println("onFailure");
>>                return this;
>>        }
>>
>> The following exception is thrown:
>>
>> Caused by: org.apache.tapestry5.ioc.internal.util.TapestryException:
>> null id in pt.hi.asianconnect.entities.League entry (don't flush the
>> Session after an exception occurs) [at
>> classpath:pt/hi/asianconnect/components/generated/CreateUpdateLeague.tml,
>> line 12]
>>        at
>> org.apache.tapestry5.internal.bindings.PropBinding.get(PropBinding.java:62)
>>        at
>> org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl$1.read(InternalComponentResourcesImpl.java:510)
>>        ... 119 more
>> Caused by: org.hibernate.AssertionFailure: null id in
>> pt.hi.asianconnect.entities.League entry (don't flush the Session
>> after an exception occurs)
>>        at
>> org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:78)
>>        at
>> org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(DefaultFlushEntityEventListener.java:187)
>>        at
>> org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:143)
>>        at
>> org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:219)
>>        at
>> org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:99)
>>        at
>> org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:58)
>>        at
>> org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:996)
>>        at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1589)
>>        at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306)
>>        at DefaultHibernateDAO.findByCriteria(DefaultHibernateDAO.java:104)
>>
>>
>> The abort method from DAO was an experiment of mine wich calls
>> hibernatesessionmanager.abort(). From what i understand, what happens
>> is when the page is to be renderered, the hibernatesessionmanager
>> that's used has "dirty" data that's why it uses
>> SessionImpl.autoFlushIfRequired when i'm fetching data to refill the
>> page, hence my experiment on calling the abort from
>> hibernatesessionmanger, still this doesn't do it and i don't know how
>> to "clean" data from the sessionmanager.
>>
>> Ideas anyone?
>>
>> One importante note, the test i'm doing implies that the my method
>> that saveOrUpdate the entity is "hitting" a unique constraint
>>
>> On Thu, Sep 10, 2009 at 11:20 PM, Kalle Korhonen
>>  wrote:
>> > You should instead try storing it onValidate. If it fails, you should
>> > record an error and if it succeeds you should commit only in onSuccess
>> > (but the method body can be otherwise empty).
>> >
>> > Kalle
>> >
>> >
>> > On Thu, Sep 10, 2009 at 2:55 PM, Bruno Santos 
>> wrote:
>> >> Good evening,
>> >>
>> >> I have a form using a zone and i have @Comm

Re: Exception handling after violation of unique constraint

2009-09-11 Thread Sven Homburg
what is your reason, that you want to persist the enity
in the validation event?

i think its more clear to persist it in the onSuccess event method

with regards
Sven Homburg
Founder of the Chenille Kit Project
http://www.chenillekit.org




2009/9/11 Bruno Santos 

> Thanks for your answer, i learned a bit more of tapestry.
>
> Now i have one more problem, not exactly related but in the same area.
>
> I have
>
>void onValidateForm() {
>if (entity.getId().longValue() == 0l) {
>league.setId(null);
>}
>
>System.out.println("OnValidateForm");
>try {
>_entityDAO.persist(entity);
>} catch (RuntimeException ex) {
>leagueForm.recordError("error"); // EXCEPTION IS
> THROWN - THE TEST
> I'M DOING HITS THE UNIQUE CONSTRAINT
>}
>
>}
>
>void onFailure() {
>_entityDAO.abort();
>System.out.println("onFailure");
>}
>
> And this is working except it doesn't refresh the form with the errors
> i added on the onValidate
>
> When i use:
>
>Object onFailure() {
>_entityDAO.abort();
>System.out.println("onFailure");
>return this;
>}
>
> The following exception is thrown:
>
> Caused by: org.apache.tapestry5.ioc.internal.util.TapestryException:
> null id in pt.hi.asianconnect.entities.League entry (don't flush the
> Session after an exception occurs) [at
> classpath:pt/hi/asianconnect/components/generated/CreateUpdateLeague.tml,
> line 12]
>at
> org.apache.tapestry5.internal.bindings.PropBinding.get(PropBinding.java:62)
>at
> org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl$1.read(InternalComponentResourcesImpl.java:510)
>... 119 more
> Caused by: org.hibernate.AssertionFailure: null id in
> pt.hi.asianconnect.entities.League entry (don't flush the Session
> after an exception occurs)
>at
> org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:78)
>at
> org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(DefaultFlushEntityEventListener.java:187)
>at
> org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:143)
>at
> org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:219)
>at
> org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:99)
>at
> org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:58)
>at
> org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:996)
>at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1589)
>at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306)
>at DefaultHibernateDAO.findByCriteria(DefaultHibernateDAO.java:104)
>
>
> The abort method from DAO was an experiment of mine wich calls
> hibernatesessionmanager.abort(). From what i understand, what happens
> is when the page is to be renderered, the hibernatesessionmanager
> that's used has "dirty" data that's why it uses
> SessionImpl.autoFlushIfRequired when i'm fetching data to refill the
> page, hence my experiment on calling the abort from
> hibernatesessionmanger, still this doesn't do it and i don't know how
> to "clean" data from the sessionmanager.
>
> Ideas anyone?
>
> One importante note, the test i'm doing implies that the my method
> that saveOrUpdate the entity is "hitting" a unique constraint
>
> On Thu, Sep 10, 2009 at 11:20 PM, Kalle Korhonen
>  wrote:
> > You should instead try storing it onValidate. If it fails, you should
> > record an error and if it succeeds you should commit only in onSuccess
> > (but the method body can be otherwise empty).
> >
> > Kalle
> >
> >
> > On Thu, Sep 10, 2009 at 2:55 PM, Bruno Santos 
> wrote:
> >> Good evening,
> >>
> >> I have a form using a zone and i have @CommitAfter on the
> >> onSubmitFromEntityForm()
> >>
> >> 
> >>  >>t:value="entity.name" />
> >> 
> >>
> >> @CommitAfter
> >> Object onSubmitFromEntityForm() {
> >>  
> >> try {
> >> entityDao.persist(entity);
> >> } catch (exception ex) {
> >>  // handle exception
> >> }
> >> }
> >>
> >> altough i'm handling the exception the @CommitAfter creates a new
> >> exception since it tries to commit something that's not in transaction
> >> due to catched exception.
> >>
> >> How to deal with this? Is there a way to avoid the @CommitAfter to
> >> execute ... a handler i can use? I think i can remove the @CommitAfter
> >> but don't believe this should be first option.
> >>
> >> -
> >> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org

Exception handling after violation of unique constraint

2009-09-11 Thread Bruno Santos
Thanks for your answer, i learned a bit more of tapestry.

Now i have one more problem, not exactly related but in the same area.

I have

void onValidateForm() {
if (entity.getId().longValue() == 0l) {
league.setId(null);
}

System.out.println("OnValidateForm");
try {
_entityDAO.persist(entity);
} catch (RuntimeException ex) {
leagueForm.recordError("error"); // EXCEPTION IS THROWN 
- THE TEST
I'M DOING HITS THE UNIQUE CONSTRAINT
}

}

void onFailure() {
_entityDAO.abort();
System.out.println("onFailure");
}

And this is working except it doesn't refresh the form with the errors
i added on the onValidate

When i use:

Object onFailure() {
_entityDAO.abort();
System.out.println("onFailure");
return this;
}

The following exception is thrown:

Caused by: org.apache.tapestry5.ioc.internal.util.TapestryException:
null id in pt.hi.asianconnect.entities.League entry (don't flush the
Session after an exception occurs) [at
classpath:pt/hi/asianconnect/components/generated/CreateUpdateLeague.tml,
line 12]
at 
org.apache.tapestry5.internal.bindings.PropBinding.get(PropBinding.java:62)
at 
org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl$1.read(InternalComponentResourcesImpl.java:510)
... 119 more
Caused by: org.hibernate.AssertionFailure: null id in
pt.hi.asianconnect.entities.League entry (don't flush the Session
after an exception occurs)
at 
org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:78)
at 
org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(DefaultFlushEntityEventListener.java:187)
at 
org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:143)
at 
org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:219)
at 
org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:99)
at 
org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:58)
at 
org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:996)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1589)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306)
at DefaultHibernateDAO.findByCriteria(DefaultHibernateDAO.java:104)


The abort method from DAO was an experiment of mine wich calls
hibernatesessionmanager.abort(). From what i understand, what happens
is when the page is to be renderered, the hibernatesessionmanager
that's used has "dirty" data that's why it uses
SessionImpl.autoFlushIfRequired when i'm fetching data to refill the
page, hence my experiment on calling the abort from
hibernatesessionmanger, still this doesn't do it and i don't know how
to "clean" data from the sessionmanager.

Ideas anyone?

One importante note, the test i'm doing implies that the my method
that saveOrUpdate the entity is "hitting" a unique constraint

On Thu, Sep 10, 2009 at 11:20 PM, Kalle Korhonen
 wrote:
> You should instead try storing it onValidate. If it fails, you should
> record an error and if it succeeds you should commit only in onSuccess
> (but the method body can be otherwise empty).
>
> Kalle
>
>
> On Thu, Sep 10, 2009 at 2:55 PM, Bruno Santos  wrote:
>> Good evening,
>>
>> I have a form using a zone and i have @CommitAfter on the
>> onSubmitFromEntityForm()
>>
>> 
>> >                                        t:value="entity.name" />
>> 
>>
>> @CommitAfter
>> Object onSubmitFromEntityForm() {
>>  
>> try {
>> entityDao.persist(entity);
>> } catch (exception ex) {
>>  // handle exception
>> }
>> }
>>
>> altough i'm handling the exception the @CommitAfter creates a new
>> exception since it tries to commit something that's not in transaction
>> due to catched exception.
>>
>> How to deal with this? Is there a way to avoid the @CommitAfter to
>> execute ... a handler i can use? I think i can remove the @CommitAfter
>> but don't believe this should be first option.
>>
>> -
>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>
>>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapes

Re: Exception handling + @CommitAfter

2009-09-10 Thread Kalle Korhonen
You should instead try storing it onValidate. If it fails, you should
record an error and if it succeeds you should commit only in onSuccess
(but the method body can be otherwise empty).

Kalle


On Thu, Sep 10, 2009 at 2:55 PM, Bruno Santos  wrote:
> Good evening,
>
> I have a form using a zone and i have @CommitAfter on the
> onSubmitFromEntityForm()
>
> 
>                                         t:value="entity.name" />
> 
>
> @CommitAfter
> Object onSubmitFromEntityForm() {
>  
> try {
> entityDao.persist(entity);
> } catch (exception ex) {
>  // handle exception
> }
> }
>
> altough i'm handling the exception the @CommitAfter creates a new
> exception since it tries to commit something that's not in transaction
> due to catched exception.
>
> How to deal with this? Is there a way to avoid the @CommitAfter to
> execute ... a handler i can use? I think i can remove the @CommitAfter
> but don't believe this should be first option.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Exception handling + @CommitAfter

2009-09-10 Thread Bruno Santos
Good evening,

I have a form using a zone and i have @CommitAfter on the
onSubmitFromEntityForm()





@CommitAfter
Object onSubmitFromEntityForm() {
 
try {
entityDao.persist(entity);
} catch (exception ex) {
 // handle exception
}
}

altough i'm handling the exception the @CommitAfter creates a new
exception since it tries to commit something that's not in transaction
due to catched exception.

How to deal with this? Is there a way to avoid the @CommitAfter to
execute ... a handler i can use? I think i can remove the @CommitAfter
but don't believe this should be first option.

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: T5: Exception Handling

2008-05-20 Thread Leon Derks
e turned the 
RequestExceptionHandler service into a pipeline.


Can you show me some code of how to do this?
Leon


Peter Stavrinides wrote:

Hi Leon

I posted a number of questions to the list about this topic, but got 
only a few perls. One of them was this post, particularly Filip's 
answer:

http://www.mail-archive.com/users@tapestry.apache.org/msg21914.html

Also see this page, for how to override Tapestry's error page with 
your own friendly error page:

http://wiki.apache.org/tapestry/Tapestry5ExceptionPage

I am not sure what you are trying to do, but would suggest you 
familiarize yourself a bit more with Tapestry's error reporting 
mechanisms, which imho are incredibly powerful and easy to use.


Hope this helps,
Peter


- Original Message -
From: "Leon Derks" <[EMAIL PROTECTED]>
To: "Tapestry users" 
Sent: Friday, 16 May, 2008 1:35:19 PM GMT +02:00 Athens, Beirut, 
Bucharest, Istanbul

Subject: T5: Exception Handling

Hello

What is the best way to handle exceptions in Tapestry 5?

I want to show some kind of general error page, when an exception 
occurs.


At the moment I have a onException method in my BasePage class. But 
for some reason the Error page is not returned.

What is the way in T5 to handle exceptions?

Object onException(Throwable cause) {
return new Error();
}

Leon

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


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



  



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



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






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



Re: T5: Exception Handling

2008-05-19 Thread Andreas Andreou
Directly adding a tapestry url also works


   404
  /NotFound.html


That was in T4 that used the servlet (instead of filter) approach...
perhaps it also
works in T5.

On Mon, May 19, 2008 at 5:35 PM, Toby Hobson <[EMAIL PROTECTED]> wrote:
> Given that a JSP is basically a servlet, why not do something like
>
> <%
>response.include(request.getContextPath() + "/MyTapestryErrorPage);
> %>
>
> from your jsp exception page
>
> btw I can't remember - can you map an exception handler to a servlet in 
> web.xml?
>
> Toby
>
> - Original Message 
> From: Thiago HP <[EMAIL PROTECTED]>
> To: Tapestry users 
> Sent: Monday, 19 May, 2008 2:52:02 PM
> Subject: Re: T5: Exception Handling
>
> On 5/19/08, Peter Stavrinides <[EMAIL PROTECTED]> wrote:
>>  To configure:
>>  You would simply use a standard JSP / HTML error page, and wire it in your
>> web.xml. I am using Tomcat and it works great... works on Jetty too.
>
> Something I've done once is to setup a 404.html page that redirects to
> a Tapestry page via Javascript, including the original URL so I can
> log it. ;)
>
> --
> Thiago
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>
>



-- 
Andreas Andreou - [EMAIL PROTECTED] - http://blog.andyhot.gr
Tapestry / Tacos developer
Open Source / JEE Consulting

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



Re: T5: Exception Handling

2008-05-19 Thread Toby Hobson
Given that a JSP is basically a servlet, why not do something like

<%
response.include(request.getContextPath() + "/MyTapestryErrorPage);
%>

from your jsp exception page

btw I can't remember - can you map an exception handler to a servlet in web.xml?

Toby

- Original Message 
From: Thiago HP <[EMAIL PROTECTED]>
To: Tapestry users 
Sent: Monday, 19 May, 2008 2:52:02 PM
Subject: Re: T5: Exception Handling

On 5/19/08, Peter Stavrinides <[EMAIL PROTECTED]> wrote:
>  To configure:
>  You would simply use a standard JSP / HTML error page, and wire it in your
> web.xml. I am using Tomcat and it works great... works on Jetty too.

Something I've done once is to setup a 404.html page that redirects to
a Tapestry page via Javascript, including the original URL so I can
log it. ;)

-- 
Thiago

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






Re: T5: Exception Handling

2008-05-19 Thread Thiago HP
On 5/19/08, Filip S. Adamsen <[EMAIL PROTECTED]> wrote:
> Now why hadn't I thought of that... :D

Sometimes, a solution is so simple that we unconciously search for
more complicated ones . . . :)

>  Thanks!

You're welcome!

-- 
Thiago

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



Re: T5: Exception Handling

2008-05-19 Thread Filip S. Adamsen

Now why hadn't I thought of that... :D

Thanks!

-Filip

Thiago HP skrev:

On 5/19/08, Peter Stavrinides <[EMAIL PROTECTED]> wrote:

 To configure:
 You would simply use a standard JSP / HTML error page, and wire it in your
web.xml. I am using Tomcat and it works great... works on Jetty too.


Something I've done once is to setup a 404.html page that redirects to
a Tapestry page via Javascript, including the original URL so I can
log it. ;)



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



Re: T5: Exception Handling

2008-05-19 Thread Filip S. Adamsen
rride server error pages(404, 505 etc)?
And I don't understand what Flip means with :I've turned the 
RequestExceptionHandler service into a pipeline.


Can you show me some code of how to do this?
Leon


Peter Stavrinides wrote:

Hi Leon

I posted a number of questions to the list about this topic, but got 
only a few perls. One of them was this post, particularly Filip's 
answer:

http://www.mail-archive.com/users@tapestry.apache.org/msg21914.html

Also see this page, for how to override Tapestry's error page with 
your own friendly error page:

http://wiki.apache.org/tapestry/Tapestry5ExceptionPage

I am not sure what you are trying to do, but would suggest you 
familiarize yourself a bit more with Tapestry's error reporting 
mechanisms, which imho are incredibly powerful and easy to use.


Hope this helps,
Peter


- Original Message -
From: "Leon Derks" <[EMAIL PROTECTED]>
To: "Tapestry users" 
Sent: Friday, 16 May, 2008 1:35:19 PM GMT +02:00 Athens, Beirut, 
Bucharest, Istanbul

Subject: T5: Exception Handling

Hello

What is the best way to handle exceptions in Tapestry 5?

I want to show some kind of general error page, when an exception 
occurs.


At the moment I have a onException method in my BasePage class. But 
for some reason the Error page is not returned.

What is the way in T5 to handle exceptions?

Object onException(Throwable cause) {
return new Error();
}

Leon

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


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



  



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



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






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



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



Re: T5: Exception Handling

2008-05-19 Thread Thiago HP
On 5/19/08, Peter Stavrinides <[EMAIL PROTECTED]> wrote:
>  To configure:
>  You would simply use a standard JSP / HTML error page, and wire it in your
> web.xml. I am using Tomcat and it works great... works on Jetty too.

Something I've done once is to setup a 404.html page that redirects to
a Tapestry page via Javascript, including the original URL so I can
log it. ;)

-- 
Thiago

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



Re: T5: Exception Handling

2008-05-19 Thread Peter Stavrinides
Just a little side note:
Filip is right, you can't use a Tapestry page for these, but that is probably 
the correct behavior as this is a different type of error (an exception to the 
rule if you like) which the server needs to handle by explicitly interrupting a 
request/response and generating a new one on the server in accordance with the 
error condition... For example a page not found has little to do with your 
Tapestry application, but the server is still being addressed and needs to 
respond. So you wouldn't want a Tapestry to handle these IMHO, but that doesn't 
stop tapestry apps from making use of them when required! (using 
response.sendError) 

To configure:
You would simply use a standard JSP / HTML error page, and wire it in your 
web.xml. I am using Tomcat and it works great... works on Jetty too. The only 
error page/s I can't get to override perfectly are 401 and 503, but I have 
found some workarounds for these. 

503 is a service unavailable/ under maintenance error and will occur when the 
server is running but the application is not, so wouldn't make sense using it 
in your app anyhow. I found Tomcat is a little deficient here, see: 
http://www.nabble.com/Error-Page-Question-td16153138.html (if anyone has solved 
this please share).For the 401 authentication error, I simply use a 403 
forbidden instead, but I can get away with this as I am using forms 
authentication. 

I had thought about putting some of this stuff on the wiki...  as yet I haven't 
because error handling can be very scenario specific. Anyway here is a short 
example of how to configure your server error page:

Add to web.xml:

 
404
   /error404.jsp  



error404.jsp: (Important - create this file in /webapp) and NOT in 
/webapp/WEB-INF
<%@ page isErrorPage="true" %>

http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";>

Error 404 Page Not Found


Page Not Found

 We apologise for any inconvenience, but the resource you have
specified cannot be found, please check the URL is typed correctly. 

If you require assistance please contact client support. To continue return to the previous page.




As simple as that...
Cheers,
Peter.

- Original Message -
From: "Filip S. Adamsen" <[EMAIL PROTECTED]>
To: "Tapestry users" 
Sent: Sunday, 18 May, 2008 1:39:31 AM GMT +02:00 Athens, Beirut, Bucharest, 
Istanbul
Subject: Re: T5: Exception Handling

Hi Leon,

How to override server error pages depends on what server you're using. 
As far as I'm aware it's unfortunately not possible to use Tapestry 
pages as server error pages - if I'm wrong here, I'd really like to know 
how to do it. :)

What I mean by turning the RequestExceptionHandler into a pipeline is 
that I've overridden the original service with my own that uses a pipeline.

http://tapestry.apache.org/tapestry5/tapestry-ioc/pipeline.html

So I define my filter:

   public interface RequestExceptionFilter {

 void handleRequestException(Throwable exception, 
RequestExceptionHandler handler)
 throws IOException;
   }

Then I create a new RequestExceptionHandler as a pipeline:

   public static RequestExceptionHandler 
buildImprovedRequestExceptionHandler(
   List configuration,
   @InjectService("RequestExceptionHandler") RequestExceptionHandler 
requestExceptionHandler,
   PipelineBuilder builder,
   Logger logger
   ) {
 return builder.build(
 logger,
 RequestExceptionHandler.class,
 RequestExceptionFilter.class,
 configuration,
 requestExceptionHandler
 );
   }

I then contribute this to AliasOverrides to replace the default 
RequestExceptionHandler:

   public static void contributeAliasOverrides(
   Configuration configuration,
   @InjectService("ImprovedRequestExceptionHandler") 
RequestExceptionHandler requestExceptionHandler
   ) {
 
configuration.add(AliasContribution.create(RequestExceptionHandler.class, 
requestExceptionHandler));
   }

I can then contribute filters to the pipeline like this:

   public static void contributeImprovedRequestExceptionHandler(
   OrderedConfiguration configuration,
   RequestExceptionErrorFilter requestExceptionErrorFilter
   ) {
 configuration.add("Error", requestExceptionErrorFilter);
   }

Where RequestExceptionErrorFilter looks like this:

   public class RequestExceptionErrorFilter
   implements RequestExceptionFilter {

 private final RedirectService redirectService;
 private final SecurityService securityService;
 private final Logger logger;

 public RequestExceptionErrorFilter(RedirectService redirectService, 
SecurityService securityService, Logger logger) {
   this.redirectService = redirectService;
   this.securityService = securityService;
   this.logger = logger;
 }

 public void handleRequestExcep

Re: T5: Exception Handling

2008-05-19 Thread Leon Derks

Hi Filip,

Thanks for your answer. I understand now.
But one final question. How does your redirectService looks like?

Leon

Filip S. Adamsen wrote:

Hi Leon,

How to override server error pages depends on what server you're 
using. As far as I'm aware it's unfortunately not possible to use 
Tapestry pages as server error pages - if I'm wrong here, I'd really 
like to know how to do it. :)


What I mean by turning the RequestExceptionHandler into a pipeline is 
that I've overridden the original service with my own that uses a 
pipeline.


http://tapestry.apache.org/tapestry5/tapestry-ioc/pipeline.html

So I define my filter:

  public interface RequestExceptionFilter {

void handleRequestException(Throwable exception, 
RequestExceptionHandler handler)

throws IOException;
  }

Then I create a new RequestExceptionHandler as a pipeline:

  public static RequestExceptionHandler 
buildImprovedRequestExceptionHandler(

  List configuration,
  @InjectService("RequestExceptionHandler") 
RequestExceptionHandler requestExceptionHandler,

  PipelineBuilder builder,
  Logger logger
  ) {
return builder.build(
logger,
RequestExceptionHandler.class,
RequestExceptionFilter.class,
configuration,
requestExceptionHandler
);
  }

I then contribute this to AliasOverrides to replace the default 
RequestExceptionHandler:


  public static void contributeAliasOverrides(
  Configuration configuration,
  @InjectService("ImprovedRequestExceptionHandler") 
RequestExceptionHandler requestExceptionHandler

  ) {

configuration.add(AliasContribution.create(RequestExceptionHandler.class, 
requestExceptionHandler));

  }

I can then contribute filters to the pipeline like this:

  public static void contributeImprovedRequestExceptionHandler(
  OrderedConfiguration configuration,
  RequestExceptionErrorFilter requestExceptionErrorFilter
  ) {
configuration.add("Error", requestExceptionErrorFilter);
  }

Where RequestExceptionErrorFilter looks like this:

  public class RequestExceptionErrorFilter
  implements RequestExceptionFilter {

private final RedirectService redirectService;
private final SecurityService securityService;
private final Logger logger;

public RequestExceptionErrorFilter(RedirectService 
redirectService, SecurityService securityService, Logger logger) {

  this.redirectService = redirectService;
  this.securityService = securityService;
  this.logger = logger;
}

public void handleRequestException(Throwable exception, 
RequestExceptionHandler handler)

throws IOException {
  if (securityService.isProductionModeEnabled()) {
logger.error("Exception during request", exception);
redirectService.sendRedirect(ErrorIndex.class, false);
  }
  else {
handler.handleRequestException(exception);
  }
}
  }

RedirectService and SecurityService are my own classes. They just make 
some things easier for me. As you can see I show an error page when 
I'm in production but invoke the next filter in the pipeline if I'm 
not. You could contribute more filters if needed.


I've been wanting to contribute a strategy filter before this one 
allowing to do different things depending on the type of exception 
thrown, but haven't had the time nor need to do so yet.


http://tapestry.apache.org/tapestry5/tapestry-ioc/strategy.html

Anyhow, hope this helps - if not, you know where to ask. :)

-Filip

On 2008-05-16 17:37, Leon Derks wrote:

Thanks Peter,

Your original question in the post is also what I would like to know.

Do you now know how to override server error pages(404, 505 etc)?
And I don't understand what Flip means with :I've turned the 
RequestExceptionHandler service into a pipeline.


Can you show me some code of how to do this?
Leon


Peter Stavrinides wrote:

Hi Leon

I posted a number of questions to the list about this topic, but got 
only a few perls. One of them was this post, particularly Filip's 
answer:

http://www.mail-archive.com/users@tapestry.apache.org/msg21914.html

Also see this page, for how to override Tapestry's error page with 
your own friendly error page:

http://wiki.apache.org/tapestry/Tapestry5ExceptionPage

I am not sure what you are trying to do, but would suggest you 
familiarize yourself a bit more with Tapestry's error reporting 
mechanisms, which imho are incredibly powerful and easy to use.


Hope this helps,
Peter


- Original Message -
From: "Leon Derks" <[EMAIL PROTECTED]>
To: "Tapestry users" 
Sent: Friday, 16 May, 2008 1:35:19 PM GMT +02:00 Athens, Beirut, 
Bucharest, Istanbul

Subject: T5: Exception Handling

Hello

What is the best way to handle exceptions in Tapestry 5?

I want to show some kind of general error page, when an exception 
occurs.


At the m

Re: T5: Exception Handling

2008-05-17 Thread Filip S. Adamsen

Hi Leon,

How to override server error pages depends on what server you're using. 
As far as I'm aware it's unfortunately not possible to use Tapestry 
pages as server error pages - if I'm wrong here, I'd really like to know 
how to do it. :)


What I mean by turning the RequestExceptionHandler into a pipeline is 
that I've overridden the original service with my own that uses a pipeline.


http://tapestry.apache.org/tapestry5/tapestry-ioc/pipeline.html

So I define my filter:

  public interface RequestExceptionFilter {

void handleRequestException(Throwable exception, 
RequestExceptionHandler handler)

throws IOException;
  }

Then I create a new RequestExceptionHandler as a pipeline:

  public static RequestExceptionHandler 
buildImprovedRequestExceptionHandler(

  List configuration,
  @InjectService("RequestExceptionHandler") RequestExceptionHandler 
requestExceptionHandler,

  PipelineBuilder builder,
  Logger logger
  ) {
return builder.build(
logger,
RequestExceptionHandler.class,
RequestExceptionFilter.class,
configuration,
requestExceptionHandler
);
  }

I then contribute this to AliasOverrides to replace the default 
RequestExceptionHandler:


  public static void contributeAliasOverrides(
  Configuration configuration,
  @InjectService("ImprovedRequestExceptionHandler") 
RequestExceptionHandler requestExceptionHandler

  ) {

configuration.add(AliasContribution.create(RequestExceptionHandler.class, 
requestExceptionHandler));

  }

I can then contribute filters to the pipeline like this:

  public static void contributeImprovedRequestExceptionHandler(
  OrderedConfiguration configuration,
  RequestExceptionErrorFilter requestExceptionErrorFilter
  ) {
configuration.add("Error", requestExceptionErrorFilter);
  }

Where RequestExceptionErrorFilter looks like this:

  public class RequestExceptionErrorFilter
  implements RequestExceptionFilter {

private final RedirectService redirectService;
private final SecurityService securityService;
private final Logger logger;

public RequestExceptionErrorFilter(RedirectService redirectService, 
SecurityService securityService, Logger logger) {

  this.redirectService = redirectService;
  this.securityService = securityService;
  this.logger = logger;
}

public void handleRequestException(Throwable exception, 
RequestExceptionHandler handler)

throws IOException {
  if (securityService.isProductionModeEnabled()) {
logger.error("Exception during request", exception);
redirectService.sendRedirect(ErrorIndex.class, false);
  }
  else {
handler.handleRequestException(exception);
  }
}
  }

RedirectService and SecurityService are my own classes. They just make 
some things easier for me. As you can see I show an error page when I'm 
in production but invoke the next filter in the pipeline if I'm not. You 
could contribute more filters if needed.


I've been wanting to contribute a strategy filter before this one 
allowing to do different things depending on the type of exception 
thrown, but haven't had the time nor need to do so yet.


http://tapestry.apache.org/tapestry5/tapestry-ioc/strategy.html

Anyhow, hope this helps - if not, you know where to ask. :)

-Filip

On 2008-05-16 17:37, Leon Derks wrote:

Thanks Peter,

Your original question in the post is also what I would like to know.

Do you now know how to override server error pages(404, 505 etc)?
And I don't understand what Flip means with :I've turned the 
RequestExceptionHandler service into a pipeline.


Can you show me some code of how to do this?
Leon


Peter Stavrinides wrote:

Hi Leon

I posted a number of questions to the list about this topic, but got 
only a few perls. One of them was this post, particularly Filip's answer:

http://www.mail-archive.com/users@tapestry.apache.org/msg21914.html

Also see this page, for how to override Tapestry's error page with 
your own friendly error page:

http://wiki.apache.org/tapestry/Tapestry5ExceptionPage

I am not sure what you are trying to do, but would suggest you 
familiarize yourself a bit more with Tapestry's error reporting 
mechanisms, which imho are incredibly powerful and easy to use.


Hope this helps,
Peter


- Original Message -
From: "Leon Derks" <[EMAIL PROTECTED]>
To: "Tapestry users" 
Sent: Friday, 16 May, 2008 1:35:19 PM GMT +02:00 Athens, Beirut, 
Bucharest, Istanbul

Subject: T5: Exception Handling

Hello

What is the best way to handle exceptions in Tapestry 5?

I want to show some kind of general error page, when an exception occurs.

At the moment I have a onException method in my BasePage class. But 
for some reason the Error page

Re: T5: Exception Handling

2008-05-16 Thread Leon Derks

Thanks Peter,

Your original question in the post is also what I would like to know.

Do you now know how to override server error pages(404, 505 etc)?
And I don't understand what Flip means with :I've turned the 
RequestExceptionHandler service into a pipeline.


Can you show me some code of how to do this?
Leon


Peter Stavrinides wrote:

Hi Leon

I posted a number of questions to the list about this topic, but got only a few 
perls. One of them was this post, particularly Filip's answer:
http://www.mail-archive.com/users@tapestry.apache.org/msg21914.html

Also see this page, for how to override Tapestry's error page with your own 
friendly error page:
http://wiki.apache.org/tapestry/Tapestry5ExceptionPage

I am not sure what you are trying to do, but would suggest you familiarize 
yourself a bit more with Tapestry's error reporting mechanisms, which imho are 
incredibly powerful and easy to use.

Hope this helps,
Peter


- Original Message -
From: "Leon Derks" <[EMAIL PROTECTED]>
To: "Tapestry users" 
Sent: Friday, 16 May, 2008 1:35:19 PM GMT +02:00 Athens, Beirut, Bucharest, 
Istanbul
Subject: T5: Exception Handling

Hello

What is the best way to handle exceptions in Tapestry 5?

I want to show some kind of general error page, when an exception occurs.

At the moment I have a onException method in my BasePage class. But for 
some reason the Error page is not returned.

What is the way in T5 to handle exceptions?

Object onException(Throwable cause) {
return new Error();
}

Leon

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


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



  



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



Re: T5: Exception Handling

2008-05-16 Thread Peter Stavrinides
Hi Leon

I posted a number of questions to the list about this topic, but got only a few 
perls. One of them was this post, particularly Filip's answer:
http://www.mail-archive.com/users@tapestry.apache.org/msg21914.html

Also see this page, for how to override Tapestry's error page with your own 
friendly error page:
http://wiki.apache.org/tapestry/Tapestry5ExceptionPage

I am not sure what you are trying to do, but would suggest you familiarize 
yourself a bit more with Tapestry's error reporting mechanisms, which imho are 
incredibly powerful and easy to use.

Hope this helps,
Peter


- Original Message -
From: "Leon Derks" <[EMAIL PROTECTED]>
To: "Tapestry users" 
Sent: Friday, 16 May, 2008 1:35:19 PM GMT +02:00 Athens, Beirut, Bucharest, 
Istanbul
Subject: T5: Exception Handling

Hello

What is the best way to handle exceptions in Tapestry 5?

I want to show some kind of general error page, when an exception occurs.

At the moment I have a onException method in my BasePage class. But for 
some reason the Error page is not returned.
What is the way in T5 to handle exceptions?

Object onException(Throwable cause) {
return new Error();
}

Leon

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


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



T5: Exception Handling

2008-05-16 Thread Leon Derks

Hello

What is the best way to handle exceptions in Tapestry 5?

I want to show some kind of general error page, when an exception occurs.

At the moment I have a onException method in my BasePage class. But for 
some reason the Error page is not returned.

What is the way in T5 to handle exceptions?

Object onException(Throwable cause) {
   return new Error();
   }

Leon

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



Re: Application Exception handling

2007-03-13 Thread Jesse Kuhnert

I think most the exception infrastructure is focused around building
up location / context information more so than exception types, though
types are handled as well of course.. .

If you want to know how tapestry handles it right now take a look at:

http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/engine/AbstractEngine.java?view=markup

I can see it being useful having a hivemind strategy / config point
similar to how data squeezers "vote" for handling something being the
means by which these exception presenters are chosen. I'll file a jira
issue for it.

On 3/8/07, Justin Walsh <[EMAIL PROTECTED]> wrote:

Is there a preferred way/pattern of handling application exceptions in a
tapestry application.
For example, I have a page, AuthorizationFailure.html which I want to
display when a javax.ejb.EJBAccessException is thrown from the ejb
layer, with a custom message etc.

At the moment I'm plugging in my own ExceptionPresenter which sniffs out
the root cause and delegates to a handler, defaulting to the exception
page when a specific handler can't be found.  But I'm wondering if I'm
missing anything.  Perhaps there are exception handler base classes that
I can use? Or perhaps I can configure an exception presenter for a
specific type of exception?

Cheers

--
Justin Walsh
http://www.ewage.co.za


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





--
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

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



Application Exception handling

2007-03-08 Thread Justin Walsh
Is there a preferred way/pattern of handling application exceptions in a
tapestry application.
For example, I have a page, AuthorizationFailure.html which I want to
display when a javax.ejb.EJBAccessException is thrown from the ejb
layer, with a custom message etc.

At the moment I'm plugging in my own ExceptionPresenter which sniffs out
the root cause and delegates to a handler, defaulting to the exception
page when a specific handler can't be found.  But I'm wondering if I'm
missing anything.  Perhaps there are exception handler base classes that
I can use? Or perhaps I can configure an exception presenter for a
specific type of exception? 

Cheers

-- 
Justin Walsh 
http://www.ewage.co.za


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



Re: bypassing the normal exception handling

2006-11-13 Thread Jesse Kuhnert

Throw a RuntimeException instead of ApplicationRuntimeException ?

On 11/13/06, Dan Adams <[EMAIL PROTECTED]> wrote:


I have a page where if there is an exception I actually want it to
bubble up all the way to the container so that a 500 error is displayed.
Anyone know how to do that?

--
Dan Adams
Senior Software Engineer
Interactive Factory
617.235.5857


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





--
Jesse Kuhnert
Tapestry/Dojo/(and a dash of TestNG), team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com


bypassing the normal exception handling

2006-11-13 Thread Dan Adams
I have a page where if there is an exception I actually want it to
bubble up all the way to the container so that a 500 error is displayed.
Anyone know how to do that?

-- 
Dan Adams
Senior Software Engineer
Interactive Factory
617.235.5857


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