private void addCharts ( PageParameters parameters ) { List < Chart > charts = getChartFromParams ( parameters ) ; //If we have more than one chart - use SmallComponents if ( charts . size ( ) > 1 ) { List < SmallChartComponent > components = new ArrayList <> ( ) ; for ( Chart i : charts ) { components . add ( new SmallChartComponent ( i ) ) ; } add ( new ListView < SmallChartComponent > ( "components" , components ) { protected void populateItem ( ListItem item ) { item . add ( ( SmallChartComponent ) item . getModelObject ( ) ) ; } } ) ; } else { //else use the regular full-width chart component List < ChartComponent > components = new ArrayList <> ( ) ; for ( Chart i : charts ) { components . add ( new ChartComponent ( i ) ) ; } add ( new ListView < ChartComponent > ( "components" , components ) { protected void populateItem ( ListItem item ) { item . add ( ( ChartComponent ) item . getModelObject ( ) ) ; } } ) ; } //Add Code Components List < CodeComponent > code_components = new ArrayList <> ( ) ; for ( Chart i : charts ) { code_components . add ( new CodeComponent ( i ) ) ; } add ( new ListView < CodeComponent > ( "code_components" , code_components ) { protected void populateItem ( ListItem item ) { item . add ( ( CodeComponent ) item . getModelObject ( ) ) ; } } ) ; }
Gets the charts and the code containers from the page parameters constructs Wicket componenets from them and adds them to a Wicket ListView .