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/29 11:53:44 UTC

Loadable Detachable Model on button click and not before

Hi,

I have the following code:


*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*);

    }

*ChartPanel*


 *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);

    }


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?

Re: Loadable Detachable Model on button click and not before

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

Please create a quickstart application as Sven asked you few days ago.
It is not easy to understand your question. May be the code will make it
more clear.

On Tue, Apr 30, 2019 at 10:31 AM Sibgha Nazir <si...@gmail.com> wrote:

> Hi,
>
> Following up on my question. I cant find the solution on the internet.
>
> Best Regards,
> Sibgha
>
> On Mon, Apr 29, 2019 at 1:53 PM Sibgha Nazir <si...@gmail.com> wrote:
>
> > Hi,
> >
> > I have the following code:
> >
> >
> > *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*);
> >
> >     }
> >
> > *ChartPanel*
> >
> >
> >  *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);
> >
> >     }
> >
> >
> > 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?
> >
>

Re: Loadable Detachable Model on button click and not before

Posted by Sibgha Nazir <si...@gmail.com>.
Hi,

Following up on my question. I cant find the solution on the internet.

Best Regards,
Sibgha

On Mon, Apr 29, 2019 at 1:53 PM Sibgha Nazir <si...@gmail.com> wrote:

> Hi,
>
> I have the following code:
>
>
> *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*);
>
>     }
>
> *ChartPanel*
>
>
>  *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);
>
>     }
>
>
> 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?
>