You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Michael Taylor <mi...@google.com> on 2010/11/22 19:51:13 UTC

AJAX zone refresh error messages

Greetings Tapestry users,

I have a question about ajax refreshing zones.
I have a page that contains a number of custom components each of which has
its own zone that gets refreshed via ajax.
I've noticed that if there is a problem on the server side when executing
the ajax refresh tapestry dynamically pops up a read error message box at
the top of the page which is visible for a few seconds and then fades out.
The problem I'm having is that this error message is showing the stack trace
of the exception that got thrown on the sever side which isn't particularly
user friendly.
I'd like to customize what this error message says, but I'm not sure how to
do it.  I'd tried poking around in the documentation, but all I could find
was information on form validation error messages which didn't seem quite
applicable.
Could anyone give me any tips on how to customize these ajax refresh error
messages (or point me at the relevant documentation).

Thanks in advance,


Mike T

Re: AJAX zone refresh error messages

Posted by Michael Taylor <mi...@google.com>.
At the moment we're using a 5.2 build (pulled from head sometime in April).

Here's the simplest sort of example I could come up with.

The java code would look something like this


import org.apache.tapestry5.annotations.InjectComponent;
import org.apache.tapestry5.corelib.components.Zone;

import java.util.Date;

public class TestErrorPage {

  @InjectComponent
  private Zone testZone;

  public Object onActionFromRefreshTestZoneLink() {
    return testZone.getBody();
  }

  public String getCurrentTime() {
    return new Date().toString();
  }
}




and the TML


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
<head>
      <title>This is only a test</title>
</head>
<body>
  This is text outside the zone: ${currentTime}
  <br/>
  <div t:type="zone" t:id="testZone">
    This is text inside the zone: ${currentTime}
  </div>
  <a t:type="actionlink" t:id="refreshTestZoneLink" href="#"
t:zone="testZone">Refresh Zone</a>
</body>
</html>


When everything works you get something like

[image: working.png]


Now let's simulate an error happening during the AJAX request


public Object onActionFromRefreshTestZoneLink() {
    throw new RuntimeException("Oh no there was an error!");
  }


Now you'll get something like the following

[image: Simple_error.png]


Notice the red box with the error message in it.  This will appear on
screen, and then fade out after a few seconds.
When you have a simple exception like this it's not too bad, however when
the exception gets generated deep down in the code and passes through
multiple layers of rethrowing it's starts getting ugly.

