You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Kalle Korhonen <ka...@gmail.com> on 2014/09/24 17:24:10 UTC
Re: Component exception wanted! No data, fail gracefully.
On Wed, Sep 24, 2014 at 5:30 AM, Chris Mylonas <ch...@opencsta.org> wrote:
>
> The SliderSectionServiceImpl throws higher up the stack - can this pass
>>> the exception up to setupRender? I thought "throws SystemException" would
>>> have been enough?
>>>
>>
>> What about having your code handling the exceptions itself, when it calls
>> the EJB methods that can throw exceptions?
>>
>>
> Handling is adding a tonne of work, just on the slider component I've had
> to muck around with several page classes, the service implementing class
> and the value encoder now returns null just for hackiness tests - maybe not
> so much in this project because it's little, but I have another larger
> project to hit the books on so-to-speak, so am using this smaller project
> to see my best options. My re-thrown message has come up but it's exactly
> what I was hoping to avoid ##below
>
>
> Another option: have you tried adding an onException(Exception e) method
>> to your component?
>>
>
> Yes. And in the onException method I try and return a different page that
> has @InjectPage in the component class.
> Using tapestry-hibernate I think the errors pop upwards much nicer - that
> could be EJB FUD I'm stirring, it's quite late and my comedy hour is nearly
> here, just warming up :)
>
>
>> Another option: override the Tapestry error page.
>>
>
> You know, I think this one will do the job. I may just have to make a
> hashtable of error codes to friendly-configure-this-component-yourself page
> for the component ##above. Hashtable or service would be nicer - My first
> ever tapestry service was for converting netmask to stroke notation for a
> select i.e. 255.255.255.0 to /24 - I know how much code that saved!!!
>
In 5.4, you can contribute to the default error page and map exception
types to specific error pages (
http://tapestry.apache.org/5.4/apidocs/org/apache/tapestry5/internal/services/DefaultRequestExceptionHandler.html
- that reminds me, I should add information about that to the user guide as
well).
Kalle
Re: Component exception wanted! No data, fail gracefully.
Posted by Chris Mylonas <ch...@opencsta.org>.
I'm going to have to d/l your project and go over it more carefully than a
browser look at it. The error I omitted when using
RequestExceptionHandler was, sic, "there is no such service by that name".
However, that was >midnight and this morning when I tried it deployed.
Unfortunately it did not redirect as I thought it would and I have since
done:
void setupRender() {
// slider = sliderService.getById(new Long(1)); //using the EJB
through an @Inject T5 service
// slider = sliderEJBService.getById(new Long(1)); //using the @EJB
notation
throw new SliderException(new Throwable("YEAH")); //just throw an
exception
}
But I'm getting the standard exception report page. This is on beta-6
because I can't get beta-22 to work (see other thread re: commons-io
dependency)
An exception has occurred processing this request.
Render queue error in SetupRender[Index:layout.slider]:
java.lang.Throwable: YEAH
I might go back to my prototyping workflow using tapestry-hibernate so
there is less "other shit" in the way when doing the tapestry stuff because
it'll be quicker. (Might give me a chance to write some codegen scripts)
P.S. Thiago, if you read this, mail died a couple of times today and rss
feeds didn't update correctly without a shutdown. I'll reboot my machine,
but this is unix underneath man! 21st century too! :P
On Thu, Sep 25, 2014 at 9:09 AM, Kalle Korhonen <ka...@gmail.com>
wrote:
> On Wed, Sep 24, 2014 at 9:34 AM, Chris Mylonas <ch...@opencsta.org> wrote:
>
> >
> >> In 5.4, you can contribute to the default error page and map exception
> >> types to specific error pages (
> >> http://tapestry.apache.org/5.4/apidocs/org/apache/
> >> tapestry5/internal/services/DefaultRequestExceptionHandler.html
> >> - that reminds me, I should add information about that to the user guide
> >> as
> >> well).
> >>
> >
> > And I've contributed all this in AppModule
> > public void
> contributeDefaultRequestExceptionHandler(MappedConfiguration<Class,
> > Class> configuration) {
> > configuration.add(SliderException.class, DefaultNeeded.class);
> > }
> >
> > with a few attempts guessing the method name
> contributeRequestExceptionHandler,
> > contributeExceptionHandler but each time a similar error in the logs:
> > Caused by: java.lang.IllegalArgumentException: Contribution
> > org.opencsta.website.metwide.web.services.AppModule.
> > contributeDefaultRequestExceptionHandler(MappedConfiguration) (at
> > AppModule.java:133) is for service 'DefaultRequestExceptionHandler',
> > which does not exist.
> >
>
> RequestExceptionHandler is the interface and the service name, so
> contributeRequestExceptionHandler works, I wonder which error message you
> got when you tried it. DefaultRequestExceptionHandler is the default
> exceptionHandler that accepts contributions. This configuration is already
> being used in tapestry-security 0.6, which is for T5.4 (see
>
> https://github.com/tynamo/tapestry-security/blob/master/src/main/java/org/tynamo/security/services/SecurityModule.java
> ).
>
> Kalle
>
Re: Component exception wanted! No data, fail gracefully.
Posted by Kalle Korhonen <ka...@gmail.com>.
On Wed, Sep 24, 2014 at 9:34 AM, Chris Mylonas <ch...@opencsta.org> wrote:
>
>> In 5.4, you can contribute to the default error page and map exception
>> types to specific error pages (
>> http://tapestry.apache.org/5.4/apidocs/org/apache/
>> tapestry5/internal/services/DefaultRequestExceptionHandler.html
>> - that reminds me, I should add information about that to the user guide
>> as
>> well).
>>
>
> And I've contributed all this in AppModule
> public void contributeDefaultRequestExceptionHandler(MappedConfiguration<Class,
> Class> configuration) {
> configuration.add(SliderException.class, DefaultNeeded.class);
> }
>
> with a few attempts guessing the method name contributeRequestExceptionHandler,
> contributeExceptionHandler but each time a similar error in the logs:
> Caused by: java.lang.IllegalArgumentException: Contribution
> org.opencsta.website.metwide.web.services.AppModule.
> contributeDefaultRequestExceptionHandler(MappedConfiguration) (at
> AppModule.java:133) is for service 'DefaultRequestExceptionHandler',
> which does not exist.
>
RequestExceptionHandler is the interface and the service name, so
contributeRequestExceptionHandler works, I wonder which error message you
got when you tried it. DefaultRequestExceptionHandler is the default
exceptionHandler that accepts contributions. This configuration is already
being used in tapestry-security 0.6, which is for T5.4 (see
https://github.com/tynamo/tapestry-security/blob/master/src/main/java/org/tynamo/security/services/SecurityModule.java
).
Kalle
Re: Component exception wanted! No data, fail gracefully.
Posted by Chris Mylonas <ch...@opencsta.org>.
>
> In 5.4, you can contribute to the default error page and map exception
> types to specific error pages (
> http://tapestry.apache.org/5.4/apidocs/org/apache/tapestry5/internal/services/DefaultRequestExceptionHandler.html
> - that reminds me, I should add information about that to the user guide
> as
> well).
So ... I tried and failed ... surprise surprise - it's 2:30am :)
If a simple example to start off with helps, this is what I have so far.
I have a Slider component from earlier in the thread. It fetches slider
data from persistence via EJB/JPA in a tapestry IoC service via
setupRender()
The Slider component template - it has 4 slides, hardcoded so it needs 4
slides! Obviously needs more dev to make it more configurable (i.e. 2
slides or 5 slides)
<t:container xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd">
<!-- Slider starts -->
<div class="parallax-slider">
<!-- Slider (Parallax Slider) -->
<div id="da-slider" class="da-slider">
<!-- Each slide should be enclosed inside
"da-slide" class -->
<div class="da-slide">
<div class="slide-details">
<!-- Heading -->
<h2><span>${slider.heading1}</span></h2>
<!-- Para -->
<p>${slider.blurb1}</p>
<!-- Read more link -->
<a href="${slider.href1}"
class="da-link">${slider.text1}</a>
<!-- Image -->
<div class="da-img"><img
src="${context:img/parallax/1.png}" alt="image01" /></div>
</div>
</div>
<div class="da-slide">
<h2><span>${slider.heading2}</span></h2>
<p>${slider.blurb2}</p>
<a href="${slider.href2}"
class="da-link">${slider.text2}</a>
<div class="da-img"><img
src="${context:img/parallax/2.png}" alt="image01" /></div>
</div>
<div class="da-slide">
<h2><span>${slider.heading3}</span></h2>
<p>${slider.blurb3}</p>
<a href="${slider.href3}"
class="da-link">${slider.text3}</a>
<div class="da-img"><img
src="${context:img/parallax/3.png}" alt="image01" /></div>
</div>
<div class="da-slide">
<h2><span>${slider.heading4}</span></h2>
<p>${slider.blurb4}</p>
<a href="${slider.href4}"
class="da-link">${slider.text4}</a>
<div class="da-img"><img
src="${context:img/parallax/4.png}" alt="image01" /></div>
</div>
<nav class="da-arrows">
<span class="da-arrows-prev"></span>
<span class="da-arrows-next"></span>
</nav>
</div>
</div>
<!-- Slider ends -->
</t:container>
When the component Slider fetches the stored data and it doesn't exist, an
EJBException/NoResultException is caught in the SliderFetchDataService and
rethrown as a SliderException.
public class SliderException extends RuntimeException {
public SliderException(Throwable throwable) {
super(throwable);
}
public SliderException(String message, Throwable throwable) {
super(message, throwable);
}
}
The custom/contributed exception handling page is called DefaultNeeded and
reading the docs I'm expecting DefaultNeeded/Slider to be redirected to
but don't expect anything for the moment because it's bare (no context is
handled)
Here is DefaultNeeded java/tml
public class DefaultNeeded {
//no activation context yet, just display a page
}
<html t:type="Bare" title="Create SliderSection" t:sidebarTitle="Current
Time"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"
xmlns:p="tapestry:parameter">
<h1>Create SliderSection</h1>
<div class="SliderSection">
<!-- Note this is commented out
<t:beaneditform object="newSliderSection" exclude="id" />
-->
</div>
</html>
And I've contributed all this in AppModule
public void
contributeDefaultRequestExceptionHandler(MappedConfiguration<Class, Class>
configuration) {
configuration.add(SliderException.class, DefaultNeeded.class);
}
with a few attempts guessing the method name
contributeRequestExceptionHandler, contributeExceptionHandler but each
time a similar error in the logs:
Caused by: java.lang.IllegalArgumentException: Contribution
org.opencsta.website.metwide.web.services.AppModule.contributeDefaultRequestExceptionHandler(MappedConfiguration)
(at AppModule.java:133) is for service 'DefaultRequestExceptionHandler',
which does not exist.
So I guess I just have the wrong contributeMethodName/ArgumentList
happening - looks like several arguments missing
Looking at
http://tapestry.apache.org/5.4/apidocs/org/apache/tapestry5/internal/services/DefaultRequestExceptionHandler.html
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Component exception wanted! No data, fail gracefully.
Posted by Chris Mylonas <ch...@opencsta.org>.
> You should update to 5.4-beta-22
my beta-6 is like a year of betas behind! thanks
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Component exception wanted! No data, fail gracefully.
Posted by Kalle Korhonen <ka...@gmail.com>.
On Wed, Sep 24, 2014 at 8:49 AM, Chris Mylonas <ch...@opencsta.org> wrote:
> Hi Kalle,
>
>> In 5.4, you can contribute to the default error page and map exception
>> types to specific error pages (
>> http://tapestry.apache.org/5.4/apidocs/org/apache/
>> tapestry5/internal/services/DefaultRequestExceptionHandler.html
>> - that reminds me, I should add information about that to the user guide
>> as
>> well).
>>
>
> I came across this earlier tonight http://tynamo.org/tapestry-
> exceptionpage+guide and it looks like what you refer to in 5.4 docs.
> I'm using 5.4-beta-6 for my little-bootstrap-project. Making
> SliderException handled by a CreateDefaultSlider page is precisely what I'm
> after to get me out of little-bootstrap-project curation tasks :)
>
You should update to 5.4-beta-22. And yes, a version of the
tapestry-exceptionpage module was merged to T5.4.
Kalle
Re: Component exception wanted! No data, fail gracefully.
Posted by Chris Mylonas <ch...@opencsta.org>.
Hi Kalle,
> In 5.4, you can contribute to the default error page and map exception
> types to specific error pages (
> http://tapestry.apache.org/5.4/apidocs/org/apache/tapestry5/internal/services/DefaultRequestExceptionHandler.html
> - that reminds me, I should add information about that to the user guide
> as
> well).
I came across this earlier tonight
http://tynamo.org/tapestry-exceptionpage+guide and it looks like what you
refer to in 5.4 docs.
I'm using 5.4-beta-6 for my little-bootstrap-project. Making
SliderException handled by a CreateDefaultSlider page is precisely what
I'm after to get me out of little-bootstrap-project curation tasks :)
The context aware stuff looks handy for connecting to external systems, be
it email (as per example), ajax/rest responses, webrtc failures.
I'll give it a shot now and if failure, report on it tomorrow - if I
succeed I may have enough juice in the tank to respond tonight :P
Thanks for pointing it out, more terrific stuff in 5.4
Chris
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org