6 Replies Latest reply on Sep 15, 2008 5:18 AM by ilya_shaikovsky

    Datascroller and editable datatable

    bfayle

      I have a dataTable that is editable. When the user enters data and clicks the dataScroller the data entered is lost. How do I get the dataScroller to update the model prior to the data scrolling changing pages?

        • 1. Re: Datascroller and editable datatable
          ilya_shaikovsky

          AjaxSingle = false should resolve this.

          • 2. Re: Datascroller and editable datatable
            bfayle

            Thanks - the documentation is a bit sparse on many of the attributes.

            • 3. Re: Datascroller and editable datatable

              Did using the AJaxSingle=false work for you? I tried it to no avali.

              • 4. Re: Datascroller and editable datatable
                ilya_shaikovsky

                ekinsey, all the customers that was trying this case was succesfull with ajaxSingle="false".

                Explain more carefully your case. Code snippets and environment info will be helpfull.

                • 5. Re: Datascroller and editable datatable

                  Hi iLya,

                  I've attached my sample code. When I enter text into the inputText boxes and page to another page using the datascroller the data is missing from the inputText boxes when I navigate back to the page. I help that you can provide is greatly appreciated. Also, please forward any working code that you may have.

                  Best regards,
                  -E


                  View

                  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                  <html xmlns="http://www.w3.org/1999/xhtml"
                  xmlns:h="http://java.sun.com/jsf/html"
                  xmlns:f="http://java.sun.com/jsf/core"
                  xmlns:ui="http://java.sun.com/jsf/facelets"
                  xmlns:a4j="http://richfaces.org/a4j"
                  xmlns:rich="http://richfaces.org/rich"
                  xmlns:t="http://myfaces.apache.org/tomahawk">

                  <!--
                  Replace path to template, title, header and body
                  with actual data.
                  -->

                  <ui:composition template="/templates/common.xhtml">
                  <ui:define name="pageTitle">Title</ui:define>
                  <ui:define name="pageHeader">Table Example</ui:define>
                  <ui:define name="body">
                  <f:view>
                  <h:form>
                  <rich:panel header="Table" id="pnltable">
                  <rich:datascroller for="mytable" pageIndexVar="pageIndex"
                  pagesVar="pages" ajaxSingle="false">
                  <f:facet name="pages">
                  <h:outputText value="#{pageIndex} / #{pages}"></h:outputText>
                  </f:facet>
                  </rich:datascroller>

                  <rich:dataTable value="#{bean.personlist}" var="person"
                  id="mytable" rows="10">
                  <rich:column>
                  <f:facet name="header">Name</f:facet>
                  <h:outputText value="#{person.name}" />
                  </rich:column>
                  <rich:column>
                  <f:facet name="header">Address</f:facet>
                  <h:inputText value="#{person.address}"/>
                  </rich:column>
                  <rich:column>
                  <f:facet name="header">Comment</f:facet>
                  <h:inputText value="#{person.comment}"/>
                  </rich:column>
                  </rich:dataTable>

                  <h:commandButton value="Go"
                  actionListener="#{bean.process}" />

                  </rich:panel>

                  </h:form>
                  </f:view>
                  </ui:define>
                  </ui:composition>




                  Backing Bean

                  /**
                  *
                  */
                  package demo;

                  import java.util.ArrayList;

                  import javax.faces.event.ActionEvent;

                  /**
                  * @author kinseye
                  *
                  */
                  public class Bean {
                  private String text;
                  private ArrayList personlist = new ArrayList();

                  public Bean() {

                  for (int i = 0; i < 100; i++) {
                  Person person = new Person();
                  person.setName("Mr. Name " + i);
                  person.setAddress("");
                  person.setComment("Comment = " + person.hashCode());
                  personlist.add(person);
                  }
                  }

                  public ArrayList getPersonlist() {
                  return personlist;
                  }

                  public void setPersonlist(ArrayList personlist) {
                  this.personlist = personlist;
                  }

                  public String getText() {
                  return text;
                  }

                  public void setText(String text) {
                  this.text = text;
                  }

                  public void process(ActionEvent event ){
                  for (Person person : personlist) {
                  System.out.println("Person: " + person.getName() +";"+person.getAddress());
                  }
                  System.out.println(event.getSource());
                  }
                  }



                  Doman Object


                  package demo;

                  /**
                  * Created by JBoss Tools
                  */
                  public class Person {

                  private String name;
                  private String address;
                  private String comment;

                  public Person() {
                  }

                  public String getName() {
                  return name;
                  }

                  public void setName(String name) {
                  this.name = name;
                  }

                  public String getAddress() {
                  return address;
                  }

                  public void setAddress(String address) {
                  this.address = address;
                  }

                  @Override
                  public int hashCode() {
                  final int prime = 31;
                  int result = 1;
                  result = prime * result + ((address == null) ? 0 : address.hashCode());
                  result = prime * result + ((comment == null) ? 0 : comment.hashCode());
                  result = prime * result + ((name == null) ? 0 : name.hashCode());
                  return result;
                  }

                  @Override
                  public boolean equals(Object obj) {
                  if (this == obj)
                  return true;
                  if (obj == null)
                  return false;
                  if (getClass() != obj.getClass())
                  return false;
                  final Person other = (Person) obj;
                  if (address == null) {
                  if (other.address != null)
                  return false;
                  } else if (!address.equals(other.address))
                  return false;
                  if (comment == null) {
                  if (other.comment != null)
                  return false;
                  } else if (!comment.equals(other.comment))
                  return false;
                  if (name == null) {
                  if (other.name != null)
                  return false;
                  } else if (!name.equals(other.name))
                  return false;
                  return true;
                  }

                  public String getComment() {
                  return comment;
                  }

                  public void setComment(String comment) {
                  this.comment = comment;
                  }
                  }

                  • 6. Re: Datascroller and editable datatable
                    ilya_shaikovsky

                    1) RF version?

                    2) place rich:messages to the page.