users@woodstock.java.net

Re: Problem getting selected table row with AJAX

From: Dan Labrecque <Dan.Labrecque_at_Sun.COM>
Date: Wed, 02 Apr 2008 09:06:14 -0500

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
> <mailto: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
> <mailto:users-unsubscribe_at_woodstock.dev.java.net>
> For additional commands, e-mail: users-help_at_woodstock.dev.java.net
> <mailto:users-help_at_woodstock.dev.java.net>
>
>