Unable to navigate to onError outcome during query-param validation

Splash Forums PrettyFaces Users Unable to navigate to onError outcome during query-param validation

This topic contains 0 replies, has 1 voice, and was last updated by  weljoweb 6 years, 2 months ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #17998

    weljoweb
    Participant

    I’m trying to navigate to a JSF view when there is an error in validation, without the page being redirected or going to the standard 404 page. I thought I would do this by setting the attribute onError to a jsf navigation outcome. However I always get sent to the standard 404 page.

    Here are my configuration:

    pretty-faces config

    <url-mapping id=”catalog-email-detail”>

    <pattern value=”/catalog/email-detail” />

    <query-param name=”item_id”

    validator=”#{catalogParameterValidator.validateItemId}” onError=”#{catalogParameterValidator.getErrorOutcome}”>#{emailDetailBean.itemId}</query-param>

    <view-id value=”/faces/viewEmailDetail.jsf” />

    <action>#{emailDetailBean.loadPage}</action>

    </url-mapping>

    faces-config.xml

    <navigation-rule>

    <from-view-id>/faces/*</from-view-id>

    <navigation-case>

    <from-outcome>goInvalidItemPage</from-outcome>

    <to-view-id>/faces/invalidItemPage.jspx</to-view-id>

    </navigation-case>

    </navigation-rule>

    Looking at ParameterValidator.handleValidationFailure(final FacesContext context, final FacesMessage message, String onError), the process entered the following if scenario:

    if (!context.getResponseComplete() && !continueToFaces)

    {

    HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();

    try

    {

    response.sendError(HttpServletResponse.SC_NOT_FOUND);

    context.responseComplete();

    }

    catch (IOException e1)

    {

    throw new PrettyException(e1);

    }

    }

    I think continueToFaces should be set to true if handleNavigation was called and the response is not complete.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

Comments are closed.