Take a look into the javadoc for UIData.encodeBegin() method:

<snip>
In addition to the default behavior, ensure that any saved per-row state for our child input components is discarded unless it is needed to rerender the current page with errors.
<snap>

That´s the reason why setting the component values will not work in your datatable.

Try to make it with value bindings and hold the selection state in your bean(s).

Regards,
Mathias

Balaji Saranathan schrieb:
To add on,
My Checkbox code looks like this.

<h:column id="checkboxColumn">
<f:facet name="header">
<h:selectBooleanCheckbox id="headerCheckbox"binding="#{DataTableHandler.headerSelected}" immediate="true" valueChangeListener="#{DataTableHandler.selectAllRows}" onclick="submit()" />
</f:facet>
<h:selectBooleanCheckbox id="rowCheckbox" binding="#{DataTableHandler.selected}" />
</h:column>

    -----Original Message-----
    *From:* Balaji Saranathan [mailto:[EMAIL PROTECTED]
    *Sent:* Friday, August 05, 2005 4:16 PM
    *To:* 'MyFaces Discussion'
    *Subject:* DataTable SelectAll

    Hi,

    Below is a code snippet I use to selectAllRows on a dataTable. I use
    a selectBooleanCheckBox in header and associate a valuechangeevent.
    I have 10 rows displayed at a time and the I get the log message in
    the else as many times.

    However, when the page is rendered, the other checkboxes are not
    checked. Can you help? Or is there any other better way to do it?

       public String selectAllRows(ValueChangeEvent e)
       {
          log.debug("Inside the selectAllRows");
          int firstRow = table.getFirst();
          int numRows = table.getRows();

          for (int index = firstRow; index < (firstRow + numRows); index++)
          {
             table.setRowIndex( index );

             if (selected.isSelected())
             {
                log.debug("Inside the selected.isSelected");
                //Do nothing
             }
             else
             {
                //select all of them.
                log.debug("Gonna set all of them to true");
                selected.setSelected(true);
             }
          }
          return "success";
       }

    TIA



    Confidentiality Notice

    The information contained in this electronic message and any
    attachments to this message are intended
    for the exclusive use of the addressee(s) and may contain
    confidential or privileged information. If
    you are not the intended recipient, please notify the sender at
    Wipro or [EMAIL PROTECTED] immediately
    and destroy all copies of this message and any attachments.



Confidentiality Notice

The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain confidential or privileged information. If you are not the intended recipient, please notify the sender at Wipro or [EMAIL PROTECTED] immediately
and destroy all copies of this message and any attachments.


Reply via email to