myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Kienenberger <mkien...@gmail.com>
Subject Re: Exception with selectManyCheckBox inside dataTable
Date Tue, 22 Nov 2005 15:19:56 GMT
This may not be your only problem, but it's one.

You may only have one child component in the facet tag.

Wrap your two components inside of a <h:panelGroup>

<f:facet name="header">
    <h:panelGroup>
         <t:selectManyCheckbox id="selectManyCheckbox" layout="spread">
           <f:selectItems value="#{selectManyCheckboxBean.items}" />
         </t:selectManyCheckbox>
         <h:outputText value="Selected" />
    </h:panelGroup>
</f:facet>



On 11/22/05, Martin PeĊ™ina <martin.perina@ataco.cz> wrote:
> Hello,
>
> I tried to use a checkbox on each row of a dataTable using
> this minimalized JSP code:
>
>     <t:dataTable cellspacing="0" frame="border" rules="rows"
>         value="#{selectManyCheckboxBean.items}"
>         var="item" rowIndexVar="rowIndex">
>
>       <h:column>
>         <f:facet name="header">
>           <t:selectManyCheckbox id="selectManyCheckbox" layout="spread">
>             <f:selectItems value="#{selectManyCheckboxBean.items}" />
>           </t:selectManyCheckbox>
>           <h:outputText value="Selected" />
>         </f:facet>
>
>         <t:checkbox for="selectManyCheckbox" index="#{rowIndex}"/>
>       </h:column>
>
>       ...
>
>     </t:dataTable>
>
>
> Backing bean code:
>
> public class SelectManyCheckboxBean {
>     private List items;
>     private String[] selectedItems;
>
>     public SelectManyCheckboxBean() {
>         setItems(new ArrayList());
>         getItems().add(new SelectItem("Item 1"));
>         getItems().add(new SelectItem("Item 2"));
>         getItems().add(new SelectItem("Item 3"));
>     }
>
>     public List getItems() {
>         return items;
>     }
>
>     public void setItems(List items) {
>         this.items = items;
>     }
>
>     public String[] getSelectedItems() {
>         return selectedItems;
>     }
>
>     public void setSelectedItems(String[] selectedItems) {
>         this.selectedItems = selectedItems;
>     }
> ...
> }
>
>
> When the page is accessed, this exception is thrown:
>
> javax.faces.FacesException: index 0 >= 0
>         at
> org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:422)
>         at
> org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:234)
>         at
> org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:373)
>         at
> javax.faces.webapp.FacesServlet.service(FacesServlet.java:107)
>         at
> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:428)
>         at org.mortbay.jetty.servlet.WebApplicationHandler
> $CachedChain.doFilter(WebApplicationHandler.java:830)
>         at
> org.mortbay.jetty.servlet.jsr77.Jsr77Filter.doFilter(Jsr77Filter.java:77)
>         at org.mortbay.jetty.servlet.WebApplicationHandler
> $CachedChain.doFilter(WebApplicationHandler.java:821)
>         at
> org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:123)
>         at org.mortbay.jetty.servlet.WebApplicationHandler
> $CachedChain.doFilter(WebApplicationHandler.java:821)
>         at
> org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:471)
>         at
> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:568)
>         at org.mortbay.http.HttpContext.handle(HttpContext.java:1530)
>         at
> org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:633)
>         at org.mortbay.http.HttpContext.handle(HttpContext.java:1482)
>         at org.mortbay.http.HttpServer.service(HttpServer.java:927)
>         at org.jboss.jetty.Jetty.service(Jetty.java:456)
>         at
> org.mortbay.http.HttpConnection.service(HttpConnection.java:816)
>         at
> org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:983)
>         at
> org.mortbay.http.HttpConnection.handle(HttpConnection.java:833)
>         at
> org.mortbay.http.SocketListener.handleConnection(SocketListener.java:244)
>         at
> org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357)
>         at org.mortbay.util.ThreadPool
> $PoolThread.run(ThreadPool.java:534)
> Caused by: org.apache.jasper.JasperException: index 0 >= 0
>         at
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
>         at
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
>         at
> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
>         at
> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:428)
>         at org.mortbay.jetty.servlet.WebApplicationHandler
> $CachedChain.doFilter(WebApplicationHandler.java:830)
>         at
> org.mortbay.jetty.servlet.jsr77.Jsr77Filter.doFilter(Jsr77Filter.java:77)
>         at org.mortbay.jetty.servlet.WebApplicationHandler
> $CachedChain.doFilter(WebApplicationHandler.java:821)
>         at
> org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:471)
>         at
> org.mortbay.jetty.servlet.Dispatcher.dispatch(Dispatcher.java:280)
>         at
> org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:171)
>         at
> org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:416)
>
>
> Tested on MyFaces 1.1.1 and nightly build 20051121, JDK 1.4.2,
> JBoss 4.0.3 SP1 with Jetty 5.1.6
>
> Thanks for any help
>
>
> Martin Perina
>
>
>
>
>
>
Mime
View raw message