hello forum,
I'm playing with dynamic grid/columns but now have a problem.
My code is based on http://www.casabacdemo.com/forum/posts/list/21.page and is almost same structured and the example in the developers guide (page 64ff).
My code gets some information from a database and should generate dynamic columns according to the columns coming from the database.
If I increase the number of desired columns (example select id ... -> select id, name ....) then it works well and a new grid with new columns is being generated. But if I decrease the number of columns, the application crushes with an IndexArrayOutOfBoundException. BUT if I refresh the applet or the preview in the Layout designer the new grid gets properly displayed.
The IndexArrayOutOfBoundException is not coming from the server but from the client.
So, any ideas ?
regards
build Grid Code:
Code:
private void buildGrid(){
getData(); //load Data from DB
m_rowComponent.getChildren().clear();
// create fix grid
FIXGRIDComponentTag fgTag = new FIXGRIDComponentTag();
fgTag.setId("FG");
fgTag.setObjectbinding("#{MyBean.rows}");
fgTag.setSbvisibleamount("25");
fgTag.setBorder("true");
fgTag.setBorderwidth("1");
fgTag.setBordercolor("#ff000f");
fgTag.setHeight("100%");
fgTag.setWidth("100%");
BaseComponent fg = fgTag.createBaseComponent();
// create columns
for (int j=0; j<columns; j++)
{
GRIDCOLComponentTag gcTag = new GRIDCOLComponentTag();
gcTag.setId("FGC"+j);
//gcTag.setText("COL"+j);
gcTag.setText(columnNames[j]);
System.out.println(" " + columnNames[j] + "|||" + j);
gcTag.setWidth(columnWidth+"%");
// create field below column
FIELDComponentTag fiTag = new FIELDComponentTag();
fiTag.setId("FIE"+j);
fiTag.setText(".{values.COL"+j+"}");
BaseComponent gc = gcTag.createBaseComponent();
gc.getChildren().add(fiTag.createBaseComponent());
fg.getChildren().add(gc);
}
m_rowComponent.getChildren().add(fg);
}
Code:
public void setRowComponent(ROWComponent rowComponent){
if (m_rowComponent == rowComponent)
return;
m_rowComponent = rowComponent;
buildGrid();
}
Code:
public ROWComponent getRowComponent(){
return m_rowComponent;
}
Code:
public void onDoIt(ActionEvent event) {
buildGrid();
}
Exception:
Error occurred within the client processing.
Please view the stack trace below and the client log for more information.
java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException: 1
at org.eclnt.client.elements.PageParserUpdate.applyXML(PageParserUpdate.java:175)
at org.eclnt.client.page.Page.processUpdateResponse(Page.java:544)
at org.eclnt.client.page.Page.access$2(Page.java:52
at org.eclnt.client.page.Page$MyUpdateDataTransferListener.dataTransferEnded(Page.java:97)
at org.eclnt.client.comm.http.DataTransfer.transferXMLFinished(DataTransfer.java:342)
at org.eclnt.client.comm.http.DataTransfer.communicateToServerSynchronous(DataTransfer.java:115)
at org.eclnt.client.page.Page.callServerRun(Page.java:452)
at org.eclnt.client.page.Page$CallServerRunner.run(Page.java:59)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException: 1
at org.eclnt.client.elements.PageParserUpdate.mergeElementsWithPseudoElement(PageParserUpdate.java:300)
at org.eclnt.client.elements.PageParserUpdate.applyXML(PageParserUpdate.java:170)
... 15 more
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException: 1
at org.eclnt.client.elements.PageParserUpdate.mergeElementsWithPseudoElement(PageParserUpdate.java:300)
at org.eclnt.client.elements.PageParserUpdate.mergeElementsWithPseudoElement(PageParserUpdate.java:227)
... 16 more
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException: 1
at org.eclnt.client.elements.PageParserUpdate.mergeElementsWithPseudoElement(PageParserUpdate.java:300)
at org.eclnt.client.elements.PageParserUpdate.mergeElementsWithPseudoElement(PageParserUpdate.java:227)
... 17 more
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException: 1
at org.eclnt.client.elements.PageParserUpdate.mergeElementsWithPseudoElement(PageParserUpdate.java:300)
at org.eclnt.client.elements.PageParserUpdate.mergeElementsWithPseudoElement(PageParserUpdate.java:227)
... 18 more
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException: 1
at org.eclnt.client.elements.PageParserUpdate.mergeElementsWithPseudoElement(PageParserUpdate.java:300)
at org.eclnt.client.elements.PageParserUpdate.mergeElementsWithPseudoElement(PageParserUpdate.java:227)
... 19 more
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException: 1
at org.eclnt.client.elements.PageParserUpdate.mergeElementsWithPseudoElement(PageParserUpdate.java:300)
at org.eclnt.client.elements.PageParserUpdate.mergeElementsWithPseudoElement(PageParserUpdate.java:227)
... 20 more
Caused by: java.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException: 1
at org.eclnt.client.elements.PageParserUpdate.mergeElementsWithPseudoElement(PageParserUpdate.java:300)
at org.eclnt.client.elements.PageParserUpdate.mergeElementsWithPseudoElement(PageParserUpdate.java:227)
... 21 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
at org.eclnt.client.controls.layout.FlexGridLayout.layoutContainer(FlexGridLayout.java:193)
at org.eclnt.client.elements.impl.FIXGRIDElement.handleChangeOfControlSize(FIXGRIDElement.java:494)
at org.eclnt.client.elements.PageElement.notifyChangeOfControlSize(PageElement.java:387)
at org.eclnt.client.elements.PageElement.notifyChangeOfControlSize(PageElement.java:395)
at org.eclnt.client.elements.PageElement.notifyChangeOfControlSize(PageElement.java:395)
at org.eclnt.client.elements.PageElementColumn.applyComponentData(PageElementColumn.java:426)
at org.eclnt.client.elements.impl.GRIDHEADERLABELElement.applyComponentData(GRIDHEADERLABELElement.java:116)
at org.eclnt.client.elements.PageElement.applyComponentDataIC(PageElement.java:300)
at org.eclnt.client.elements.PageParserUpdate.mergeElementsWithPseudoElement(PageParserUpdate.java:279)
... 22 more