Hi,

On Wed, Apr 24, 2019 at 8:14 PM Sibgha Nazir <sibgha...@gmail.com> wrote:

> I make the call like this
>
>     @Override
>
>     *public* *void* renderHead(IHeaderResponse response)
>
>     {
>
>         *super*.renderHead(response);
>
>
>
>         Optional<AjaxRequestTarget> target = RequestCycle.*get*
> ().find(AjaxRequestTarget.*class*);
>
>
>         *if* (!target.equals(Optional.*empty*()))
>

You can use target.isPresent()


>
>             renderChart(target.get());
>
>     }
>

You are trying to update a component after the rendering process has been
started.
As the exception message tries to explain this is not allowed.

Wicket request cycle is split in two phases - the action phase and the
render phase.
The action phase is when a callback method like onClick, onUpdate, onXyz is
called. Here you can manipulate the component tree in any ways.
Once the action phase is finished Wicket starts rendering - the complete
page for non-Ajax requests or only the components added to
AjaxRequestTarget for the Ajax ones.
It works fine in the first request because it is a non-Ajax one and
RequestCycle.find(AjaxRequestTarget) returns an empty Optional, so nothing
is being done there.

You need to move this code either to the action phase or to onConfigure()


>
> On Wed, Apr 24, 2019 at 7:00 PM Martin Grigorov <mgrigo...@apache.org>
> wrote:
>
> > Hi,
> >
> > On Wed, Apr 24, 2019 at 5:08 PM Sibgha Nazir <sibgha...@gmail.com>
> wrote:
> >
> > > Hello wicket developer,
> > >
> > > I am facing the following exception on re-rendering a wicket panel
> using
> > > the code
> > >
> > >
> > >
> > >           iPartialPageRequestHandler.add(chartPanel);
> > >
> >
> > In which method of your code do you make that call ?
> > How do you get a reference to iPartialPageRequestHandler? Is it passed
> as a
> > parameter to the method by Wicket or do you look it up by using
> > RequestCycle.find(Class) ?
> >
> >
> > >
> > > java.lang.IllegalStateException: A partial update of the page is being
> > > rendered, component [ChartPanel [Component id = chart-container]] can
> no
> > > longer be added
> > >
> > > It renders it perfectly the first time. But I want to call this again
> and
> > > again when user clicks refresh button. What does this mean?
> > >
> > > Best Regards,
> > > Sibgha Nazir
> > >
> >
>

Reply via email to