Wicket
  1. Wicket
  2. WICKET-4103

FeedbackMessages added in IRequestCycleListener#onRequestHandlerExecuted do not get displayed in response page

    Details

      Description

      When adding a feedback message in IRequestCycleListener#onRequestHandlerExecuted it does not get displayed on the response page. It is also not available on subsequent requests.

      1. endrequesttest.zip
        35 kB
        Christian Huber

        Activity

        Hide
        Christian Huber added a comment -

        I had tried adding

        throw new RestartResponseException(ErrorPage.class);

        to the onrequesthandlerexecuted() callback while ErrorPage is just an empty page with empty markup and mounted at "error" (calling that page did work when the exception was not thrown) but that caused the following error:

        ERROR - DefaultExceptionMapper - Unexpected error occurred
        org.apache.wicket.RestartResponseException
        ERROR - DefaultExceptionMapper - Unexpected error occurred
        java.lang.IllegalStateException: Header was already written to response!

        throwing the exception directly in the homepage constuctor got me redirected to the error page as expected.

        would you need a new quickstart for this?

        Show
        Christian Huber added a comment - I had tried adding throw new RestartResponseException(ErrorPage.class); to the onrequesthandlerexecuted() callback while ErrorPage is just an empty page with empty markup and mounted at "error" (calling that page did work when the exception was not thrown) but that caused the following error: ERROR - DefaultExceptionMapper - Unexpected error occurred org.apache.wicket.RestartResponseException ERROR - DefaultExceptionMapper - Unexpected error occurred java.lang.IllegalStateException: Header was already written to response! throwing the exception directly in the homepage constuctor got me redirected to the error page as expected. would you need a new quickstart for this?
        Hide
        Igor Vaynberg added a comment -

        setting feedback messages in onrequesthandlerexecuted() is too late because at this point the page has been rendered.

        the messages are not available in the next request because the HomePage is stateless and does not bind the session object into http session. call session.bind() if you want to persist the session.

        if you are using this for txn then what you can do here is throw a restartresponseexception and redirect to an error page if txn commit fails.

        Show
        Igor Vaynberg added a comment - setting feedback messages in onrequesthandlerexecuted() is too late because at this point the page has been rendered. the messages are not available in the next request because the HomePage is stateless and does not bind the session object into http session. call session.bind() if you want to persist the session. if you are using this for txn then what you can do here is throw a restartresponseexception and redirect to an error page if txn commit fails.

          People

          • Assignee:
            Igor Vaynberg
            Reporter:
            Christian Huber
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development