You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Sibgha Nazir <si...@gmail.com> on 2019/04/28 19:29:20 UTC
Loadable Detachable Model not updating on re-render
Hi,
This question is related to LoadableDetachable Model.
I have a wicket panel, LearningCurveChartPanel.
*public* LearningCurveChartPanel(String aId, IModel<AnnotatorState>
aModel)
{
*super*(aId);
model = aModel;
//initially the chart is empty. passing empty model
chartPanel = *new* ChartPanel(*MID_CHART_CONTAINER*,
LoadableDetachableModel.*of*(*this*::renderChart));
chartPanel.setOutputMarkupId(*true*);
add(chartPanel);
}
@OnEvent
*public* *void* onRenderAnnotations(RenderAnnotationsEvent aEvent)
{
LOG.trace("rendered annotation event");
aEvent.getRequestHandler().add(*this*);
}
which is rendering a ChartPanel. The ChartPanel is like this
*public* ChartPanel(String aId, LoadableDetachableModel<LearningCurve>
loadableDetachableModel)
{
*super*(aId);
chartModel = (loadableDetachableModel);
chart = *new* WebMarkupContainer(*MID_CHART_CONTAINER*);
chart.setMarkupId("canvas");
chart.setOutputMarkupId(*true*);
add(chart);
chartAjaxBejavior = *new* ChartAjaxBejavior();
add(chartAjaxBejavior);
}
The chartModel has the right data and it renders correctly with the data
that is fed to it from LearningCurveChartPanel.
But when the onRenderAnnotation event of the LearningCurveChartPanel
triggers what I am trying to do is to update the (re-render) the Chart
Panel inside it. It does re-render the chart panel but the model stays the
same. I want to implement it such that the model of the ChartPanel updates
and when it re-renders it as the latest data when the onRenderAnnotation
event was triggered.
Please guide me in the right direction.
Best,
Sibgha
Re: Loadable Detachable Model not updating on re-render
Posted by Sibgha Nazir <si...@gmail.com>.
There is one more thing regarding the same code. Here I am adding
ChartPanel in the constructor of LearningCurveChartPanel and as the
LearningCurveChartPanel loads the chart panel is loaded with the data that
is returned by renderChart. I want to do such that the ChartPanel only
renders when I click a button. How do I change the below line to
chartPanel = *new* ChartPanel(*MID_CHART_CONTAINER*,
LoadableDetachableModel.*of*(*this*::renderChart));
And how do I define such thing in the onClick event?
Best,
Sibgha
On Sun, Apr 28, 2019 at 9:29 PM Sibgha Nazir <si...@gmail.com> wrote:
> Hi,
>
> This question is related to LoadableDetachable Model.
>
> I have a wicket panel, LearningCurveChartPanel.
>
> *public* LearningCurveChartPanel(String aId, IModel<AnnotatorState>
> aModel)
>
> {
>
> *super*(aId);
>
> model = aModel;
>
>
> //initially the chart is empty. passing empty model
>
> chartPanel = *new* ChartPanel(*MID_CHART_CONTAINER*,
>
> LoadableDetachableModel.*of*(*this*::renderChart));
>
>
>
> chartPanel.setOutputMarkupId(*true*);
>
> add(chartPanel);
>
> }
>
> @OnEvent
>
> *public* *void* onRenderAnnotations(RenderAnnotationsEvent aEvent)
>
> {
>
> LOG.trace("rendered annotation event");
>
>
> aEvent.getRequestHandler().add(*this*);
>
> }
>
>
> which is rendering a ChartPanel. The ChartPanel is like this
>
> *public* ChartPanel(String aId, LoadableDetachableModel<LearningCurve>
> loadableDetachableModel)
>
> {
>
> *super*(aId);
>
>
>
> chartModel = (loadableDetachableModel);
>
>
> chart = *new* WebMarkupContainer(*MID_CHART_CONTAINER*);
>
> chart.setMarkupId("canvas");
>
> chart.setOutputMarkupId(*true*);
>
> add(chart);
>
>
> chartAjaxBejavior = *new* ChartAjaxBejavior();
>
> add(chartAjaxBejavior);
>
> }
>
>
> The chartModel has the right data and it renders correctly with the data
> that is fed to it from LearningCurveChartPanel.
>
> But when the onRenderAnnotation event of the LearningCurveChartPanel
> triggers what I am trying to do is to update the (re-render) the Chart
> Panel inside it. It does re-render the chart panel but the model stays the
> same. I want to implement it such that the model of the ChartPanel updates
> and when it re-renders it as the latest data when the onRenderAnnotation
> event was triggered.
>
> Please guide me in the right direction.
>
> Best,
> Sibgha
>
>
>
>
Re: Loadable Detachable Model not updating on re-render
Posted by Sibgha Nazir <si...@gmail.com>.
I will do that. Thanks.
On Mon, Apr 29, 2019 at 9:54 AM Maxim Solodovnik <so...@gmail.com>
wrote:
> http://wicket.apache.org/start/quickstart.html
>
> And upload your project to github or some other service like this :)
>
> On Mon, 29 Apr 2019 at 14:49, Sibgha Nazir <si...@gmail.com> wrote:
>
> > How to create quick start?
> >
> > On Mon, Apr 29, 2019 at 9:39 AM Sven Meier <sv...@meiers.net> wrote:
> >
> > >
> > >
> > > Hi,
> > >
> > >
> > >
> > > that should do it, no need to call detach() for yourself.
> > >
> > >
> > >
> > > Hard to tell what's going wrong. Can you create a quickstart?
> > >
> > >
> > >
> > > Regards
> > >
> > > Sven
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > >
> > > > On 29.04.2019 at 09:16, <Sibgha Nazir> wrote:
> > > >
> > > >
> > > > Hi, I tried doing the following *public* ChartPanel(String aId,
> > > LoadableDetachableModel loadableDetachableModel) {
> > > *super*(aId*,**loadableDetachableModel*); chartModel =
> > > (loadableDetachableModel); chart = *new*
> > > WebMarkupContainer(*MID_CHART_CONTAINER*); chart.setMarkupId("canvas");
> > > chart.setOutputMarkupId(*true*); add(chart); chartAjaxBejavior = *new*
> > > ChartAjaxBejavior(); add(chartAjaxBejavior); } It still doesn't update
> > the
> > > ChartPanel with the new model when onRenderAnnotations triggers. Do I
> > have
> > > to explicitly call detach()? On Mon, Apr 29, 2019 at 7:49 AM Sven Meier
> > > wrote: > > > Hi, > > > > your chartPanel should pass the
> > > chartModel to the super constructor. The > panel takes care that the
> > > model is detached after the request. > > > > If you just hold
> > > chartModel as a member variable, no one will call > detach() on it >
> > > > > > Have fun > > Sven > > > > > > > > >
> >
> > > > > > On 28.04.2019 at 21:29, wrote: > > > >
> > > > > Hi, This question is related to LoadableDetachable Model. I
> have a
> > > > wicket panel, LearningCurveChartPanel. *public* >
> > > LearningCurveChartPanel(String aId, IModel aModel) { *super*(aId);
> model
> > =
> > > > aModel; //initially the chart is empty. passing empty model
> chartPanel
> > > = > *new* ChartPanel(*MID_CHART_CONTAINER*, >
> > > LoadableDetachableModel.*of*(*this*::renderChart)); >
> > > chartPanel.setOutputMarkupId(*true*); add(chartPanel); } @OnEvent
> > *public*
> > > > *void* onRenderAnnotations(RenderAnnotationsEvent aEvent) { >
> > > LOG.trace("rendered annotation event"); >
> > > aEvent.getRequestHandler().add(*this*); } which is rendering a
> > ChartPanel.
> > > > The ChartPanel is like this *public* ChartPanel(String aId, >
> > > LoadableDetachableModel loadableDetachableModel) { *super*(aId);
> > > chartModel > = (loadableDetachableModel); chart = *new* >
> > > WebMarkupContainer(*MID_CHART_CONTAINER*); chart.setMarkupId("canvas");
> > >
> > > chart.setOutputMarkupId(*true*); add(chart); chartAjaxBejavior =
> *new* >
> > > Char
> > > tAjaxBejavior(); add(chartAjaxBejavior); } The chartModel has > the
> > > right data and it renders correctly with the data that is fed to it >
> > > from LearningCurveChartPanel. But when the onRenderAnnotation event of
> > the
> > > > LearningCurveChartPanel triggers what I am trying to do is to update
> > > the > (re-render) the Chart Panel inside it. It does re-render the
> > chart
> > > panel > but the model stays the same. I want to implement it such
> that
> > > the model of > the ChartPanel updates and when it re-renders it as
> the
> > > latest data when > the onRenderAnnotation event was triggered. Please
> > > guide me in the right > direction. Best, Sibgha > > >
> > > >
> > >
> >
>
>
> --
> WBR
> Maxim aka solomax
>
Re: Loadable Detachable Model not updating on re-render
Posted by Maxim Solodovnik <so...@gmail.com>.
http://wicket.apache.org/start/quickstart.html
And upload your project to github or some other service like this :)
On Mon, 29 Apr 2019 at 14:49, Sibgha Nazir <si...@gmail.com> wrote:
> How to create quick start?
>
> On Mon, Apr 29, 2019 at 9:39 AM Sven Meier <sv...@meiers.net> wrote:
>
> >
> >
> > Hi,
> >
> >
> >
> > that should do it, no need to call detach() for yourself.
> >
> >
> >
> > Hard to tell what's going wrong. Can you create a quickstart?
> >
> >
> >
> > Regards
> >
> > Sven
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > >
> > > On 29.04.2019 at 09:16, <Sibgha Nazir> wrote:
> > >
> > >
> > > Hi, I tried doing the following *public* ChartPanel(String aId,
> > LoadableDetachableModel loadableDetachableModel) {
> > *super*(aId*,**loadableDetachableModel*); chartModel =
> > (loadableDetachableModel); chart = *new*
> > WebMarkupContainer(*MID_CHART_CONTAINER*); chart.setMarkupId("canvas");
> > chart.setOutputMarkupId(*true*); add(chart); chartAjaxBejavior = *new*
> > ChartAjaxBejavior(); add(chartAjaxBejavior); } It still doesn't update
> the
> > ChartPanel with the new model when onRenderAnnotations triggers. Do I
> have
> > to explicitly call detach()? On Mon, Apr 29, 2019 at 7:49 AM Sven Meier
> > wrote: > > > Hi, > > > > your chartPanel should pass the
> > chartModel to the super constructor. The > panel takes care that the
> > model is detached after the request. > > > > If you just hold
> > chartModel as a member variable, no one will call > detach() on it >
> > > > > Have fun > > Sven > > > > > > > > > >
> > > > > On 28.04.2019 at 21:29, wrote: > > > >
> > > > Hi, This question is related to LoadableDetachable Model. I have a
> > > wicket panel, LearningCurveChartPanel. *public* >
> > LearningCurveChartPanel(String aId, IModel aModel) { *super*(aId); model
> =
> > > aModel; //initially the chart is empty. passing empty model chartPanel
> > = > *new* ChartPanel(*MID_CHART_CONTAINER*, >
> > LoadableDetachableModel.*of*(*this*::renderChart)); >
> > chartPanel.setOutputMarkupId(*true*); add(chartPanel); } @OnEvent
> *public*
> > > *void* onRenderAnnotations(RenderAnnotationsEvent aEvent) { >
> > LOG.trace("rendered annotation event"); >
> > aEvent.getRequestHandler().add(*this*); } which is rendering a
> ChartPanel.
> > > The ChartPanel is like this *public* ChartPanel(String aId, >
> > LoadableDetachableModel loadableDetachableModel) { *super*(aId);
> > chartModel > = (loadableDetachableModel); chart = *new* >
> > WebMarkupContainer(*MID_CHART_CONTAINER*); chart.setMarkupId("canvas");
> >
> > chart.setOutputMarkupId(*true*); add(chart); chartAjaxBejavior = *new* >
> > Char
> > tAjaxBejavior(); add(chartAjaxBejavior); } The chartModel has > the
> > right data and it renders correctly with the data that is fed to it >
> > from LearningCurveChartPanel. But when the onRenderAnnotation event of
> the
> > > LearningCurveChartPanel triggers what I am trying to do is to update
> > the > (re-render) the Chart Panel inside it. It does re-render the
> chart
> > panel > but the model stays the same. I want to implement it such that
> > the model of > the ChartPanel updates and when it re-renders it as the
> > latest data when > the onRenderAnnotation event was triggered. Please
> > guide me in the right > direction. Best, Sibgha > > >
> > >
> >
>
--
WBR
Maxim aka solomax
Re: Loadable Detachable Model not updating on re-render
Posted by Sibgha Nazir <si...@gmail.com>.
How to create quick start?
On Mon, Apr 29, 2019 at 9:39 AM Sven Meier <sv...@meiers.net> wrote:
>
>
> Hi,
>
>
>
> that should do it, no need to call detach() for yourself.
>
>
>
> Hard to tell what's going wrong. Can you create a quickstart?
>
>
>
> Regards
>
> Sven
>
>
>
>
>
>
>
>
>
>
> >
> > On 29.04.2019 at 09:16, <Sibgha Nazir> wrote:
> >
> >
> > Hi, I tried doing the following *public* ChartPanel(String aId,
> LoadableDetachableModel loadableDetachableModel) {
> *super*(aId*,**loadableDetachableModel*); chartModel =
> (loadableDetachableModel); chart = *new*
> WebMarkupContainer(*MID_CHART_CONTAINER*); chart.setMarkupId("canvas");
> chart.setOutputMarkupId(*true*); add(chart); chartAjaxBejavior = *new*
> ChartAjaxBejavior(); add(chartAjaxBejavior); } It still doesn't update the
> ChartPanel with the new model when onRenderAnnotations triggers. Do I have
> to explicitly call detach()? On Mon, Apr 29, 2019 at 7:49 AM Sven Meier
> wrote: > > > Hi, > > > > your chartPanel should pass the
> chartModel to the super constructor. The > panel takes care that the
> model is detached after the request. > > > > If you just hold
> chartModel as a member variable, no one will call > detach() on it >
> > > > Have fun > > Sven > > > > > > > > > >
> > > > On 28.04.2019 at 21:29, wrote: > > > >
> > > Hi, This question is related to LoadableDetachable Model. I have a
> > wicket panel, LearningCurveChartPanel. *public* >
> LearningCurveChartPanel(String aId, IModel aModel) { *super*(aId); model =
> > aModel; //initially the chart is empty. passing empty model chartPanel
> = > *new* ChartPanel(*MID_CHART_CONTAINER*, >
> LoadableDetachableModel.*of*(*this*::renderChart)); >
> chartPanel.setOutputMarkupId(*true*); add(chartPanel); } @OnEvent *public*
> > *void* onRenderAnnotations(RenderAnnotationsEvent aEvent) { >
> LOG.trace("rendered annotation event"); >
> aEvent.getRequestHandler().add(*this*); } which is rendering a ChartPanel.
> > The ChartPanel is like this *public* ChartPanel(String aId, >
> LoadableDetachableModel loadableDetachableModel) { *super*(aId);
> chartModel > = (loadableDetachableModel); chart = *new* >
> WebMarkupContainer(*MID_CHART_CONTAINER*); chart.setMarkupId("canvas"); >
> chart.setOutputMarkupId(*true*); add(chart); chartAjaxBejavior = *new* >
> Char
> tAjaxBejavior(); add(chartAjaxBejavior); } The chartModel has > the
> right data and it renders correctly with the data that is fed to it >
> from LearningCurveChartPanel. But when the onRenderAnnotation event of the
> > LearningCurveChartPanel triggers what I am trying to do is to update
> the > (re-render) the Chart Panel inside it. It does re-render the chart
> panel > but the model stays the same. I want to implement it such that
> the model of > the ChartPanel updates and when it re-renders it as the
> latest data when > the onRenderAnnotation event was triggered. Please
> guide me in the right > direction. Best, Sibgha > > >
> >
>
Re: Loadable Detachable Model not updating on re-render
Posted by Sibgha Nazir <si...@gmail.com>.
Hi,
I tried doing the following
*public* ChartPanel(String aId, LoadableDetachableModel<LearningCurve>
loadableDetachableModel)
{
*super*(aId*,**loadableDetachableModel*);
chartModel = (loadableDetachableModel);
chart = *new* WebMarkupContainer(*MID_CHART_CONTAINER*);
chart.setMarkupId("canvas");
chart.setOutputMarkupId(*true*);
add(chart);
chartAjaxBejavior = *new* ChartAjaxBejavior();
add(chartAjaxBejavior);
}
It still doesn't update the ChartPanel with the new model when
onRenderAnnotations triggers. Do I have to explicitly call detach()?
On Mon, Apr 29, 2019 at 7:49 AM Sven Meier <sv...@meiers.net> wrote:
>
>
> Hi,
>
>
>
> your chartPanel should pass the chartModel to the super constructor. The
> panel takes care that the model is detached after the request.
>
>
>
> If you just hold chartModel as a member variable, no one will call
> detach() on it
>
>
>
> Have fun
>
> Sven
>
>
>
>
>
>
>
>
>
> >
> > On 28.04.2019 at 21:29, <Sibgha Nazir> wrote:
> >
> >
> > Hi, This question is related to LoadableDetachable Model. I have a
> wicket panel, LearningCurveChartPanel. *public*
> LearningCurveChartPanel(String aId, IModel aModel) { *super*(aId); model =
> aModel; //initially the chart is empty. passing empty model chartPanel =
> *new* ChartPanel(*MID_CHART_CONTAINER*,
> LoadableDetachableModel.*of*(*this*::renderChart));
> chartPanel.setOutputMarkupId(*true*); add(chartPanel); } @OnEvent *public*
> *void* onRenderAnnotations(RenderAnnotationsEvent aEvent) {
> LOG.trace("rendered annotation event");
> aEvent.getRequestHandler().add(*this*); } which is rendering a ChartPanel.
> The ChartPanel is like this *public* ChartPanel(String aId,
> LoadableDetachableModel loadableDetachableModel) { *super*(aId); chartModel
> = (loadableDetachableModel); chart = *new*
> WebMarkupContainer(*MID_CHART_CONTAINER*); chart.setMarkupId("canvas");
> chart.setOutputMarkupId(*true*); add(chart); chartAjaxBejavior = *new*
> ChartAjaxBejavior(); add(chartAjaxBejavior); } The chartModel has
> the right data and it renders correctly with the data that is fed to it
> from LearningCurveChartPanel. But when the onRenderAnnotation event of the
> LearningCurveChartPanel triggers what I am trying to do is to update the
> (re-render) the Chart Panel inside it. It does re-render the chart panel
> but the model stays the same. I want to implement it such that the model of
> the ChartPanel updates and when it re-renders it as the latest data when
> the onRenderAnnotation event was triggered. Please guide me in the right
> direction. Best, Sibgha
> >
>
Re: Loadable Detachable Model not updating on re-render
Posted by Sven Meier <sv...@meiers.net>.
Hi,
that should do it, no need to call detach() for yourself.
Hard to tell what's going wrong. Can you create a quickstart?
Regards
Sven
>
> On 29.04.2019 at 09:16, <Sibgha Nazir> wrote:
>
>
> Hi, I tried doing the following *public* ChartPanel(String aId, LoadableDetachableModel loadableDetachableModel) { *super*(aId*,**loadableDetachableModel*); chartModel = (loadableDetachableModel); chart = *new* WebMarkupContainer(*MID_CHART_CONTAINER*); chart.setMarkupId("canvas"); chart.setOutputMarkupId(*true*); add(chart); chartAjaxBejavior = *new* ChartAjaxBejavior(); add(chartAjaxBejavior); } It still doesn't update the ChartPanel with the new model when onRenderAnnotations triggers. Do I have to explicitly call detach()? On Mon, Apr 29, 2019 at 7:49 AM Sven Meier wrote: > > > Hi, > > > > your chartPanel should pass the chartModel to the super constructor. The > panel takes care that the model is detached after the request. > > > > If you just hold chartModel as a member variable, no one will call > detach() on it > > > > Have fun > > Sven > > > > > > > > > > > > > On 28.04.2019 at 21:29, wrote: > > > >
> > Hi, This question is related to LoadableDetachable Model. I have a > wicket panel, LearningCurveChartPanel. *public* > LearningCurveChartPanel(String aId, IModel aModel) { *super*(aId); model = > aModel; //initially the chart is empty. passing empty model chartPanel = > *new* ChartPanel(*MID_CHART_CONTAINER*, > LoadableDetachableModel.*of*(*this*::renderChart)); > chartPanel.setOutputMarkupId(*true*); add(chartPanel); } @OnEvent *public* > *void* onRenderAnnotations(RenderAnnotationsEvent aEvent) { > LOG.trace("rendered annotation event"); > aEvent.getRequestHandler().add(*this*); } which is rendering a ChartPanel. > The ChartPanel is like this *public* ChartPanel(String aId, > LoadableDetachableModel loadableDetachableModel) { *super*(aId); chartModel > = (loadableDetachableModel); chart = *new* > WebMarkupContainer(*MID_CHART_CONTAINER*); chart.setMarkupId("canvas"); > chart.setOutputMarkupId(*true*); add(chart); chartAjaxBejavior = *new* > Char
tAjaxBejavior(); add(chartAjaxBejavior); } The chartModel has > the right data and it renders correctly with the data that is fed to it > from LearningCurveChartPanel. But when the onRenderAnnotation event of the > LearningCurveChartPanel triggers what I am trying to do is to update the > (re-render) the Chart Panel inside it. It does re-render the chart panel > but the model stays the same. I want to implement it such that the model of > the ChartPanel updates and when it re-renders it as the latest data when > the onRenderAnnotation event was triggered. Please guide me in the right > direction. Best, Sibgha > > >
>
Re: Loadable Detachable Model not updating on re-render
Posted by Sven Meier <sv...@meiers.net>.
Hi,
your chartPanel should pass the chartModel to the super constructor. The panel takes care that the model is detached after the request.
If you just hold chartModel as a member variable, no one will call detach() on it
Have fun
Sven
>
> On 28.04.2019 at 21:29, <Sibgha Nazir> wrote:
>
>
> Hi, This question is related to LoadableDetachable Model. I have a wicket panel, LearningCurveChartPanel. *public* LearningCurveChartPanel(String aId, IModel aModel) { *super*(aId); model = aModel; //initially the chart is empty. passing empty model chartPanel = *new* ChartPanel(*MID_CHART_CONTAINER*, LoadableDetachableModel.*of*(*this*::renderChart)); chartPanel.setOutputMarkupId(*true*); add(chartPanel); } @OnEvent *public* *void* onRenderAnnotations(RenderAnnotationsEvent aEvent) { LOG.trace("rendered annotation event"); aEvent.getRequestHandler().add(*this*); } which is rendering a ChartPanel. The ChartPanel is like this *public* ChartPanel(String aId, LoadableDetachableModel loadableDetachableModel) { *super*(aId); chartModel = (loadableDetachableModel); chart = *new* WebMarkupContainer(*MID_CHART_CONTAINER*); chart.setMarkupId("canvas"); chart.setOutputMarkupId(*true*); add(chart); chartAjaxBejavior = *new* ChartAjaxBejavior(); add(chartAjaxBejavior); } The chartModel has
the right data and it renders correctly with the data that is fed to it from LearningCurveChartPanel. But when the onRenderAnnotation event of the LearningCurveChartPanel triggers what I am trying to do is to update the (re-render) the Chart Panel inside it. It does re-render the chart panel but the model stays the same. I want to implement it such that the model of the ChartPanel updates and when it re-renders it as the latest data when the onRenderAnnotation event was triggered. Please guide me in the right direction. Best, Sibgha
>