users@woodstock.java.net

Re: Problem getting selected table row with AJAX

From: Felipe Jaekel <fkjaekel_at_gmail.com>
Date: Tue, 8 Apr 2008 14:03:17 -0300

Sorry for the delay to reply.

Yes, I am adding rows with a button outside the table.

I finally noticed that an exception is thrown every time I try to submit
something from the table. In the stack trace bellow, "tableColumn1" is the
id of the column that has the component. I tested with button, checkbox and
radiobutton.

Thanks again for the help,
Felipe

08/04/2008 13:35:30 org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8084
08/04/2008 13:35:30 org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
08/04/2008 13:35:30 org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/35 config=null
08/04/2008 13:35:30 org.apache.catalina.startup.Catalina start
INFO: Server startup in 4596 ms
08/04/2008 13:35:34 org.apache.shale.remoting.faces.MappingsHelper
createMappings
INFO: Configuring Mappings instance of type
08/04/2008 13:35:34 org.apache.shale.remoting.faces.MappingsHelper
createMappings
INFO: org.apache.shale.remoting.impl.MappingsImpl
08/04/2008 13:35:34 org.apache.shale.remoting.faces.MappingsHelper
configureMappings
INFO: Configuring processor mapping
08/04/2008 13:35:34 org.apache.shale.remoting.faces.MappingsHelper
configureMappings
INFO: /static/*:org.apache.shale.remoting.impl.ClassResourceProcessor
08/04/2008 13:35:34 org.apache.shale.remoting.faces.MappingsHelper
configureMappings
INFO: Configuring processor mapping
08/04/2008 13:35:34 org.apache.shale.remoting.faces.MappingsHelper
configureMappings
INFO: /dynamic/*:org.apache.shale.remoting.impl.MethodBindingProcessor
08/04/2008 13:35:34 org.apache.shale.remoting.faces.MappingsHelper
configureMappings
INFO: Configuring processor mapping
08/04/2008 13:35:34 org.apache.shale.remoting.faces.MappingsHelper
configureMappings
INFO: /webapp/*:org.apache.shale.remoting.impl.WebResourceProcessor
08/04/2008 13:36:08 com.sun.faces.lifecycle.ApplyRequestValuesPhase execute
WARNING: For input string: "tableColumn1"
java.lang.NumberFormatException: For input string: "tableColumn1"
        at
java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
        at java.lang.Integer.parseInt(Integer.java:447)
        at java.lang.Integer.parseInt(Integer.java:497)
        at
com.sun.data.provider.impl.IndexRowKey.create(IndexRowKey.java:64)
        at
com.sun.data.provider.impl.AbstractTableDataProvider.getRowKey(AbstractTableDataProvider.java:146)
        at
com.sun.webui.jsf.component.TableRowGroupBase.invokeOnComponent(TableRowGroupBase.java:1291)
        at
javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
        at
javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
        at
javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
        at
javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
        at
javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
        at
javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
        at
javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
        at
javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
        at
javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
        at
javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
        at
javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
        at
javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
        at
javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
        at
javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
        at
com.sun.faces.extensions.avatar.components.PartialTraversalViewRootHelper.invokeContextCallbackOnSubtrees(PartialTraversalViewRootHelper.java:565)
        at
com.sun.faces.extensions.avatar.components.PartialTraversalViewRootHelper.processDecodes(PartialTraversalViewRootHelper.java:233)
        at
com.sun.faces.extensions.avatar.components.PartialTraversalViewRootImpl.processDecodes(PartialTraversalViewRootImpl.java:145)
        at
com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:101)
        at
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
        at
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
        at
com.sun.faces.extensions.avatar.lifecycle.PartialTraversalLifecycle.execute(PartialTraversalLifecycle.java:94)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at
com.sun.webui.jsf.util.UploadFilter.doFilter(UploadFilter.java:267)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
        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(Thread.java:619)
08/04/2008 13:36:08 com.sun.faces.lifecycle.LifecycleImpl phase
WARNING: executePhase(APPLY_REQUEST_VALUES
2,com.sun.faces.context.FacesContextImpl_at_7fc8b2) threw exception
javax.faces.FacesException: For input string: "tableColumn1"
        at
com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:109)
        at
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
        at
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
        at
com.sun.faces.extensions.avatar.lifecycle.PartialTraversalLifecycle.execute(PartialTraversalLifecycle.java:94)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at
com.sun.webui.jsf.util.UploadFilter.doFilter(UploadFilter.java:267)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
        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(Thread.java:619)
Caused by: java.lang.NumberFormatException: For input string: "tableColumn1"
        at
java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
        at java.lang.Integer.parseInt(Integer.java:447)
        at java.lang.Integer.parseInt(Integer.java:497)
        at
com.sun.data.provider.impl.IndexRowKey.create(IndexRowKey.java:64)
        at
com.sun.data.provider.impl.AbstractTableDataProvider.getRowKey(AbstractTableDataProvider.java:146)
        at
com.sun.webui.jsf.component.TableRowGroupBase.invokeOnComponent(TableRowGroupBase.java:1291)
        at
javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
        at
javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
        at
javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
        at
javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
        at
javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
        at
javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
        at
javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
        at
javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
        at
javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
        at
javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
        at
javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
        at
javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
        at
javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
        at
javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
        at
com.sun.faces.extensions.avatar.components.PartialTraversalViewRootHelper.invokeContextCallbackOnSubtrees(PartialTraversalViewRootHelper.java:565)
        at
com.sun.faces.extensions.avatar.components.PartialTraversalViewRootHelper.processDecodes(PartialTraversalViewRootHelper.java:233)
        at
com.sun.faces.extensions.avatar.components.PartialTraversalViewRootImpl.processDecodes(PartialTraversalViewRootImpl.java:145)
        at
com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:101)
        ... 22 more


2008/4/4, Dan Labrecque <Dan.Labrecque_at_sun.com>:
>
> Felipe Jaekel wrote:
>
> What I mean with ajax transaction is not fired is that I have a dynamic
> faces ajax transaction component whitch I set the radio button to submit its
> value, the same way I do with other components. The radio button has a
> process value change. If I put a bookmark inside the event handler it
> doesn't stops there.
>
> I read the tableRowGroup TLD, but I don't think it's a problem with the
> dataprovider, because I can add or remove data to it and the table refresh
> correctly. I'm using DynaFaces.Tx.fire('transactionName').
>
>
> Adding/removing table rows is typically done via JSF's invoke application
> phase. Typically, after a button has queued an action. This has nothing to
> do with decoding radio button values via an Ajax request -- that is done
> much earlier.
>
> When you add rows, is that done with a button/hyperlink outside the table
> (i.e., not in a table cell)? As a test, add a hyperlink to the table cell
> and see what happens. If the hyperlink does not invoke an action properly,
> then there is most likely a problem with the DataProvider.
>
>
> I still dont't understand how to submit a radio button or a check box from
> the table, isn't there any tutorial I can follow?
>
>
> Not for how to use Dynamic Faces with a table. Again, you're treading in
> uncharted waters here. ;)
>
> Dan
>
>
> Thanks for the help,
> Felipe
>
> 2008/4/2, Dan Labrecque <Dan.Labrecque_at_sun.com>:
> >
> > I don't understand what you mean by the Ajax transaction is not fired?
> > However, you're treading in uncharted waters here. All I can suggest is that
> > you read the "Life Cycle" section in the tableRowGroup TLD. It is important
> > to understand what is expected by the DataProvider and when. In your
> > scenario, radiobuttons must be submitted -- basically everything under the
> > table is a virtual form. But, if you do not have the DataProvider set
> > correctly during the JSF decode phase, these components will not be decoded.
> > Therefore, you won't be able to retrieve any selected rows.
> >
> > Sorry I cannot be more helpful,
> > Dan
> >
> > Felipe Jaekel wrote:
> >
> > To add and remove data from the table, AJAX is working fine.
> >
> > To edit data I have a radio button to select the row. I followed this
> > tutorial <http://www.netbeans.org/kb/60/web/web-jpa-part2.html>.
> >
> > When I add this radio button to the AJAX transaction, it's not fired. I
> > think the problem is that the radio button id is dynamic. I tried to submit
> > the tableRowGroup, the transaction is fired, but
> > getTableRowGroup1().getSelectedRowKeys() returns empty.
> >
> > Here is my code:
> > <df:ajaxTransaction id="ajaxTransaction2"
> > inputs="page1:html1:body1:form1:button2,page1:html1:body1:form1:table1:tableRowGroup1:tableColumn3:radioButton1"
> > render="page1:html1:body1:form1:staticText5"/>
> >
> > <webuijsf:table augmentTitle="false" id="table1" title="Table"
> > width="10">
> > <webuijsf:tableRowGroup
> > binding="#{Page1.tableRowGroup1}" id="tableRowGroup1" rows="10"
> > selected="#{Page1.selectedState}"
> > sourceData="#{SessionBean1.beans}"
> > sourceVar="currentRow">
> > <webuijsf:tableColumn
> > id="tableColumn3"
> > onClick="setTimeout(function(){document.getElementById('form1:table1').initAllRows()},
> > 0);" selectId="radioButton1" width="9">
> > <webuijsf:radioButton
> > id="radioButton1" label="" name="radioButton1" selected="#{Page1.selected}"
> > selectedValue="#{Page1.selectedValue}"/>
> > </webuijsf:tableColumn>
> > <webuijsf:tableColumn
> > headerText="codigo" id="tableColumn1" sort="codigo">
> > <webuijsf:staticText
> > id="staticText3" text="#{currentRow.value['codigo']}"/>
> > </webuijsf:tableColumn>
> > <webuijsf:tableColumn headerText="nome"
> > id="tableColumn2" sort="nome">
> > <webuijsf:staticText
> > id="staticText4" text="#{currentRow.value['nome']}"/>
> > </webuijsf:tableColumn>
> > </webuijsf:tableRowGroup>
> > </webuijsf:table>
> > <webuijsf:staticText
> > binding="#{Page1.staticText5}" id="staticText5" />
> > <webuijsf:button
> > actionExpression="#{Page1.button2_action}" id="button2"
> >
> > onClick="DynaFaces.Tx.fire('ajaxTransaction2');&#xa;return false;"
> > text="Button"/>
> >
> > public String button2_action()
> > {
> > staticText5.setText(getSelectedRow().getNome());
> > return null;
> > }
> >
> > private Bean getSelectedRow()
> > {
> > if(getTableRowGroup1().getSelectedRowsCount() > 0)
> > {
> > return
> > getSessionBean1().getBeans().get(Integer.parseInt(getTableRowGroup1().getSelectedRowKeys()[0].getRowId()));
> > }
> > else
> > {
> > return null;
> > }
> > }
> >
> > Thanks a lot,
> > Felipe
> >
> > 2008/4/1, Dan Labrecque <Dan.Labrecque_at_sun.com>:
> > >
> > > There is no selected row value other than what is associated with the
> > > checkbox you provided in a table cell. First, you must to ensure that the
> > > HTML input value of the checkbox is submitted. Then, you need to ensure the
> > > same DataProvider, used to render the table, is available during the JSF
> > > decode phase. The table needs to iterate over each row and call the decode
> > > method of each checkbox component.
> > >
> > > Please see the "Life Cycle" section, in the tableRowGroup TLD doc
> > > below, for more info.
> > >
> > > http://webdev2.sun.com/woodstock-tlddocs
> > >
> > > Dan
> > >
> > > Felipe Jaekel wrote:
> > >
> > > > I have an Ajax Transaction component. I'm trying to get the selected
> > > > row value from a table, so I configured it to send input, but it's not
> > > > working.
> > > >
> > > > Is there something else that has to be done to get this working?
> > > >
> > > > Thanks,
> > > > Felipe
> > > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe_at_woodstock.dev.java.net
> > > For additional commands, e-mail: users-help_at_woodstock.dev.java.net
> > >
> > >
> >
> >
>
>