[Logo] Enterprise Client Community
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
dynamic grid / columns  XML
Forum Index -> Development
Author Message
bodis

Active

Joined: 04/04/2008 10:30:30
Messages: 8
Offline

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
 
CaptainCasa

Power User
[Avatar]

Joined: 21/11/2007 12:23:06
Messages: 5520
Offline

Hi,

could you try the following:

Instead of...
Code:
     	// create fix grid
          FIXGRIDComponentTag fgTag = new FIXGRIDComponentTag();
          
          fgTag.setId("FG");
          fgTag.setObjectbinding("#{MyBean.rows}");
 


...do:
Code:
     	// create fix grid
          FIXGRIDComponentTag fgTag = new FIXGRIDComponentTag();
          
          fgTag.setObjectbinding("#{MyBean.rows}");
 


I.e. do not assign the same id once again to the grid. (You do not have to define an id at all - if you do not define one, it will be generated automatically, every time a new one of course).

Please feed back if this is the "solution". Thanks.

Björn

Björn Müller, CaptainCasa GmbH
bodis

Active

Joined: 04/04/2008 10:30:30
Messages: 8
Offline

yes this is the solution ... thanks

Although its strange that, when incresing the number of columns, it works.
CaptainCasa

Power User
[Avatar]

Joined: 21/11/2007 12:23:06
Messages: 5520
Offline

...well, yes (I do not bore you with the internal reason...).

What we proposed to you is more a "bypass" than a "solution" (+ it is specific to the FIXGRID component). First thing: we 'll point this out within the documentation, and then provide a cleaner solution.

Thanks + regards! Björn

Björn Müller, CaptainCasa GmbH
bodis

Active

Joined: 04/04/2008 10:30:30
Messages: 8
Offline

hello forum,

I have a new problem with dynamic columns.
It seems that I have some sort of "ghost" columns.

If I change the width of a column and then generate a new FIXGRID with less columns, there's some sort of ghost column. Maybe the fixgrid is not rendered properly, although I clear the row (that contains the dynamic grid) before rebuilding the grid) ?
Or maybe the grid isnt cleared at all ?

If I don't change the width it works well !

Here some pics:


now change the width of a column



now generate new FIXGRID with less columns. Note that the width of column 3 ist the same as from the bigger FIXGrid before. But it should have been rebuild.



here my buildGrid() method (almost the same as above)

private void buildGrid(){
int i = 0;
m_rowComponent.getChildren().clear();

FIXGRIDComponentTag fgTag = new FIXGRIDComponentTag();
fgTag.setObjectbinding("#{MyBean.rows}");
fgTag.setSbvisibleamount("10");
fgTag.setWidth("100%");
fgTag.setHeight("100%");
BaseComponent fg = fgTag.createBaseComponent();
m_rowComponent.getChildren().add(fg);

while(i < m_counter){

GRIDCOLComponentTag gcTag = new GRIDCOLComponentTag();
gcTag.setText("col ["+i+"]");
gcTag.setWidth(100/m_counter+"%");
gcTag.setHeight("20");
gcTag.setFont("weight:bold;align:center");

FIELDComponentTag fiTag = new FIELDComponentTag();
fiTag.setHeight("20");
fiTag.setText(".{values.COL"+i+"}");
BaseComponent gc = gcTag.createBaseComponent();
gc.getChildren().add(fiTag.createBaseComponent());
fg.getChildren().add(gc);

i++;
}


CaptainCasa

Power User
[Avatar]

Joined: 21/11/2007 12:23:06
Messages: 5520
Offline

Hi,

this has to do with the internal keeping of modified widths.

Could you please call the FIXGRIDListBinding's method:

Code:
 FIXGRIDListBinding.setModcolumnswidths(null);
 


when updating the grid's column structure.

I have not checked everything, so I hope this does not cause a null pointer...

Björn

PS: thanks for isolating the code in this perfect way...!

Björn Müller, CaptainCasa GmbH
bodis

Active

Joined: 04/04/2008 10:30:30
Messages: 8
Offline

perfect !

This was it. So before rebuilding I had to clear up the rows properties. It's not sufficient to clear the rowComponent.

very thanks !
CaptainCasa

Power User
[Avatar]

Joined: 21/11/2007 12:23:06
Messages: 5520
Offline

good..!

BTW: I could imagine the same happens with column sequence (user dragging & dropping columns...).
There is a method setModcolumnsequence() as well, which then also should be passed a null value.

Björn

Björn Müller, CaptainCasa GmbH
bodis

Active

Joined: 04/04/2008 10:30:30
Messages: 8
Offline

yes I already applied that
 
Forum Index -> Development
Go to:   
Powered by JForum 2.1.6 © JForum Team