[Logo] Enterprise Client Community
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
ARRAYGrid inside subclass of FIXGRIDItem does not work?  XML
Forum Index -> Development
Author Message
unger

Power User

Joined: 22/07/2008 05:19:28
Messages: 261
Offline

Hello community-members,

I have a problem using ARRAYGRID:

My Page:
Code:
 ...
 <t:arraygrid id="g_411" height="100" objectbinding="#{d.AnalyticTemplateMBean.grid}" sbvisibleamount="50" selectorcolumn="1" suppressheadline="true" usefieldforlabel="false" width="200" />
 ...
 


My managed Bean:
Code:
 public class ComponentItem extends ARRAYGRIDItem {
 		@Override
 		public void onRowDeselect() {
 			super.onRowDeselect();
 		}
 		@Override
 		public void onRowExecute() {
 			super.onRowExecute();
 		}
 	}
 
 	protected ARRAYGRIDListBinding<ComponentItem> grid = null;
 
 	public ARRAYGRIDListBinding<ComponentItem> getGrid() {
 		if (grid != null)
 			return grid;
 		grid = new ARRAYGRIDListBinding<ComponentItem>();
 		String[] titles = new String[] { "" };
 		String[] widths = new String[] { "100%" };
 		grid.setTitles(titles);
 		grid.setWidths(widths);
 
 		List<UIComponent> list = tree.getItemList();
 		for (UIComponent component : list) {
 			ComponentItem componentItem = new ComponentItem();
 			String[] columns = new String[] { component.getText() };
 			componentItem.setValues(columns);
 			grid.getItems().add(componentItem);
 		}
 		return grid;
 	}
 


All works very well, when the class definition isn't inside a FIXGRIDItem!
Now I put the class inside a subclass of FIXGRIDItem, because I need access to AnalyticQuery analyticQuery:

Code:
 public class UIQueryItem extends FIXGRIDItem {
   private AnalyticQuery analyticQuery = null;
 	public UIQueryItem(AnalyticQuery pAnalyticQuery) {
 			analyticQuery = pAnalyticQuery;
 		}
 
 		public void onToggle() {
 		}
 
 		public void onRowExecute() {
 		}
 
 		public void onRowSelect() {
 			selectedQuery = this;
 		}
 
 		public AnalyticQuery getAnalyticQuery() {
 			return analyticQuery;
 		}
 
 		public void setAnalyticQuery(AnalyticQuery analyticQuery) {
 			this.analyticQuery = analyticQuery;
 		}
 
 		public class ComponentItem extends ARRAYGRIDItem {
 			@Override
 			public void onRowDeselect() {
 				super.onRowDeselect();
 			}
 
 			@Override
 			public void onRowExecute() {
 				super.onRowExecute();
 			}
 		}
 
 		protected ARRAYGRIDListBinding<ComponentItem> grid = null;
 
 		public ARRAYGRIDListBinding<ComponentItem> getGrid() {
 			if (grid != null)
 				return grid;
 			grid = new ARRAYGRIDListBinding<ComponentItem>();
 			String[] titles = new String[] { "" };
 			String[] widths = new String[] { "100%" };
 			grid.setTitles(titles);
 			grid.setWidths(widths);
 
 			List<UIComponent> list = tree.getItemList();
 			for (UIComponent component : list) {
 				ComponentItem componentItem = new ComponentItem();
 				String[] columns = new String[] { component.getText() };
 				componentItem.setValues(columns);
 				grid.getItems().add(componentItem);
 			}
 			return grid;
 		}
 	}
 


Nothing changed but the JSP binding:

Code:
 <t:arraygrid id="g_411" height="100" objectbinding="#{d.AnalyticTemplateMBean.selectedQuery.grid}" sbvisibleamount="50" selectorcolumn="1" suppressheadline="true" usefieldforlabel="false" width="200" />
 


Here the binding is made to:
Code:
 private UIQueryItem selectedQuery = null;
 


When the user select a GUI item, of course selectedQuery is not null.

Code:
javax.servlet.ServletException: Index: 0, Size: 0
 	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 	at com.schott.indit.passntAdmin.utils.LoginFilter.doFilter(LoginFilter.java:46)
 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 	at org.eclnt.jsfserver.util.ThreadingFilter.doFilter(ThreadingFilter.java:226)
 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 	at org.eclnt.jsfserver.util.CompressionFilter.doFilter(CompressionFilter.java:33)
 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
 	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
 	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
 	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
 	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
 	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
 	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
 	at java.lang.Thread.run(Unknown Source)
 Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
 	at java.util.ArrayList.RangeCheck(Unknown Source)
 	at java.util.ArrayList.get(Unknown Source)
 	at org.eclnt.jsfserver.elements.impl.FIXGRIDComponent.checkIfColumnIsRendered(FIXGRIDComponent.java:1904)
 	at org.eclnt.jsfserver.elements.impl.FIXGRIDComponent.encodeChildren(FIXGRIDComponent.java:815)
 	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:930)
 	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:933)
 	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:933)
 	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:933)
 	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:933)
 	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:933)
 	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:933)
 	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:933)
 	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:933)
 	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:933)
 	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:933)
 	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:933)
 	at javax.faces.render.Renderer.encodeChildren(Renderer.java:148)
 	at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
 	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:930)
 	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:933)
 	at com.sun.faces.application.ViewHandlerImpl.doRenderView(ViewHandlerImpl.java:266)
 	at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:197)
 	at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
 	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
 	at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
 	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
 	... 21 more
 


Any clue?

Regards,

Joachim
unger

