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-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to