For example if I do this

  public Object onActionFromRefreshTestZoneLink() {
    throw new RuntimeException(new RuntimeException(new RuntimeException("Oh
no there was an error!")));
  }


then the error message looks like


[image: nested_error.png]


Now I can kind of fix this by wrapping all of my zone refresh handlers in a
giant try catch block and eating the thrown exception and throwing a more
user friendly exception (although even then I seem to be stuck with the
"Communication with the server failed:" being tacked onto the front of it)
but I was wondering if there were any other options.


Mike T

On Tue, Nov 23, 2010 at 7:36 PM, Paul Stanton <pa...@mapshed.com.au> wrote:

> haha leverage is perfectly appropriate in that context!
>
> i'm not sure i'm familiar with the error popup you're referring to, when i
> get XHR errors, i think blackbird handles them (ie it is the default in
> t5.1)
>
> what version are you using and can you produce a simple example to
> reproduce your problem?
>
> p.
>
>
> On 24/11/2010 6:30 AM, Christian Edward Gruber wrote:
>
>> I apologize, sincerely, for my colleague using the word "leverage" as a
>> verb.  He's been in one too many meetings with management. ;-)
>>
>> But seriously, no, it's not blackbird.  It's the little red error messages
>> that pop up when you get XHR errors.  (Mike, Blackbird is a javascript-based
>> error console per http://www.gscottolson.com/blackbirdjs/)
>>
>> Christian.
>>
>> On Nov 23, 2010, at 8:52 AM, Michael Taylor wrote:
>>
>>  To be honest I'm not sure.  I don't really know what 'BlackBird' is.
>>> I was hoping though to still show an error message to the user, but just
>>> make it a little more user friendly instead of a giant stack trace.
>>> I could just suppress these error messages and then role my own custom
>>> error
>>> display, but I thought it might be easier to leverage this one and just
>>> change the displayed text.
>>>
>>> Mike T
>>>
>>> On Mon, Nov 22, 2010 at 5:59 PM, Paul Stanton<pa...@mapshed.com.au>
>>>  wrote:
>>>
>>>  is the error message you're referring to the 'BlackBird' error popup?
>>>>
>>>> if you want to disable it set SymbolConstants.BLACKBIRD_ENABLED to false
>>>> in
>>>> your Module.
>>>>
>>>> p.
>>>>
>>>>
>>>> On 23/11/2010 5:51 AM, Michael Taylor wrote:
>>>>
>>>>  Greetings Tapestry users,
>>>>>
>>>>> I have a question about ajax refreshing zones.
>>>>> I have a page that contains a number of custom components each of which
>>>>> has
>>>>> its own zone that gets refreshed via ajax.
>>>>> I've noticed that if there is a problem on the server side when
>>>>> executing
>>>>> the ajax refresh tapestry dynamically pops up a read error message box
>>>>> at
>>>>> the top of the page which is visible for a few seconds and then fades
>>>>> out.
>>>>> The problem I'm having is that this error message is showing the stack
>>>>> trace
>>>>> of the exception that got thrown on the sever side which isn't
>>>>> particularly
>>>>> user friendly.
>>>>> I'd like to customize what this error message says, but I'm not sure
>>>>> how
>>>>> to
>>>>> do it.  I'd tried poking around in the documentation, but all I could
>>>>> find
>>>>> was information on form validation error messages which didn't seem
>>>>> quite
>>>>> applicable.
>>>>> Could anyone give me any tips on how to customize these ajax refresh
>>>>> error
>>>>> messages (or point me at the relevant documentation).
>>>>>
>>>>> Thanks in advance,
>>>>>
>>>>>
>>>>> Mike T
>>>>>
>>>>>
>>>>>  ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>
>>>>
>>>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: AJAX zone refresh error messages

Posted by Paul Stanton <pa...@mapshed.com.au>.
haha leverage is perfectly appropriate in that context!

i'm not sure i'm familiar with the error popup you're referring to, when 
i get XHR errors, i think blackbird handles them (ie it is the default 
in t5.1)

what version are you using and can you produce a simple example to 
reproduce your problem?

p.

On 24/11/2010 6:30 AM, Christian Edward Gruber wrote:
> I apologize, sincerely, for my colleague using the word "leverage" as a verb.  He's been in one too many meetings with management. ;-)
>
> But seriously, no, it's not blackbird.  It's the little red error messages that pop up when you get XHR errors.  (Mike, Blackbird is a javascript-based error console per http://www.gscottolson.com/blackbirdjs/)
>
> Christian.
>
> On Nov 23, 2010, at 8:52 AM, Michael Taylor wrote:
>
>> To be honest I'm not sure.  I don't really know what 'BlackBird' is.
>> I was hoping though to still show an error message to the user, but just
>> make it a little more user friendly instead of a giant stack trace.
>> I could just suppress these error messages and then role my own custom error
>> display, but I thought it might be easier to leverage this one and just
>> change the displayed text.
>>
>> Mike T
>>
>> On Mon, Nov 22, 2010 at 5:59 PM, Paul Stanton<pa...@mapshed.com.au>  wrote:
>>
>>> is the error message you're referring to the 'BlackBird' error popup?
>>>
>>> if you want to disable it set SymbolConstants.BLACKBIRD_ENABLED to false in
>>> your Module.
>>>
>>> p.
>>>
>>>
>>> On 23/11/2010 5:51 AM, Michael Taylor wrote:
>>>
>>>> Greetings Tapestry users,
>>>>
>>>> I have a question about ajax refreshing zones.
>>>> I have a page that contains a number of custom components each of which
>>>> has
>>>> its own zone that gets refreshed via ajax.
>>>> I've noticed that if there is a problem on the server side when executing
>>>> the ajax refresh tapestry dynamically pops up a read error message box at
>>>> the top of the page which is visible for a few seconds and then fades out.
>>>> The problem I'm having is that this error message is showing the stack
>>>> trace
>>>> of the exception that got thrown on the sever side which isn't
>>>> particularly
>>>> user friendly.
>>>> I'd like to customize what this error message says, but I'm not sure how
>>>> to
>>>> do it.  I'd tried poking around in the documentation, but all I could find
>>>> was information on form validation error messages which didn't seem quite
>>>> applicable.
>>>> Could anyone give me any tips on how to customize these ajax refresh error
>>>> messages (or point me at the relevant documentation).
>>>>
>>>> Thanks in advance,
>>>>
>>>>
>>>> Mike T
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>

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


Re: AJAX zone refresh error messages

Posted by Christian Edward Gruber <cg...@google.com>.
I apologize, sincerely, for my colleague using the word "leverage" as a verb.  He's been in one too many meetings with management. ;-)

But seriously, no, it's not blackbird.  It's the little red error messages that pop up when you get XHR errors.  (Mike, Blackbird is a javascript-based error console per http://www.gscottolson.com/blackbirdjs/)

Christian.

On Nov 23, 2010, at 8:52 AM, Michael Taylor wrote:

> To be honest I'm not sure.  I don't really know what 'BlackBird' is.
> I was hoping though to still show an error message to the user, but just
> make it a little more user friendly instead of a giant stack trace.
> I could just suppress these error messages and then role my own custom error
> display, but I thought it might be easier to leverage this one and just
> change the displayed text.
> 
> Mike T
> 
> On Mon, Nov 22, 2010 at 5:59 PM, Paul Stanton <pa...@mapshed.com.au> wrote:
> 
>> is the error message you're referring to the 'BlackBird' error popup?
>> 
>> if you want to disable it set SymbolConstants.BLACKBIRD_ENABLED to false in
>> your Module.
>> 
>> p.
>> 
>> 
>> On 23/11/2010 5:51 AM, Michael Taylor wrote:
>> 
>>> Greetings Tapestry users,
>>> 
>>> I have a question about ajax refreshing zones.
>>> I have a page that contains a number of custom components each of which
>>> has
>>> its own zone that gets refreshed via ajax.
>>> I've noticed that if there is a problem on the server side when executing
>>> the ajax refresh tapestry dynamically pops up a read error message box at
>>> the top of the page which is visible for a few seconds and then fades out.
>>> The problem I'm having is that this error message is showing the stack
>>> trace
>>> of the exception that got thrown on the sever side which isn't
>>> particularly
>>> user friendly.
>>> I'd like to customize what this error message says, but I'm not sure how
>>> to
>>> do it.  I'd tried poking around in the documentation, but all I could find
>>> was information on form validation error messages which didn't seem quite
>>> applicable.
>>> Could anyone give me any tips on how to customize these ajax refresh error
>>> messages (or point me at the relevant documentation).
>>> 
>>> Thanks in advance,
>>> 
>>> 
>>> Mike T
>>> 
>>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>> 
>> 


Re: AJAX zone refresh error messages

Posted by Michael Taylor <mi...@google.com>.
To be honest I'm not sure.  I don't really know what 'BlackBird' is.
I was hoping though to still show an error message to the user, but just
make it a little more user friendly instead of a giant stack trace.
I could just suppress these error messages and then role my own custom error
display, but I thought it might be easier to leverage this one and just
change the displayed text.

Mike T

On Mon, Nov 22, 2010 at 5:59 PM, Paul Stanton <pa...@mapshed.com.au> wrote:

> is the error message you're referring to the 'BlackBird' error popup?
>
> if you want to disable it set SymbolConstants.BLACKBIRD_ENABLED to false in
> your Module.
>
> p.
>
>
> On 23/11/2010 5:51 AM, Michael Taylor wrote:
>
>> Greetings Tapestry users,
>>
>> I have a question about ajax refreshing zones.
>> I have a page that contains a number of custom components each of which
>> has
>> its own zone that gets refreshed via ajax.
>> I've noticed that if there is a problem on the server side when executing
>> the ajax refresh tapestry dynamically pops up a read error message box at
>> the top of the page which is visible for a few seconds and then fades out.
>> The problem I'm having is that this error message is showing the stack
>> trace
>> of the exception that got thrown on the sever side which isn't
>> particularly
>> user friendly.
>> I'd like to customize what this error message says, but I'm not sure how
>> to
>> do it.  I'd tried poking around in the documentation, but all I could find
>> was information on form validation error messages which didn't seem quite
>> applicable.
>> Could anyone give me any tips on how to customize these ajax refresh error
>> messages (or point me at the relevant documentation).
>>
>> Thanks in advance,
>>
>>
>> Mike T
>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: AJAX zone refresh error messages

Posted by Paul Stanton <pa...@mapshed.com.au>.
is the error message you're referring to the 'BlackBird' error popup?

if you want to disable it set SymbolConstants.BLACKBIRD_ENABLED to false 
in your Module.

p.

On 23/11/2010 5:51 AM, Michael Taylor wrote:
> Greetings Tapestry users,
>
> I have a question about ajax refreshing zones.
> I have a page that contains a number of custom components each of which has
> its own zone that gets refreshed via ajax.
> I've noticed that if there is a problem on the server side when executing
> the ajax refresh tapestry dynamically pops up a read error message box at
> the top of the page which is visible for a few seconds and then fades out.
> The problem I'm having is that this error message is showing the stack trace
> of the exception that got thrown on the sever side which isn't particularly
> user friendly.
> I'd like to customize what this error message says, but I'm not sure how to
> do it.  I'd tried poking around in the documentation, but all I could find
> was information on form validation error messages which didn't seem quite
> applicable.
> Could anyone give me any tips on how to customize these ajax refresh error
> messages (or point me at the relevant documentation).
>
> Thanks in advance,
>
>
> Mike T
>

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