Power User

Joined: 22/07/2008 05:19:28
Messages: 261
Offline

I found, that it works when
Code:
 rendered=#{d.AnalyticTemplateMBean.selectedQuery != null}
 

is set.

So the program should crash, when it starts. Then selectedQuery is null. But the grid leaves empty. When I select a Query-Item the program crashes. But then selectedQuery is not null.

Conclusion: It's not a EC topic.

Regards,

Joachim
CaptainCasa

Power User
[Avatar]

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

Hi,

we tested this and did not find any problems - and echanged the exclamation mark in the title by a question mark ;-)

Please take a look onto the following example:

Code:
 package workplace;
 
 import java.io.Serializable;
 import java.util.Random;
 
 import org.eclnt.editor.annotations.CCGenClass;
 import org.eclnt.jsfserver.defaultscreens.Statusbar;
 import org.eclnt.jsfserver.elements.impl.ARRAYGRIDItem;
 import org.eclnt.jsfserver.elements.impl.ARRAYGRIDListBinding;
 import org.eclnt.jsfserver.elements.impl.FIXGRIDItem;
 import org.eclnt.jsfserver.elements.impl.FIXGRIDListBinding;
 
 @CCGenClass (expressionBase="#{wp.DemoGridWithArrayGrid}")
 
 public class DemoGridWithArrayGrid implements Serializable
 {
     public class InnerGridItem extends ARRAYGRIDItem implements java.io.Serializable
     {
         @Override
         public void onRowSelect()
         {
             Statusbar.outputSuccess("INNERGRID ROWSELECT :" + getValues()[0]);
         }
     }
 
     public class GridItem extends FIXGRIDItem implements java.io.Serializable
     {
         protected String m_name;
         public String getName() { return m_name; }
         public void setName(String value) { m_name = value; }
 
         protected ARRAYGRIDListBinding<InnerGridItem> m_innerGrid = new ARRAYGRIDListBinding<InnerGridItem>();
         public ARRAYGRIDListBinding<InnerGridItem> getInnerGrid() { return m_innerGrid; }
         
         public GridItem()
         {
             super();
             m_innerGrid.setTitles(new String[] {"Left Col","Right Col"});
             m_innerGrid.setWidths(new String[] {"50%","50%"});
             int maxi = s_random.nextInt(15);
             for (int i=0; i<maxi; i++)
             {
                 InnerGridItem igi = new InnerGridItem();
                 igi.setValues(new Object[] {m_name+"_left_"+i,m_name+"_right_"+i});
                 m_innerGrid.getItems().add(igi);
             }
         }
         
         @Override
         public void onRowSelect()
         {
             Statusbar.outputSuccess("GRID ROWSELECT: " + m_name);
         }
     }
 
     public DemoGridWithArrayGrid()
     {
         super();
         for (int i=0; i<10; i++)
         {
             GridItem gi = new GridItem();
             gi.setName("Name " + i);
             m_grid.getItems().add(gi);
         }
     }
     
     private static Random s_random = new Random();
     protected FIXGRIDListBinding<GridItem> m_grid = new FIXGRIDListBinding<GridItem>();
     
     public FIXGRIDListBinding<GridItem> getGrid() { return m_grid; }
 
 }
 


Page:
Code:
 <t:rowtitlebar id="g_1" text="Grid with ArrayGrid" />
 <t:rowheader id="g_2" />
 <t:rowbodypane id="g_3">
     <t:row id="g_4">
         <t:fixgrid id="g_5" bordercolor="#00000030" borderheight="1"
             borderwidth="1" headlinerowheight="20" height="100%"
             objectbinding="#{wp.DemoGridWithArrayGrid.grid}" rowheight="100"
             sbvisibleamount="10" width="100%">
             <t:gridcol id="g_6" text="Name" width="100">
                 <t:field id="g_7" text=".{name}" width="100" />
             </t:gridcol>
             <t:gridcol id="g_8" text="Grid" width="100%">
                 <t:arraygrid id="g_9" bordercolor="#00000030" borderheight="1"
                     borderwidth="1" objectbinding=".{innerGrid}" rowheight="16"
                     sbvisibleamount="5" />
             </t:gridcol>
         </t:fixgrid>
     </t:row>
 </t:rowbodypane>
 <t:rowstatusbar id="g_10" />
 


Screenshot: attached
[Thumb - gridarraygrid.png]
 Filename gridarraygrid.png [Disk] Download
 Description
 Filesize 21 Kbytes
 Downloaded:  389 time(s)


Björn Müller, CaptainCasa GmbH
unger

Power User

Joined: 22/07/2008 05:19:28
Messages: 261
Offline

Hello Björn,

1st:
Thank You!

2nd:
I built the failure that selectedQuery might be null.
But why the program didn't crash, when selectedQuery is surely null?

Joachim
CaptainCasa

Power User
[Avatar]

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

Hi,

when no grid available, we internally create a "rescue-grid" - otherwise you would not be able to work in the editor, if the grid is not implemened yet.

Björn

PS: in the lof there is a corresponding error message, that a dummy binding was created internally

Björn Müller, CaptainCasa GmbH
unger

Power User

Joined: 22/07/2008 05:19:28
Messages: 261
Offline

The problem is solved. Resolution for everybody who will find one day a similar problem:

Don't change the ARRAYGRIDListBinding instance. It must be a fix 1:1 dependency between Java instance and EC-Objectbinding attribute.

Regards,

Joachim
 
Forum Index -> Development
Go to:   
Powered by JForum 2.1.6 © JForum Team