As a follow-up: How can the Http Error code then be checked using WicketTester?
Currently, after your suggested change, the browser shows my 404 page
and status is 404, but in WicketTester, I get

In MyPage.java:

    @Override
    protected void onInitialize() {
        super.onInitialize();
        throw new
AbortWithHttpErrorCodeException(HttpServletResponse.SC_NOT_FOUND);
    }

In Test:

        TESTER_SCOPE.getTester().startPage(MyPage.class);
        
assertThat(TESTER_SCOPE.getTester().getResponse().getStatus()).isEqualTo(HttpServletResponse.SC_NOT_FOUND);

org.junit.ComparisonFailure:
Expected :404
Actual   :200

The Exception is thrown by the Page class in the test (as I see in the
debugger).

On Wed, Sep 10, 2014 at 3:09 PM, Martin Grigorov <mgrigo...@apache.org> wrote:
> Just throw AbortWithHttpErrorCodeException.
> The url will remain the same.
>
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>
> On Wed, Sep 10, 2014 at 3:43 PM, Thibault Kruse <tibokr...@googlemail.com>
> wrote:
>
>> Hi,
>>
>> we have a page for some resource mounted at /resource/<id>
>> When users enter an invalid ID, we want to render a 404 page.
>> However, we would like the resulting page not have the original url
>> with the invalid id (but http status 404).
>>
>> Is there any obvious easy way to achieve this? Because it seems the
>> general way in wicket tutorials on 404 pages seem to rely on
>> redirecting to a mounted 404 resource, which means the browser will
>> not display the original invalid URL.
>>
>> cheers,
>>   Thibault
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> For additional commands, e-mail: users-h...@wicket.apache.org
>>
>>

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

Reply via email to