well take a look into javadoc of UIData.encodeBegin() in the spec. It
says that the rowstates must be discarded in this method.

Some use cases still work by this approach. It´s ok to delete, edit or
add rows in the action
through the component binding of the selectboolean checkbox as long as
it only read the value of the component. But it will not work if you
write the value for the component.

2005/11/13, Vesa Lindfors <[EMAIL PROTECTED]>:
> Ok, what I'm doing is something Craig McClanahan has shown in
> http://forum.java.sun.com/thread.jspa?threadID=486654&messageID=2819434:
>
>  "...
>  The UIData control will take care of making sure that the correct MailBean
> is stored in the "var" element for each row. In the delete() method, you can
> simply walk through your list of MailBean beans and take action on the ones
> that have the "selected" property set.
>
>  If you do not have a boolean property on the bean that you can use,
> Approach (2) is to bind your component directly into your backing bean ...
> something like this:
>  <h:form id="mailbox">
>  <h:data_table value="#{mailsForm.mails}" var="mailBean" binding=
> "#{mybean.table}">
>  <h:column>
>  <f:facet>
>  <h:output_text value="Selected"/>
>  </f:facet>
>  <h:selectboolean_checkbox id=
> "selected" binding="#{mybean.selected}"/>
>  </h:column>
>  <h:column>
>  <f:facet>
>  <h:output_text value=
> "From"/>
>  </f:facet>
>  <h:output_text id="from" value="#{mailBean.from}"/>
>  </h:column>
>
>  ...
>  </h:data_table>
>  <h:command_button id="delete" action="#{mybean.delete}"/>
> </h:form>
>
>
>  with a backing bean something like this:
>  public class MyBean {
>
>  // Property bound to the "selected" checkbox
>
>  UISelectBoolean selected;
>  public UISelectBoolean getSelected() {
>  return selected;
>  }
>
>  public void setSelected(UISelectBoolean selected) {
>  this.selected = selected;
>  }
>
>
>  // Property bound to the entire table
>  UIData table;
>  public UIData getTable() {
>
> return table;
>  }
>  public void setTable(UIData table) {
>  this.table = table;
>
>  }
>
>  // Method to delete all the selected messages
>  public String delete() {
>
>
>  // Iterate through the data rows ...
>  int first = table.getFirst();
>  int rows = table.getRows();
>
>  for (int index = first; index < (first + rows); index++) {
>
>  // Position the table at the current row ...
>
>  table.setRowIndex(index);
>
>  // And get the message bean for this row ...
>  MailBean mailBean = (MailBean)
>  FacesContext.getCurrentInstance
> ().getRequestMap().get("mailBean");
>
>  // If this row is selected, delete the corresponding message
>  if
>  (selected.isSelected()) {
>  ...
>  }
>
>  }
>  table.setRowIndex(-1);
> // We're done now
>  return (null); // Redisplay the current page
>  }
>
>
>  Why does this work? Because there is a lot of mojo built in to the
> setRowIndex() method of the UIData component ... that is where the code that
> stores the bean for the current row into your "var" attribute lives. In
> addition, the UIData maintains a per-row value for all the input components,
> so that you don't have to. And, whenever you select a particular row index,
> it makes sure that the correct value for the current row is there.
>
>  The "Repeater" component in the components demo that ships with the
> JavaServer Faces reference implementation (including source) has a more
> fleshed out example of this sort of thing, with a page that lets you add new
> rows, edit existing rows, and remove existing rows in a table ... plus the
> ability to scroll through a large list one page at a time. All of these
> techniques work the same with <h:data_table> as well.
>
>  Craig McClanahan
>  "
>
>  And in RI Repeater example of
> http://jal.sun.com/services/jsf-components/index.jsp
> http://jal.sun.com/services/jsf-components/ShowSource.jsp?filename=/repeater.jsp:
> ...
>  <%-- Visible checkbox for selection --%>
>
>  <h:selectBooleanCheckbox
>  id="checked"
>  binding="#{RepeaterBean.checked}"/>
> ....
>
>
> http://jal.sun.com/services/jsf-components/ShowSource.jsp?filename=/src/demo/model/RepeaterBean.java
>
>  /**
>  * <p>The <code>checked</code> field for the current row.</p>
>
>  */
>  private UISelectBoolean checked = null;
>
>
>  public UISelectBoolean getChecked() {
>  return checked;
>  }
>
>
>  public void setChecked(UISelectBoolean checked) {
>  this.checked
>  = checked;
>  }
> ...
>  /**
>  * <p>Clear the checked state for all customers.</p>
>  */
>  private void clear() {
>
>  int n = count();
>  for (int i = 0; i < n; i++) {
>
>  data.setRowIndex(i);
>  checked.setSelected(false);
>  }
>
>  }
> ...
>
>
>  I can change my code, but still wondering is something broken because that
> was working in 1.1.1 but not in NB... and does that means that the RI
> example wouldn't work in Myfaces...
>  --- VLi ---
>
>
>
>
> On 11/12/05, Yee CN <[EMAIL PROTECTED]> wrote:
> > Is it possible/appropriate to use
> > <t:saveState value=#{SubscrierMB.dataModel}>
> >
> > to solve the problem?
> >
> > Regards,
> > Yee
> >
> > -----Original Message-----
> > From: Mathias Brökelmann [mailto: [EMAIL PROTECTED]
> > Sent: Saturday, 12 November 2005 9:38 PM
> > To: MyFaces Discussion
> > Subject: Re: Some notes of my loadtest results
> >
> > You have a component binding. I mean the valuebinding through the
> > attribute value. I expect something like this:
> >
> >         <h:selectBooleanCheckbox
> >              ...
> >              value="#{SubscriberMB.checkedRow}"
> >              ... >
> >         </h:selectBooleanCheckbox>
> >
> > The problem is still the same. Datatable maintains internal rowstates
> > which contains the setted values for each component and each row but
> > they are discared before render phase. The invoke application phase in
> > which you set the boolean value is before the render phase. Any value
> > you have set in the application phase through the component binding
> > will be lost since updateModel phase (which could set the value
> > through the value binding) is before invoke application.
> >
> >
> > 2005/11/12, Vesa Lindfors <[EMAIL PROTECTED]>:
> > > Sorry, I wasn't clear enough in problem description -  sure I have
> > > valuebinding in each  row:
> > >        <h:selectBooleanCheckbox
> > >             ...
> > >             binding="#{SubscriberMB.checkedRow}"
> > >             ... >
> > >        </h:selectBooleanCheckbox>
> > > and that is working like earlier. I can select (one by one) and have
> > actions
> > > for selected users (selected by clicking checkboxes).
> > >
> > >  On the other words, I failed to set checkboxes in table by programming
> > >
> > >           dataModel.setRowIndex(index);
> > >           checkedRow.setSelected(true);
> > >
> > >  And I think that should work also?
> > >  -- vLi --
> > >
> > >
> > >
> > > On 11/12/05, Mathias Brökelmann < [EMAIL PROTECTED]> wrote:
> > > > I wonder that this is working in 1.1.1.
> > > >
> > > > Normally the state for each row in a datatable is discarded before the
> > > > table is rendered if the page data contains no error. Any input
> > > > component without a valuebinding loses its value. I suggest you to use
> > > > a valuebinding for the UISelectBoolean field. This will work better in
> > > > datatables. If the selectall button is executed set the flags for the
> > > > managed bean field for each row which was bound to the select boolean
> > > > component.
> > > >
> > > > 2005/11/11, Vesa Lindfors <[EMAIL PROTECTED] >:
> > > > > I have just one more issue before I can test NB again with
> > > > > STATE_SAVING_METHOD=server && SERIALIZE_STATE_IN_SESSION=true
> > > > >
> > > > >  I had earlier ( 1.1.1) working "Select all" function for checkboxs
> in
> > my
> > > > > datatable, now in NB it's not (neither in cleint or server side). Is
> > > there
> > > > > any thing I should make differently?
> > > > >
> > > > >  private UISelectBoolean checkedRow = null;
> > > > >
> > > > >  public UISelectBoolean getCheckedRow() { return checkedRow; }
> > > > >
> > > > >  public void setCheckedRow(UISelectBoolean checked) {
> this.checkedRow
> > =
> > > > > checked; }
> > > > >
> > > > >  public void selectAllListener(ActionEvent event) {
> > > > >  ...
> > > > >      for (int index = first; index < rows; index++) {
> > > > >          dataModel.setRowIndex(index);
> > > > >           checkedRow.setSelected(true);
> > > > >        }
> > > > >      }
> > > > >  ...
> > > > >    }
> > > > >
> > > > >  x:dataTable has preserveDataModel="false" and the data list stored
> by
> > > > > x:saveState.
> > > > >
> > > > >  I can see that method is called properly and no exception is shown,
> > but
> > > the
> > > > > checkboxes are not marked as earlier...
> > > > >
> > > > >  -- VLi ---
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > On 11/9/05, Mathias Brökelmann < [EMAIL PROTECTED] >
> wrote:
> > > > > > You are right latest commit breaks that. I have committed a fix
> for
> > > > > > that so it is working now.
> > > > > >
> > > > > > 2005/11/9, Vesa Lindfors < [EMAIL PROTECTED]>:
> > > > > > > Mathias,
> > > > > > >  I tested successfully the rest of platforms with
> > > > > > > javax.faces.STATE_SAVING_METHOD=server &&
> > > > > > > SERIALIZE_STATE_IN_SESSION=false &&
> > > myfaces-20051030 .
> > > > > > >
> > > > > > >  Now I should have time to continue testing your suggestion:
> > > > > > > STATE_SAVING_METHOD=server && SERIALIZE_STATE_IN_SESSION=true &&
> > > > > > > myfaces-20051103.
> > > > > > >  But now my testing fails at the very begin: the application
> > didn't
> > > > > worked
> > > > > > > at all with state saving "server" - my ActionEvents weren't
> fired
> > at
> > > all
> > > > > ( I
> > > > > > > mean very basic form buttons didn't work anymore). Turning state
> > > saving
> > > > > to
> > > > > > > the "client" it start to work again. I tried also with
> > > myfaces-20051107
> > > > > and
> > > > > > > same results. Do you have any idea what could be changed in NB
> > > during
> > > > > > > 20051030- 20051103 so that it can have such effect?
> > > > > > >
> > > > > > >  --- VLi ---
> > > > > > >
> > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > >One more thing. I have removed the gzipping of the serialized
> > > stream
> > > > > > > > >if server side state is used. This might have caused some
> > > additional
> > > > > > > > >performance problems. Would it be possible to take the next
> > > nightly
> > > > > > > > >(20051103) and test it again with
> > > > > > > >
> > > >org.apache.myfaces.SERIALIZE_STATE_IN_SESSION=true
> > > > > to
> > > > > > > check this?
> > > > > > > >
> > > > > > > > >Mathias
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Mathias
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > > > --
> > > > Mathias
> > > >
> > >
> > >
> >
> >
> > --
> > Mathias
> >
> >
>
>


--
Mathias

Reply via email to