On Nov 27, 2:53 am, Geraldo Lopes <[EMAIL PROTECTED]> wrote: > The gwt-incubator has PagingScrollTable widget that provides > pagination. if you want to try you can > followhttp://code.google.com/p/google-web-toolkit-incubator/wiki/MakingIncu... > and get the latest version of the project. There are a example, how > use the widget. > > Basically you need...
Thank You. I tried to follow You code and comments as much as possible. But for now my code does not work now :(. Here is it: -------------------- gwt.properties -------------------- # The name of the module to compile gwt.module=unipac.Main # Path of the GWT installation directory.Use Internet-Standard of forward slases for this path gwt.install.dir=D:/Andrey/downloads/java/gwt-windows-1.5.3 # Folder within the web app context path where the output # of the GWT module compilation will be stored. gwt.output.dir=/unipac.client # Script output style: OBF[USCATED], PRETTY, or DETAILED gwt.compiler.output.style=OBF # The level of logging detail: ERROR, WARN, INFO, TRACE, DEBUG, gwt.compiler.logLevel=WARN # Script output style: OBF[USCATED], PRETTY, or DETAILED gwt.shell.output.style=OBF # The level of logging detail: ERROR, WARN, INFO, TRACE, DEBUG, gwt.shell.logLevel=WARN ==================================================================================================== persistence.xml ==================================================================================================== <?xml version="1.0" encoding="UTF-8"?> <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/ persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"> <persistence-unit name="test" transaction-type="RESOURCE_LOCAL"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <exclude-unlisted-classes>false</exclude-unlisted-classes> <properties> <property name="hibernate.connection.username" value="banalyse01"/> <property name="hibernate.connection.driver_class" value="oracle.jdbc.OracleDriver"/> <property name="hibernate.connection.password" value="banalyse01"/> <property name="hibernate.connection.url" value="jdbc:oracle:thin:banalyse01/[EMAIL PROTECTED]:1521:PROD01"/> <property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/> </properties> </persistence-unit> </persistence> ==================================================================================================== ==================================================================================================== web.xml ==================================================================================================== <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <servlet> <servlet-name>Serviso</servlet-name> <servlet-class>unipac.server.ServisoImpl</servlet-class> </servlet> <servlet-mapping> <servlet-name>Serviso</servlet-name> <url-pattern>/serviso</url-pattern> </servlet-mapping> <session-config> <session-timeout> 30 </session-timeout> </session-config> <welcome-file-list> <welcome-file>welcomeGWT.html</welcome-file> </welcome-file-list> </web-app> ==================================================================================================== ==================================================================================================== Main.gwt ==================================================================================================== <?xml version="1.0" encoding="UTF-8"?> <module> <inherits name="com.google.gwt.user.User"/> <inherits name='com.google.gwt.widgetideas.WidgetIdeas'/> <inherits name='com.google.gwt.widgetideas.ScrollTable'/> <!-- Specify the app entry point class. --> <entry-point class="unipac.client.MainEntryPoint"/> <!-- Additional source path --> <source path='domain'/> <source path='client'/> <servlet path="/servico" class="unipac.server.servisoImpl"/> </module> ==================================================================================================== ==================================================================================================== package unipac.client; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.widgetideas.table.client.TableModel; import com.google.gwt.widgetideas.table.client.TableModel.Request; import com.google.gwt.widgetideas.table.client.TableModel.SerializableResponse; import unipac.domain.Cliente; public class ClienteTableModel extends TableModel<Cliente> { public ClienteTableModel() { } @Override public void requestRows( final Request request, final Callback<Cliente> callback) { Servico.Util.getInstance().requestRows(request, null, new AsyncCallback<SerializableResponse<Cliente>>() { public void onFailure(Throwable caught) { callback.onFailure(new Exception("falha rpc")); } public void onSuccess (SerializableResponse<Cliente> result) { callback.onRowsReady(request, result); } }); } @Override protected boolean onRowInserted(int beforeRow) { throw new UnsupportedOperationException("Not supported yet."); } @Override protected boolean onRowRemoved(int row) { throw new UnsupportedOperationException("Not supported yet."); } @Override protected boolean onSetData(int row, int cell, Object data) { throw new UnsupportedOperationException("Not supported yet."); } } ==================================================================================================== ==================================================================================================== /* * unipacEntryPoint.java * */ package unipac.client; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.SimplePanel; import com.google.gwt.widgetideas.table.client.FixedWidthFlexTable; import com.google.gwt.widgetideas.table.client.FixedWidthGrid; import com.google.gwt.widgetideas.table.client.PagingScrollTable; import com.google.gwt.widgetideas.table.client.ScrollTable; /** * * @author Andrey.Siver */ public class MainEntryPoint implements EntryPoint { /** Creates a new instance of unipacEntryPoint */ public MainEntryPoint() { } /** * The entry point method, called automatically by loading a module * that declares an implementing class as an entry-point */ public void onModuleLoad() { FixedWidthFlexTable headerTable = new FixedWidthFlexTable(); headerTable.setText(0, 0, "Col1"); headerTable.setText(0, 1, "Col2"); headerTable.setText(0, 2, "Col3"); ClienteTableModel tableModel = new ClienteTableModel(); FixedWidthGrid dataTable = new FixedWidthGrid(); PagingScrollTable pagingScrollTable = new PagingScrollTable (tableModel, dataTable, headerTable); pagingScrollTable.reloadPage(); pagingScrollTable.setVisible(true); pagingScrollTable.setPageSize(10); // pagingScrollTable.setEmptyTableWidget(new HTML( // "There is no data to display")); // Setup the formatting pagingScrollTable.setCellPadding(3); pagingScrollTable.setCellSpacing(0); pagingScrollTable.setResizePolicy (ScrollTable.ResizePolicy.FILL_WIDTH); // pagingScrollTable.setHeight("400px"); pagingScrollTable.setSize("1000px", "450px"); pagingScrollTable.setColumnWidth(0, 150); pagingScrollTable.setColumnWidth(1, 150); pagingScrollTable.setColumnWidth(2, 150); SimplePanel panel = new SimplePanel(); panel.add(pagingScrollTable); RootPanel.get().add(new Label("Begin table")); RootPanel.get().add(pagingScrollTable); RootPanel.get().add(new Label("End table")); } } ==================================================================================================== ==================================================================================================== package unipac.client; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.rpc.RemoteService; import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; import com.google.gwt.user.client.rpc.ServiceDefTarget; import com.google.gwt.widgetideas.table.client.TableModel.Request; import com.google.gwt.widgetideas.table.client.TableModel.SerializableResponse; import unipac.domain.Cliente; @RemoteServiceRelativePath("servico") public interface Servico extends RemoteService { public SerializableResponse<Cliente> requestRows(Request request, Cliente examplo); public static class Util { public static ServicoAsync getInstance() { ServicoAsync service = GWT.create(Servico.class); ServiceDefTarget endpoint = (ServiceDefTarget) service; String moduleRelativeURL = GWT.getModuleBaseURL() + "serviso"; endpoint.setServiceEntryPoint(moduleRelativeURL); return service; } } } ==================================================================================================== ==================================================================================================== package unipac.client; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.widgetideas.table.client.TableModel.Request; import unipac.domain.Cliente; public interface ServicoAsync { public void requestRows(Request request , Cliente examplo , AsyncCallback callback); } ==================================================================================================== ==================================================================================================== package unipac.domain; import java.io.Serializable; import javax.persistence.Basic; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.Table; /** * * @author Andrey.Siver */ @Entity @Table(name = "CLIENTE", catalog = "", schema = "BANALYSE01") @NamedQueries( { @NamedQuery(name = "Cliente.findAll", query = "SELECT c FROM Cliente c"), @NamedQuery(name = "Cliente.findById", query = "SELECT c FROM Cliente c WHERE c.id = :id"), @NamedQuery(name = "Cliente.findByName", query = "SELECT c FROM Cliente c WHERE c.name = :name"), @NamedQuery(name = "Cliente.findByAddress", query = "SELECT c FROM Cliente c WHERE c.address = :address"), @NamedQuery(name = "Cliente.findByDateOfBirthday", query = "SELECT c FROM Cliente c WHERE c.dateOfBirthday = :dateOfBirthday") }) public class Cliente implements Serializable { private static final long serialVersionUID = 1L; @Id @Basic(optional = false) @Column(name = "ID", nullable = false, precision = 38, scale = 0) private Integer id; @Column(name = "NAME", length = 100) private String name; @Column(name = "ADDRESS", length = 100) private String address; @Column(name = "DATE_OF_BIRTHDAY") private Long dateOfBirthday; public Cliente() { } public Cliente(Integer id) { this.id = id; } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } 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; } public Long getDateOfBirthday() { return dateOfBirthday; } public void setDateOfBirthday(Long dateOfBirthday) { this.dateOfBirthday = dateOfBirthday; } @Override public int hashCode() { int hash = 0; hash += (id != null ? id.hashCode() : 0); return hash; } @Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof Cliente)) { return false; } Cliente other = (Cliente) object; if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) { return false; } return true; } @Override public String toString() { return "domain.Cliente[id=" + id + "]"; } } ==================================================================================================== ==================================================================================================== package unipac.server; import javax.persistence.EntityManager; import unipac.CONSTANTS; import javax.persistence.EntityManagerFactory; import javax.persistence.Persistence; /** * * @author Andrey.Siver */ public class CommonEntityManager { static protected EntityManagerFactory emf; static EntityManager em; public static EntityManagerFactory getEmf () { if (emf == null) { emf = Persistence.createEntityManagerFactory (CONSTANTS.EntityManagerFactoryPU); } return emf; } public static EntityManager getEm() { if (em == null) em = getEmf().createEntityManager(); return em; } } ==================================================================================================== ==================================================================================================== package unipac.server; import com.google.gwt.user.server.rpc.RemoteServiceServlet; import com.google.gwt.widgetideas.table.client.TableModel.Request; import com.google.gwt.widgetideas.table.client.TableModel.SerializableResponse; import unipac.domain.Cliente; import javax.persistence.EntityManager; import javax.persistence.Query; import unipac.client.Servico; public class ServicoImpl extends RemoteServiceServlet implements Servico { public SerializableResponse<Cliente> requestRows(Request request, Cliente qbe) { SerializableResponse result = null; EntityManager entityManager = CommonEntityManager.getEm(); entityManager.getTransaction().begin(); Query q = entityManager.createQuery("from Cliente c"); q.setMaxResults(request.getNumRows()); q.setFirstResult(request.getStartRow()); entityManager.getTransaction().commit(); result = new SerializableResponse<Cliente>(q.getResultList()); System.out.println("I'm here"); return result; } } ==================================================================================================== And since there is no debug possibilities in NetBeans for GWT project (neither server nor client -side code), or I did not make it work, I have no idea, what may be wrong. Application just shows headers :(. Regards, -Andrey --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---
