Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Can somebody please look into this ?

    Can somebody please look into this ?
    Please help.

    Comment


      ValuesManager and related DataSources

      I love the Showcase and associated sample code. It has been very helpful. But now I am trying to use gwt-rpc to retrieve hierarchical objects and store them in DynamicForm(s).

      Looking at Alius GwtRpcDataSource code and test cases, I did not see where it was performing a fetch/add/update on hierarchical object. The example shows data being copied to and from a ListGridRecord, but not something like a Record that contains other Record(s) and/or a ListGridRecord. Or does a GwtRpcDataSource create related VirtualDataSource(s) referenced by the forms? I am very confused.

      Plus I want to create reusable form components for objects like Addresses and possibly use them in multiple forms. It would be kind of cool if you could create a FormItem derived class that was essentially an aggregate DynamicForm. So an Address POJO would populate an AddressForm. But I did not see methods that allowed a FormItem to nest sets of focus points, just one.

      A typical example would be a PurchaseOrder POJO that contains billTo and shipTo properties of type Address, and an array of OrderItem instances.

      I do not want a UI that has "Bill To - Address Line 1" as the title for the first field and "Bill To - Address Line 2" as the title for the second field, etc. I would rather have "Bill To" as the title on the far left and then have a reusable AddressForm on the right with "Line 1", "Line 2", "City", "State", and "ZIP" as the title. Ideally, it would be nice if City/State/ZIP could be on the same line.

      And if there were multiple DynamicForms spread across multiple tabs, how does the ValuesManager come into play?

      Are there any larger application examples of SmartGWT such as PetClinic application that might demonstrate some of these techniques?

      Thank you for any help wrapping my head around this.

      Comment


        Server-side paging & sorting now supported by GenericGwtRpcDataSource

        Hi all

        Seeing that some of us had troubles getting server-side paging & sorting to work, I've added this functionality in GenericGwtRpcDataSource, as explained here:

        http://forums.smartclient.com/showth...4370#post44370

        The thread also contains a example project showing the functionality with a ListGrid.

        Feel free to have a look.

        cheers
        marbot

        Comment


          With the current sample implementation it is not possible to update a primary key field. When trying to do this copyValues will throw NullPointerException.

          So how can i update primary key fields?

          Comment


            ****Problem resolve i discover that i was setting the datasource after i set the treegridfields i change this and all works now =D
            *****


            I have use GWT-RPC on listgrid comboboxitem selectitem and work really nice =D

            But recently i try to use it on a Treegrid

            All work fine excepto for one thing it doesnt show the columns i set
            this is how i set my datasource .


            Code:
            	        DataSourceTextField nombre = new DataSourceTextField(menuEnum.NOMBRE.getValue(), menuEnum.NOMBRE.getDesc(), 300);
            	        
            	        DataSourceIntegerField NODEID = new DataSourceIntegerField (menuEnum.NODEID.getValue(),	menuEnum.NODEID.getDesc());
            	        NODEID.setPrimaryKey (true);
            	        NODEID.setRequired (true);
            	        
            	        DataSourceIntegerField  PARENTNODE = new DataSourceIntegerField (menuEnum.PARENTNODE.getValue(),menuEnum.PARENTNODE.getDesc());
            	        PARENTNODE.setForeignKey(id+"."+menuEnum.NODEID.getValue());
            	        PARENTNODE.setRequired (true);
            	        PARENTNODE.setRootValue(0);
            	        
            	        
            	        DataSourceTextField NOMBRE_VISTA = new DataSourceTextField(menuEnum.NOMBRE_VISTA.getValue(), menuEnum.NOMBRE_VISTA.getDesc(), 300);
            	        
            	       setFields(nombre,NODEID,PARENTNODE,NOMBRE_VISTA);


            I test it on a list grid and works , it show the columns

            but on the treegrid it only show one column with the name "Name" , all info shows correct, the problem its the columsn

            Maybe i do something wrong, or treegrid works diferent

            Sorry for my bad english ..

            Thanks
            Last edited by Coolcold; 18 Jun 2010, 13:51.

            Comment


              I found a not so clean solution to my problem. in GwtRpcDataSource i override transform response.
              Code:
                  @Override
                  protected void transformResponse(DSResponse response,
                      DSRequest request,
                      Object data)
                  {
                  	switch(request.getOperationType())
                  	{
                  		case UPDATE:
                  			request.setData(request.getOldValues());
                  			break;
                  	}
                  	super.transformResponse(response, request, data);
                  }
              This gives a warning
              Update operation - submitted record with primary key value[s]:{email: "before@example.com"} returned with modified primary key:{email: "after@example.com"}. This may indicate bad server logic. Updating cache to reflect new primary key.
              I also tried to use response.setInvalidateCache(true) instead of the request.setData(). But this is much slower because a fetch operation is performed.

              Comment


                Smart GWT Guru , please help me !!!!

                I sew lot of examples but I could not refresh my data in ComboboxItem.

                When I type in cobobox item it doesn't refresh data.
                It's calls only once transformRequest.

                I tried set different values
                such as :
                supplyItemDS.setCacheAllData(true);
                supplyItemDS.setAutoCacheAllData(true);
                item.setAutoFetchData(false);
                item.setAutoFetchData(true);

                I can call manually
                supplyItemDS.fetchData();

                but data is still old.

                Could anybode help how I can dynamically refresh my data in datasource and in combobox by typing value in it.

                Thanks

                [CODE]
                class DynamicLoadDataSource extends DataSource {

                public boolean change;

                public DynamicLoadDataSource() {
                setID("dynamicLoadDataSource");
                setDataProtocol (DSProtocol.CLIENTCUSTOM);
                setDataFormat (DSDataFormat.CUSTOM);
                setClientOnly (false);


                DataSourceTextField itemNameField = new DataSourceTextField("itemName", "Item");

                addField(unitCostField);
                }

                protected Object transformRequest (DSRequest request) {
                String requestId = request.getRequestId ();
                DSResponse response = new DSResponse ();
                response.setAttribute ("clientContext", request.getAttributeAsObject ("clientContext"));
                // Asume success
                response.setStatus (0);
                switch (request.getOperationType ()) {
                case FETCH:
                executeFetch (requestId, request, response);
                break;
                }
                return request.getData ();
                }

                protected void executeFetch (final String requestId, final DSRequest request, final DSResponse response) {

                response.setData(getRecords(10))
                processResponse (requestId, response);
                }

                ListGridRecord[] getRecords(int j) {
                ListGridRecord[] result = new ListGridRecord[j];
                ListGridRecord item = null;
                for(int i = 0; i < j; i++) {
                item = new ListGridRecord();
                item.setAttribute("itemID", new Integer(i));
                item.setAttribute("itemName", "item name " + i);
                item.setAttribute("description", "description " + i);
                item.setAttribute("category", "category " + i);
                item.setAttribute("units", "unit " + i);
                item.setAttribute("unitCost", new Float(i));
                result[i] = item;
                }
                return result;
                }

                private void forum() {

                final ComboBoxItem item = new ComboBoxItem("itemID");
                item.setWidth(240);
                item.setTitle("Item");
                item.setValueField("itemName");
                item.setDisplayField("description");
                item.setPickListWidth(450);
                item.setPickListFields(itemField);
                item.setOptionDataSource(supplyItemDS);
                item.setAutoFetchData(false);


                DynamicForm f = new DynamicForm();
                f.setFields(item);
                main.draw();
                }
                }

                [CODE]

                Comment


                  This is my class with the problem.
                  Attached Files

                  Comment


                    Hello, I am trying to make an update with a nested form ( http://www.smartclient.com/smartgwt/showcase/#grid_nested_form ).


                    I am using the GwtRpcDataSource

                    My datasource is the following

                    Code:
                    public class TestDataSource  extends GwtRpcDataSource {
                    
                        public TestDataSource () {
                            DataSourceField field;
                            field = new DataSourceIntegerField ("id", "ID");
                            field.setPrimaryKey (true);
                            field.setRequired (false);
                            addField (field);
                            field = new DataSourceTextField ("name", "NAME");
                            field.setRequired (true);
                            addField (field);
                            field = new DataSourceDateField ("date", "DATE");
                            field.setRequired (false);
                            addField (field);
                        }
                    
                        @Override
                        protected void executeFetch (final String requestId, final DSRequest request, final DSResponse response) {
                    TestServiceAsync service = GWT.create (TestService.class);
                            service.fetch (new AsyncCallback<List<TestRecord>> () {
                                public void onFailure (Throwable caught) {
                                    response.setStatus (RPCResponse.STATUS_FAILURE);
                                    processResponse (requestId, response);
                                }
                                public void onSuccess (List<TestRecord> result) {
                                    ListGridRecord[] list = new ListGridRecord[result.size ()];
                                    for (int i = 0; i < list.length; i++) {
                                        ListGridRecord record = new ListGridRecord ();
                                        copyValues (result.get (i), record);
                                        list[i] = record;
                                    }
                                    response.setData (list);
                                    processResponse (requestId, response);
                                }
                            });
                        }
                    
                        @Override
                        protected void executeAdd (final String requestId, final DSRequest request, final DSResponse response) {
                           JavaScriptObject data = request.getData ();
                            ListGridRecord rec = new ListGridRecord (data);
                            TestRecord testRec = new TestRecord ();
                            copyValues (rec, testRec);
                            TestServiceAsync service = GWT.create (TestService.class);
                            service.add (testRec, new AsyncCallback<TestRecord> () {
                                public void onFailure (Throwable caught) {
                                    response.setStatus (RPCResponse.STATUS_FAILURE);
                                    processResponse (requestId, response);
                                }
                                public void onSuccess (TestRecord result) {
                                    ListGridRecord[] list = new ListGridRecord[1];
                                    ListGridRecord newRec = new ListGridRecord ();
                                    copyValues (result, newRec);
                                    list[0] = newRec;
                                    response.setData (list);
                                    processResponse (requestId, response);
                                }
                            });
                        }
                    
                        @Override
                        protected void executeUpdate (final String requestId, final DSRequest request, final DSResponse response) {
                            JavaScriptObject data = request.getData ();
                            ListGridRecord rec = new ListGridRecord (data);
                            ListGrid grid = (ListGrid) Canvas.getById (request.getComponentId ());
                             int index = grid.getRecordIndex (rec);
                            rec = (ListGridRecord) grid.getEditedRecord (index);
                            TestRecord testRec = new TestRecord ();
                            copyValues (rec, testRec);
                            TestServiceAsync service = GWT.create (TestService.class);
                            service.update (testRec, new AsyncCallback<TestRecord> () {
                                public void onFailure (Throwable caught) {
                                    response.setStatus (RPCResponse.STATUS_FAILURE);
                                    processResponse (requestId, response);
                                }
                                public void onSuccess (TestRecord result) {
                                    ListGridRecord[] list = new ListGridRecord[1];
                                    ListGridRecord updRec = new ListGridRecord ();
                                    copyValues (result, updRec);
                                    list[0] = updRec;
                                    response.setData (list);
                                    processResponse (requestId, response);
                                }
                            });
                        }
                    
                        @Override
                        protected void executeRemove (final String requestId, final DSRequest request, final DSResponse response) {
                            JavaScriptObject data = request.getData ();
                            final ListGridRecord rec = new ListGridRecord (data);
                            TestRecord testRec = new TestRecord ();
                            copyValues (rec, testRec);
                            TestServiceAsync service = GWT.create (TestService.class);
                            service.remove (testRec, new AsyncCallback () {
                                public void onFailure (Throwable caught) {
                                    response.setStatus (RPCResponse.STATUS_FAILURE);
                                    processResponse (requestId, response);
                                }
                                public void onSuccess (Object result) {
                                    ListGridRecord[] list = new ListGridRecord[1];
                                    list[0] = rec;
                                    response.setData (list);
                                    processResponse (requestId, response);
                                }
                    
                            });
                        }
                    
                        private static void copyValues (ListGridRecord from, TestRecord to) {
                            to.setId (from.getAttributeAsInt ("id"));
                            to.setName (from.getAttributeAsString ("name"));
                            to.setDate (from.getAttributeAsDate ("date"));
                        }
                    
                        private static void copyValues (TestRecord from, ListGridRecord to) {
                            to.setAttribute ("id", from.getId ());
                            to.setAttribute ("name", from.getName ());
                            to.setAttribute ("date", from.getDate ());
                        }
                    }
                    And my entry point class :
                    Code:
                    public class ProbandoDataSource implements EntryPoint {
                    
                    	public void onModuleLoad() {
                    
                    		final DataSource dataSource = new TestDataSource();
                    
                    		final ListGrid listGrid = new ListGrid() {
                    			@Override
                    			protected Canvas getExpansionComponent(final ListGridRecord record) {
                    
                    				final ListGrid grid = this;
                    				VLayout layout = new VLayout(2);
                    				
                    				final DynamicForm df = new DynamicForm();
                    				df.setNumCols(2);
                    				df.setDataSource(dataSource);
                    
                    				df.addDrawHandler(new DrawHandler() {
                    					public void onDraw(DrawEvent event) {
                    						df.editRecord(record);
                    					}
                    				});
                    
                    				IButton saveButton = new IButton("Save");
                    				saveButton.addClickHandler(new ClickHandler() {
                    					public void onClick(ClickEvent event) {
                    						 df.saveData();
                    //I m using this to  update the record on the grid ( the view)
                    	record.setAttribute("id", (Integer) df.getValue("id"));
                    	record.setAttribute("name", (String) df.getValue("name"));
                    	record.setAttribute("date", (Date) df.getValue("date"));
                    
                    //dataSource.updateData(record); fails
                    // grid.updateData(record); fails		
                    			}
                    				});
                    
                    				IButton cancelButton = new IButton("Done");
                    				cancelButton.addClickHandler(new ClickHandler() {
                    					public void onClick(ClickEvent event) {
                    						grid.collapseRecord(record);
                    					}
                    				});
                    
                    				HLayout hLayout = new HLayout(10);
                    				hLayout.addMember(saveButton);
                    				hLayout.addMember(cancelButton);
                    
                    				layout.addMember(df);
                    				layout.addMember(hLayout);
                    				return layout;
                    			}
                    		};
                                    listGrid.setCanExpandRecords(true);
                    		listGrid.setAutoFetchData(true);
                    		listGrid.setDataSource(dataSource);
                    
                    		ListGridField itemNameField = new ListGridField("name");
                    		ListGridField skuField = new ListGridField("id");
                    
                    		listGrid.setFields(itemNameField, skuField);
                    
                    		listGrid.draw();
                    	}
                    
                    }
                    My problem is that when I am press the save button this error is shown :


                    Java.lang.ClassCastException: com.smartgwt.client.widgets.form.DynamicForm cannot be cast to com.smartgwt.client.widgets.grid.ListGrid
                    at datasource.example.client.TestDataSource.executeUpdate(TestDataSource.java:98).

                    When I tried with

                    Code:
                    dataSource.updateData(record); 
                     grid.updateData(record);
                    This error is shown

                    Java.lang.NullPointerException: null
                    at datasource.example.client.TestDataSource.executeUpdate(TestDataSource.java:100)

                    Thas anyone knows how to solve my error?
                    Thanks!

                    PD: When I dont use the expanded nested form , and I update with
                    grid.setCanEdit(true); , it works perfectly

                    Comment


                      Hi

                      I have implemented the gwt-RPC DataSource as Alius described in this thread. I have created a delete Button which should remove the selected records in the grid:

                      Code:
                       IButton buttonDel = new IButton("delete invoices");
                      		buttonDel.addClickHandler(new ClickHandler() {
                      			public void onClick(ClickEvent event) {
                      				ListGridRecord[] recordsToDelete = openInvoicesGrid
                      						.getSelection();
                      				for (ListGridRecord record : recordsToDelete) {
                      					datasource.removeData(record);
                      				}
                      			}
                      		});
                      		canvas.addChild(buttonDel);
                      But nothing happens. How can I fire the remove method implementation?

                      Comment


                        Originally posted by asdfasldkfj
                        Smart GWT Guru , please help me !!!!

                        I sew lot of examples but I could not refresh my data in ComboboxItem.

                        When I type in cobobox item it doesn't refresh data.
                        It's calls only once transformRequest.

                        I tried set different values
                        such as :
                        supplyItemDS.setCacheAllData(true);
                        supplyItemDS.setAutoCacheAllData(true);
                        item.setAutoFetchData(false);
                        item.setAutoFetchData(true);

                        I can call manually
                        supplyItemDS.fetchData();

                        but data is still old.

                        Could anybode help how I can dynamically refresh my data in datasource and in combobox by typing value in it.

                        Thanks
                        Hello,
                        I am facing the same problem, transformRequest is called only once
                        did you solve the problem ??

                        Comment


                          ListGrid grid = (ListGrid) Canvas.getById(request.getComponentId());



                          How can I solve this problem?

                          Comment


                            Hi.. has anyone found a solution for this problem. I have run into the same issue and have not found any solution. I am gwt2.2.

                            Originally posted by ron.lawrence
                            Same exact error here, using GWT 2.0.1 and the latest ee trial, but I'm not using a datasource at all, just invoking a Gwt Rpc service directly with

                            Code:
                            XXXService.Util.getInstance().doit(arg, callback)
                            where arg is just an object with a list of other objects, all of which implement Serializable. When I print this with GWT.log I get the extra string "null" after the exception in the stack trace.

                            It looks like (http://www.docjar.com/html/api/com/google/gwt/user/client/rpc/impl/SerializerBase.java.html) the "serialize" and later "check" method is getting a null value somehow. Not sure if this is a result of anything related to smartclient or not. I'm planning to experiment with this in another non-smartclient project today to see if I can recreate it there.

                            Comment


                              Hi.. has anyone found a solution for this problem. I have run into the same issue and have not found any solution. I am using gwt2.2.


                              Originally posted by kvb
                              Hi all,

                              First off: thanks so much for this discussion, it helped me a great lot with getting GWT-RPC datasources working.

                              The only problem I still have left is fetching data using Criteria. I've looked at and tried the example from this thread with the GWTCriterion class, but I'm getting this error when I'm running it:

                              Code:
                              [ERROR] com.google.gwt.user.client.rpc.SerializationException
                              [ERROR] 	at com.google.gwt.user.client.rpc.impl.SerializerBase.check(SerializerBase.java:161)
                              [ERROR] 	at com.google.gwt.user.client.rpc.impl.SerializerBase.serialize(SerializerBase.java:145)
                              [ERROR] 	at com.google.gwt.user.client.rpc.impl.ClientSerializationStreamWriter.serialize(ClientSerializationStreamWriter.java:199)
                              [ERROR] 	at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:129)
                              [ERROR] 	at nl.kees.test.db.client.util.criteria.GWTCriterion_FieldSerializer.serialize(GWTCriterion_FieldSerializer.java:32)
                              [ERROR] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                              [ERROR] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                              [ERROR] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                              [ERROR] 	at java.lang.reflect.Method.invoke(Method.java:592)
                              [ERROR] 	at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
                              [ERROR] 	at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
                              [ERROR] 	at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157)
                              [ERROR] 	at com.google.gwt.dev.shell.BrowserChannel.reactToMessagesWhileWaitingForReturn(BrowserChannel.java:1713)
                              [ERROR] 	at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:165)
                              [ERROR] 	at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120)
                              [ERROR] 	at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507)
                              [ERROR] 	at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:284)
                              [ERROR] 	at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107)
                              [ERROR] 	at com.google.gwt.user.client.rpc.impl.SerializerBase$MethodMap$.serialize$(SerializerBase.java)
                              [ERROR] 	at com.google.gwt.user.client.rpc.impl.SerializerBase.serialize(SerializerBase.java:147)
                              [ERROR] 	at com.google.gwt.user.client.rpc.impl.ClientSerializationStreamWriter.serialize(ClientSerializationStreamWriter.java:199)
                              [ERROR] 	at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:129)
                              [ERROR] 	at nl.kees.test.db.client.admin.AdminDataService_Proxy.fetch(AdminDataService_Proxy.java:52)
                              [ERROR] 	at nl.kees.test.db.client.util.DynamicDataSource.executeFetch(DynamicDataSource.java:90)
                              [ERROR] 	at nl.kees.test.db.client.util.GwtRpcDataSource.transformRequest(GwtRpcDataSource.java:105)
                              [ERROR] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                              [ERROR] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                              [ERROR] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                              [ERROR] 	at java.lang.reflect.Method.invoke(Method.java:592)
                              [ERROR] 	at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
                              [ERROR] 	at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
                              [ERROR] 	at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157)
                              [ERROR] 	at com.google.gwt.dev.shell.BrowserChannel.reactToMessages(BrowserChannel.java:1668)
                              [ERROR] 	at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:401)
                              [ERROR] 	at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222)
                              [ERROR] 	at java.lang.Thread.run(Thread.java:595)

                              I read somewhere that since GWT 2.0 (which I'm using), the IsSerializable is re-introduced instead of the regular Serializable, which might make this old example to crash?

                              Does anyone have this working (GWT-RPC fetching with Criteria) in GWT 2.0?

                              Thanks for any help!

                              Regards,

                              Kees.

                              Comment


                                Does anybody have code posted by bitblaster on 3rd Apr 2009, 02:10 ?
                                It's having server side pagination and filtering.

                                Comment

                                Working...
                                X