1. #1
    Sencha User
    Join Date
    May 2010
    Posts
    15
    Vote Rating
    0
    marvic is on a distinguished road

      0  

    Default GXT3 Grid. How load data from remote server ?

    GXT3 Grid. How load data from remote server ?


    Hi.


    I want to load data from a remote DB server in the grid.
    The following code:
    Code:
                        final RepServiceAsync service = GWT.create(RepService.class);
                        final RepProperties props = GWT.create(RepProperties.class);
    
    
                RpcProxy<PagingLoadConfig, PagingLoadResult<ReportsList>> proxy = new RpcProxy<PagingLoadConfig, PagingLoadResult<ReportsList>>() {
                    @SuppressWarnings("unchecked")
                    @Override
                    public void load(PagingLoadConfig loadConfig, AsyncCallback  callback) {
                      service.getReports(callback);
                    }
                  };
    
    
                ListStore<ReportsList> store = new ListStore<ReportsList>(props.key());
                final PagingLoader<PagingLoadConfig, PagingLoadResult<ReportsList>> loader = new PagingLoader<PagingLoadConfig, PagingLoadResult<ReportsList>>(
                        proxy);
    
    
                loader.setRemoteSort(true);
                loader.addLoadHandler(new LoadResultListStoreBinding<PagingLoadConfig, ReportsList, PagingLoadResult<ReportsList>>(
                        store));
    
    
                final PagingToolBar toolBar = new PagingToolBar(50);
                toolBar.getElement().getStyle().setProperty("borderBottom", "none");
                toolBar.bind(loader);
    
    
                ColumnConfig<ReportsList, String> nameCol = new ColumnConfig<ReportsList, String>(
                        props.name(), 150, "Name");
                ColumnConfig<ReportsList, String> pathCol = new ColumnConfig<ReportsList, String>(
                        props.path_name(), 150, "Path");
    
    
                List<ColumnConfig<ReportsList, ?>> l = new ArrayList<ColumnConfig<ReportsList, ?>>();
                l.add(nameCol);
                l.add(pathCol);
    
    
                ColumnModel<ReportsList> cm = new ColumnModel<ReportsList>(l);
    
    
                Grid<ReportsList> grid = new Grid<ReportsList>(store, cm) {
                    @Override
                    protected void onAfterFirstAttach() {
                        super.onAfterFirstAttach();
                        Scheduler.get().scheduleDeferred(new ScheduledCommand() {
                            @Override
                            public void execute() {
                                loader.load();
                            }
                        });
                    }
                };
    
    
                grid.getView().setForceFit(true);
                grid.setLoadMask(true);
                grid.setLoader(loader);
    RepProperties:
    Code:
    public interface RepProperties extends PropertyAccess<ReportsList> {
        @Path("id")
        ModelKeyProvider<ReportsList> key();
        ValueProvider<ReportsList, String> name();
        ValueProvider<ReportsList, String> path_name();
    }
    ReportsList code:

    Code:
    public class ReportsList  implements Serializable {
        private static final long serialVersionUID = 1L;
        @Id
        int id;
        String name;
        String path_name;
        
        public ReportsList() {        
        }
        
        public ReportsList(int id, String name, String path_name) {
            super();
            this.id = id;
            this.name = name;
            this.path_name = path_name;
        }
        
        public int getId() {
            return id;
        }
        public void setId(int id) {
            this.id = id;
        }
        public String getName() {
            return name;
        }
        public void setName(String name) {
            this.name = name;
        }
        public String getPath_name() {
            return path_name;
        }
        public void setPath_name(String path_name) {
            this.path_name = path_name;
        }
    }
    Code:
    public class RepServiceImpl extends RemoteServiceServlet implements RepService {
        
        private static final long serialVersionUID = 1L;
        @EJB
        private ReportEjb repManager;
    
    
        @Override
        public List<ReportsList> getReports() {
            List<ReportsList> reports = null;  
            reports = repManager.getReports();
            return reports;
        }
    }
    EJB implementation:
    Code:
    @Stateless
    public class ReportEjbBean implements ReportEjb {
    
        @Resource(name = "java:jboss/datasources/gl_sec")
        private DataSource dataSource;
        private Connection con;
    
    
        @PostConstruct
        public void initialize() {
            try {
                con = dataSource.getConnection();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        
        @PreDestroy
        public void ceanup() {
            try {
                con.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    
    
        @Override
        public List<ReportsList> getReports() {
            ArrayList<ReportsList> repList = new ArrayList<ReportsList>();
            String selectSQL = "SELECT id, name, path_name  FROM gl_reports";
            try {
                PreparedStatement preparedStatement = con
                        .prepareStatement(selectSQL);
                ResultSet rs = preparedStatement.executeQuery(selectSQL);
                while (rs.next()) {
                    repList.add(new ReportsList(rs.getInt("id"), rs.getString("name"), rs
                            .getString("path_name")));
                }
            } catch (SQLException e) {
                e.printStackTrace();
            }
            return repList;
        }
    }
    The code is executed without error, the query to the database is performed (EJB-call),
    service.getReports (callback); - performed, but the Store is empty and Grid is not populated. Where should fill a Store?
    In what could be the problem? Can somebody help?

  2. #2
    Ext GWT Premium Member icfantv's Avatar
    Join Date
    Sep 2011
    Location
    Superior, CO
    Posts
    411
    Vote Rating
    21
    icfantv will become famous soon enough icfantv will become famous soon enough

      0  

    Default


    Please do not cross post your questions. See my response to your other thread here: http://www.sencha.com/forum/showthre...nnot-fill-Grid

Thread Participants: 1

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi