ElementContainer base = new ElementContainer();
try
{
PortletSet portlets = getPortlets();
PortletConfig pc = portlets.getPortletConfig();
// first get the number of columns and rows to display
Enumeration en = portlets.getPortlets();
//see if any or the Portlets you want to add have a larger column or
//row number than that defined in PSML
while ( en.hasMoreElements() ) {
Portlet portlet = (Portlet)en.nextElement();
calculateControllerLayout( portlet );
}
setWidth( pc.getLayout( "width", getWidth() ) );
int rows = getRow();
int cols = getColumn();
if (0 == rows || 0 == cols)
return base; // empty container
Table t = new Table()
.setWidth( this.getWidth() )
.setCellPadding( this.getPadding() )
.setAlign("center");
base.addElement( t );
ElementContainer[][] elements = new ElementContainer[rows][cols];
for( int i = 0; i < rows; i++ ) {
for ( int j = 0 ; j < cols; j++ ) {
elements[i][j]=new ElementContainer();
}
}
// populate the elements array
en = portlets.getPortlets();
while (en.hasMoreElements() ) {
Portlet p = (Portlet)en.nextElement();
PortletConfig pConf = p.getPortletConfig();
Integer colObj = pConf.getConstraints().getColumn();
Integer rowObj = pConf.getConstraints().getRow();
int colnum = (colObj!=null)?colObj.intValue():0;
int rownum = (rowObj!=null)?rowObj.intValue():0;
elements[rownum % rows][colnum % cols]
.addElement( p.getContent( rundata ) );