myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Max Starets <max.star...@oracle.com>
Subject Re: AW: [Trinidad] how to add default selection for Table
Date Tue, 15 Apr 2008 16:16:58 GMT
Thomas,

Instead of creating a new instance of RowKeySetImpl(), try getting 
existing one
from the table (getSelectedRowKeys()). The exception indicates that the 
CollectionModel instance on
the RowKeySet is null. I expected that the table would set 
CollectionModel automatically, but apparently
it does not.

Max

thomas.asel@mvv.de wrote:
> Hi Max, thanks for your response.
> I tried this with a binding to method getSelectedRowKeys(), but it ends up with a NullPointerException.
The stackdrace does not contain any of my Classes so it looks like an internal error. Here
is the method I used:
>  
> public RowKeySet getSelectedRowKeys(){
>
>     RowKeySet selectedRows = new RowKeySetImpl();
>
>     List<BillingAddress> addresses = getBillingAdresses();
>
>     for(int i=0;i<addresses.size();i++){
>
>         if((addresses.get(i)).isSelected()) 
>
>             selectedRows.add(String.valueOf(i));
>
>     }
>
> return selectedRows;
>
> }
>
>  
>
> Here is the stacktrace:
>
> 15.04.2008 17:47:14 com.sun.facelets.FaceletViewHandler handleRenderException
>
> SCHWERWIEGEND: Error Rendering View[/page/meineDaten.xhtml]
>
> java.lang.NullPointerException
>
> at org.apache.myfaces.trinidad.model.RowKeySet.isContained(RowKeySet.java:104)
>
> at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.table.TableSelectOneRenderer$Radio.getSubmittedValue(TableSelectOneRenderer.java:246)
>
> at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.SimpleSelectBooleanRenderer.encodeAllAsElement(SimpleSelectBooleanRenderer.java:139)
>
> at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.FormElementRenderer.encodeAll(FormElementRenderer.java:109)
>
> at org.apache.myfaces.trinidad.render.CoreRenderer.delegateRenderer(CoreRenderer.java:330)
>
> at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.table.TableSelectOneRenderer.renderCellContent(TableSelectOneRenderer.java:177)
>
> at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.table.TableSelectOneRenderer.encodeAll(TableSelectOneRenderer.java:151)
>
> at org.apache.myfaces.trinidad.render.CoreRenderer.delegateRenderer(CoreRenderer.java:330)
>
> at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.table.SelectionColumnRenderer.renderKids(SelectionColumnRenderer.java:48)
>
> at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.ColumnRenderer._renderKids(ColumnRenderer.java:168)
>
> at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.ColumnRenderer._renderTD(ColumnRenderer.java:330)
>
> at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.ColumnRenderer._renderDataMode(ColumnRenderer.java:241)
>
> at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.ColumnRenderer.encodeAll(ColumnRenderer.java:96)
>
> at org.apache.myfaces.trinidad.render.CoreRenderer.delegateRenderer(CoreRenderer.java:330)
>
> at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.TableRenderer._renderSelectionColumn(TableRenderer.java:639)
>
> at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.TableRenderer.renderSpecialColumns(TableRenderer.java:604)
>
> at org.apache.myfaces.trinidadinternal.renderkit.core.desktop.DesktopTableRenderer.renderSingleRow(DesktopTableRenderer.java:108)
>
> at org.apache.myfaces.trinidadinternal.renderkit.core.desktop.DesktopTableRenderer$1.processRowImpl(DesktopTableRenderer.java:861)
>
> at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.table.TableUtils$RowLoop.processRow(TableUtils.java:117)
>
> at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.table.TableUtils$RowLoop.loop(TableUtils.java:103)
>
> at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.table.TableUtils$RowLoop.run(TableUtils.java:75)
>
> at org.apache.myfaces.trinidadinternal.renderkit.core.desktop.DesktopTableRenderer._renderTableRows(DesktopTableRenderer.java:912)
>
> at org.apache.myfaces.trinidadinternal.renderkit.core.desktop.DesktopTableRenderer.renderTableRows(DesktopTableRenderer.java:638)
>
> at org.apache.myfaces.trinidadinternal.renderkit.core.desktop.DesktopTableRenderer.renderTableContent(DesktopTableRenderer.java:364)
>
> at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.TableRenderer.encodeAll(TableRenderer.java:375)
>
> at org.apache.myfaces.trinidad.render.CoreRenderer.encodeEnd(CoreRenderer.java:220)
>
> at org.apache.myfaces.trinidad.component.UIXComponentBase.encodeEnd(UIXComponentBase.java:710)
>
> at org.apache.myfaces.trinidad.component.UIXCollection.encodeEnd(UIXCollection.java:525)
>
> at org.apache.myfaces.trinidad.render.CoreRenderer.encodeChild(CoreRenderer.java:299)
>
> at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.PanelHorizontalLayoutRenderer.encodeChild(PanelHorizontalLayoutRenderer.java:172)
>
> at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.PanelHorizontalLayoutRenderer._encodeChildren(PanelHorizontalLayoutRenderer.java:155)
>
> at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.PanelHorizontalLayoutRenderer.encodeAll(PanelHorizontalLayoutRenderer.java:85)
>
> at org.apache.myfaces.trinidad.render.CoreRenderer.encodeEnd(CoreRenderer.java:220)
>
> at org.apache.myfaces.trinidad.component.UIXComponentBase.encodeEnd(UIXComponentBase.java:710)
>
> at org.apache.myfaces.trinidad.render.RenderUtils.encodeRecursive(RenderUtils.java:69)
>
> at org.apache.myfaces.trinidad.render.CoreRenderer.encodeChild(CoreRenderer.java:294)
>
> at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.PanelGroupLayoutRenderer.encodeChild(PanelGroupLayoutRenderer.java:188)
>
> at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.PanelGroupLayoutRenderer._encodeChildren(PanelGroupLayoutRenderer.java:154)
>
> at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.PanelGroupLayoutRenderer.encodeAll(PanelGroupLayoutRenderer.java:106)
> at org.apache.myfaces.trinidad.render.CoreRenderer.encodeEnd(CoreRenderer.java:220)
> at org.apache.myfaces.trinidad.component.UIXComponentBase.encodeEnd(UIXComponentBase.java:710)
> at org.apache.myfaces.shared_impl.renderkit.RendererUtils.renderChild(RendererUtils.java:419)
> at org.apache.myfaces.shared_impl.renderkit.RendererUtils.renderChildren(RendererUtils.java:400)
> at org.apache.myfaces.shared_impl.renderkit.html.HtmlGroupRendererBase.encodeEnd(HtmlGroupRendererBase.java:78)
> at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:539)
> at org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils.renderChild(RendererUtils.java:419)
> at org.apache.myfaces.custom.tabbedpane.HtmlTabbedPaneRenderer.writeTabsContents(HtmlTabbedPaneRenderer.java:550)
> at org.apache.myfaces.custom.tabbedpane.HtmlTabbedPaneRenderer.encodeEnd(HtmlTabbedPaneRenderer.java:232)
> at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:539)
> at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:242)
> at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:239)
> at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:239)
> at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:580)
> at org.apache.myfaces.trinidadinternal.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:183)
> at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:41)
> at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:132)
> at javax.faces.webapp.FacesServlet.service(FacesServlet.java:140)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)´
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._invokeDoFilter(TrinidadFilterImpl.java:253)
> at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:210)
> at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:164)
> at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)´
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:100)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
> at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> at de.itservices.onlineservices.java.gui.filter.SessionExpiredFilter.doFilter(SessionExpiredFilter.java:50)
> 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:175)
> 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:844)
> 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)
>
> I also tried to set selectedRows.setContained(true) but this results in an NullPointerException
also...
>
> Thanks for your advice so far,
> Tom 
>
>  
>
>  
>  
>
> ________________________________
>
> Von: Max Starets [mailto:max.starets@oracle.com] 
> Gesendet: Dienstag, 15. April 2008 17:09
> An: MyFaces Discussion
> Betreff: Re: [Trinidad] how to add default selection for Table
>
>
>
> Thomas,
>
> Like you said, you can EL-bind selectedRowKeys. After you instantiate RowKeySetImpl,
you can call add() that takes a row key.
> Since you are using java.util.List as your table's value, the CollectionModel wrapper
will use a stringified version of the index as a key.
> So String.valueOf(index) will be a key for the given index.
>
> Regards,
> Max Starets
>
> thomas.asel@mvv.de wrote: 
>
> 	Hi all, 
> 	Im facing a problem with a tr:table that uses rowSelection="single". Depending on the
displayed data, one Row should be selected as default. The selectedRowKeys-attribute takes
an EL-expression that points to a RowKeySet. Since there aint no way to simply add a row-index
to the keyset, Im unsure how to tell the table wich row to select as default.
>
> 	My table is defined like this: 
> 	<tr:table value="#{myBean.billingAdresses}" var="address" rowSelection="single" binding="#{myBean.addressTable}"
> 
>
> 	The billingAddresses method in the BackingBean returns a list of BillingAddress-Objects.
One of these objects has a boolean attribute "selected" set to true. The row dsiplaying this
object should be preselected.
>
> 	I tried to find some help on the web but found only one solution that was highly dependent
on Seam. 
>
> 	Thanks in advance, 
> 	Tom 
>
>
> 	Thomas Asel 
> 	Diplom Informatiker (FH) 
> 	Selbständiger Softwareentwickler 
> 	im Auftrag der 24/7 IT-Services GmbH 
>
> 	== == == == == == == == == == == == 
> 	www.thomas-asel.de <file://www.thomas-asel.de>  
> 	J2EE und Contentmanagement-Lösungen 
> 	L13,7 68161 Mannheim 
> 	Tel.: +49 (0) 621 / 386 448 3 
> 	Mobil: +49(0) 176 / 219 284 26 
> 	USt-IdNr.: DE248123620 
>
>
>   


Mime
View raw message