I am trying to use the above code and I getting this error:
Non-static method 'getPage()' cannot be referenced from a static context.
my wicket version is 8.9.0.

On Tue, Jun 29, 2021 at 9:54 PM Sven Meier <s...@meiers.net> wrote:

> Hi,
>
> instead of worrying about exceptions in your #onSubmit() and always
> wrapping your code in catch-try, you can just use a general exception
> handler:
>
>      getRequestCycleListeners().add(new IRequestCycleListener()
>          {
>              @Override
>              public IRequestHandler onException(RequestCycle cycle,
> Exception ex)
>              {
>                  MyCustomValidationException validation =
> Exceptions.findCause(ex, MyCustomValidationException.class);
>                  if (validation != null) {
>                      Page page =
> IPageRequestHandler.getPage(cycle.getActiveRequestHandler())
>                      if (page != null) {
>                          // add error messages ...
> page.error(page.getString(validation.getCode()));
>                          return new RenderPageRequestHandler(page);
>                      }
>                  }
>                  return null;
>              }
>          });
>
> Hope this helps
> Sven
>
>
> On 29.06.21 18:41, vahid ghasemi wrote:
> > thanks again for answering my questions.
> > can you send me some examples of this concept?
> > (IRequestCycleListener#onException())
> > just I want to know more about that.
> >
> > On Tue, Jun 29, 2021 at 8:32 PM Sven Meier <s...@meiers.net> wrote:
> >
> >> Hi,
> >>
> >> you could use a FormValidator.
> >>
> >> Or let your onSubmit() (or any code it forwards to) throw exceptions and
> >> register an IRequestCycleListener#onException() to handle exceptions
> >> during form submit.
> >>
> >> Have fun
> >> Sven
> >>
> >>
> >> On 29.06.21 17:51, vahid ghasemi wrote:
> >>> I want to add form data to the database.
> >>> so it's not good to loading data for every input and checks from the
> >>> database.
> >>> I am using validation and when everything is ok then I connect to the
> >>> database for better performance :).
> >>> one Idea is to call the onError method into the onSubmit method. but I
> >> want
> >>> to know is a better way to handle this situation?
> >>>
> >>> On Tue, Jun 29, 2021 at 8:11 PM Maxim Solodovnik <solomax...@gmail.com
> >
> >>> wrote:
> >>>
> >>>> Maybe it would be better to perform checks during validation ?
> >>>>
> >>>> from mobile (sorry for typos ;)
> >>>>
> >>>>
> >>>> On Tue, Jun 29, 2021, 22:33 vahid ghasemi <vahidghasemi...@gmail.com>
> >>>> wrote:
> >>>>
> >>>>> Hello
> >>>>> How can I pass an error in an onSubmit method?
> >>>>> I have some errors that can detect in the onSubmit method.
> >>>>> I throw exceptions at end of the onSubmit method.
> >>>>> In the catch block, I call the error method, but after that, I expect
> >> to
> >>>>> don't go into the afterOnSubmit method, but he will go and I am
> getting
> >>>>> the wrong response.
> >>>>>
> >> ---------------------------------------------------------------------
> >> 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