Hi,
We have a situation as follows:
There's a page that holds (besides other things) two charts that are
generated by JFreechart.
The chart is in a styled panel. Everything is OK.
The chart may take some time to be generated so I put it in
AjaxLazyLoadPanel.
We also let the user decide if to show the chart when entering the page
(it's our portal page).

My question is, after this long introduction, about replacing panels.
Here's what I did:
This is the link:
        final AjaxLink enableDisableLink = new AjaxLink("enableDisableLink")
{
            private static final long serialVersionUID = 1L;

            @Override
            public void onClick(AjaxRequestTarget target) {
                sageDal.setPreference(PortalSession.get().getPersonId(),
"ChartSectionPanel",
                        ChartSectionPanel.this.titleKey, new String[] {
String.valueOf(!chartEnabled()) });
                target.addComponent(enableDisableImage);
///////////////////////////////////////// Why is that working ?
                final Panel chartArea = newChartAreaPanel("chartArea");
                ChartSectionPanel.this.replace(chartArea);
                target.addComponent(chartArea);
//////////////////// replacing and refreshing the same component?

            }

And this is the method for creating the chart:
    private Panel newChartAreaPanel(String id) {
        final Panel chartArea;
        if (chartEnabled()) {
            chartArea = new AjaxLazyLoadPanel(id) {
                private static final long serialVersionUID = 1L;

                @Override
                public Component getLazyLoadComponent(String markupId) {
                    return (new ChartPanel(markupId, chartCreator,
ChartSectionPanel.this.titleKey));
                }

            };
        } else {
            chartArea = new EmptyPanel(id);
        }
        chartArea.setOutputMarkupId(true);
        return chartArea;

    }

Everything works OK.
Please take a look at the remarks above I made .///////////////////////
I just want to be sure that this is the correct / better way.

Thanks

Eyal Golan
egola...@gmail.com

Visit: http://jvdrums.sourceforge.net/
LinkedIn: http://www.linkedin.com/in/egolan74

P  Save a tree. Please don't print this e-mail unless it's really necessary

Reply via email to