Announcement

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

    #16
    ok thanks for that.

    So i'm searching how to mke that work. I read the documentation you provided me with the link, but I don't find any sample to see how it work in practice. Every sample in the showcase is with hardcoded XML data ...

    Where can I find such an example?

    Comment


      #17
      There is really no difference. The DataURL is where to fetch data. It can be an XML file already formatted in the desired structure or a servlet or other web service that will pull data from a database and returns it. The samples avoid the need for running a database just to see the samples. Search/filter parameters are passed formatted according to your operational bindings.

      Comment


        #18
        ok, bu if i put a servlet in the dataUrl, the servlet's output have to be formatted in XML isn't it?

        Comment


          #19
          XML or JSON as specified by your operational bindings. Other formats can be used but you will have to parse them yourself in a derived data source class.

          Comment


            #20
            hum ... I tryied this but it does not work as I expect ...
            maybe I'm doing someting wrong, but I don't know what ...
            here is my datsource code :
            Code:
            public class TransportResultDataSource extends DataSource {
            
            	private static TransportResultDataSource instance = null ;
            	
            	public static TransportResultDataSource getInstance() {
            		if (instance == null) {  
            			instance = new TransportResultDataSource();  
            		}  
            		return instance; 
            	}
            	
            	private TransportResultDataSource() {
            		this.setID("transportResult");
            		this.setRecordXPath("/List/transportResult"); 
            		DataSourceTextField ituCode = new DataSourceTextField("itucode","Itu Code");
            		DataSourceTextField lastStatus = new DataSourceTextField("lastStatus","Last Status");
            		DataSourceTextField terminals = new DataSourceTextField("terminals","Departure Terminal<br/>Destination Terminal<br/>Final Terminal");
            		DataSourceTextField fullOrEmpty = new DataSourceTextField("fullOrEmpty","Full/Empty");
            		DataSourceTextField weights = new DataSourceTextField("weights","Net Weight (kg)<br/>Gross Weight(kg)");
            		DataSourceTextField statusDate = new DataSourceTextField("statusDate","Status Date");
            		DataSourceTextField departureDate = new DataSourceTextField("departureDate","Departure Date");
            		DataSourceTextField actors = new DataSourceTextField("actors","Invoicing<br/>Sender<br/>Receiver");
            		DataSourceTextField refNumbers = new DataSourceTextField("refNumbers","Customer Ref<br/>Operator Ref");
            		DataSourceTextField controlNumbers = new DataSourceTextField("controlNumbers","Ctrl train Number<br/>Railway train number<br/>Wagon number");
            		this.setFields(ituCode,lastStatus,terminals,fullOrEmpty,weights,statusDate,departureDate,actors,refNumbers,controlNumbers);
            		this.setClientOnly(true);
            		this.setDataURL("test_one.xml");
            	}
            }
            When I ask the page .... everything's magically fine!
            But ... when I use this
            Code:
            		class UpdateUrlDataHandler implements ClickHandler, KeyUpHandler {
            			public void onClick(ClickEvent event) {
            				updateData();
            			}
            			public void onKeyUp(KeyUpEvent event) {
            				if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
            					updateData();
            				}
            			}
            			private void updateData() {
            				dataSource.setDataURL("test_"+nameField.getText()+".xml");
            			}
            		}
            		
            		// Add a handler to send the name to the server
            		UpdateUrlDataHandler udh = new UpdateUrlDataHandler();
            		sendButton.addClickHandler(udh);
            		nameField.addKeyUpHandler(udh);
            Nothing changes in my ListGrid ...

            Comment


              #21
              What is your updateData() call supposed to do? For your test case, setting autoFetchData on the grid should result in an initial display of your test data. Be careful of the XPath as this is a common area to have an issue. If you aren't setting autoFetchData, issue a fetchData() on the grid when you want to load it.

              You don't want a client-only datasource if you are issuing multiple fetches to the server (not your example but what you asked for in your flowchart). If your DataURL can accept updates (by default a POST operation), don't try to perform an updateData yourself. The datasource bound to the grid will automatically send updates to the server from editing if allowed. If you want to pull a different set of data (new criteria) for the grid, issue a fetchData(critiera) call on the grid.


              You might want to open the developer console to watch the RPC calls being made between client and server. This will help you see the request formats and responses.

              Comment


                #22
                Owww, I've multiple questions after have read your message

                Originally posted by davidj6
                What is your updateData() call supposed to do?
                My updateData() fuction is supposed to update the XML loaded in the datasource in function of the content of a textbox in my UI. By now I have 2 xmls, and I try to switch the view from one to another (the final purpose is in fact, at last, use the entered values as parameters to a servlet).

                Originally posted by davidj6
                You don't want a client-only datasource if you are issuing multiple fetches to the server (not your example but what you asked for in your flowchart). If your DataURL can accept updates (by default a POST operation), don't try to perform an updateData yourself. The datasource bound to the grid will automatically send updates to the server from editing if allowed. If you want to pull a different set of data (new criteria) for the grid, issue a fetchData(critiera) call on the grid.
                So I shoud use fetchData("myXML.xml") instead of setDataURL() ??


                Originally posted by davidj6
                You might want to open the developer console to watch the RPC calls being made between client and server. This will help you see the request formats and responses.
                The question is stupid but ... how do I enable that?

                Comment


                  #23
                  Let's back up a bit here. Do you have a web service of some sort to provide the data you want to display? Does it take some parameter to define what part to return?

                  fetchData() takes a criteria to apply to the search. For a client-only datasource it can return as subset of your data for display. For a normal, server-connected datasource it can pass the criteria to the server so the correct data can be returned. I thought this was what you wanted based on the flowchart.

                  From your earlier post this is what I thought you wanted:
                  What i wanna do is very simple. I modified the default GWT application to show a ListGrid. When the user enters a text and click on send button, a call to the server is made and returns some data. Next, the data is displayed in the ListGrid.
                  Now, when I make a second call, the new data is not alone in the ListGrid : old data is still there ... What I wanna do is simply remove the old data when the async server call is a success et replace it by the new data ...


                  If this is the case, your DataURL is the URL to your server where data is retrieved - typically a web service of some sort. The fetchData(criteria) call is how you get the data you want into the grid. The criteria is the built from the text the user entered so the server knows what to do.

                  Basically, if you have to do anything more than assign the datasource to the grid and issue fetchData() calls, you're doing too much or the datasource is not correct with regards to your server requirements.

                  Take a look at the adaptive filter example. All data is pulled from a single .xml file and made client-only but filtering of what is shown is achieved by entry above the grid columns. If the DataURL was a web service and the client-only setting removed, a request would be made to the server when the filter criteria changes. This is what you are trying to accomplish albeit possibly with different "criteria".

                  See the SmartGWT FAQ for loading the developer console.

                  Comment


                    #24
                    ok, thanks for those infos.
                    I will try to learn how that works, but I'm afraid I'm completely lost ...
                    Is there any running example of a server or client connected datasource that shows how to integrate that custom calls? It shouldn't be that hard to only do this simple stuff I'm trying since several days...
                    I'm trying the Enterprise Edition too, for that I have the same question, is there a practical example of how the custom datasource work?

                    Another question, to make sure : when a setDataURL is done and loaded, it is not possible to reload the datasource loaded data unless with a page refresh? If it is possible, do you have an example where it is done? Is it possible to add dynamic parameters to that URL?
                    Last edited by romain.vdk; 21 Jun 2010, 04:56.

                    Comment


                      #25
                      ok, I resolved my problem.
                      I had to remove the this.setClientOnly(true); instruction in my datasource and use smartgwt EE.
                      Now a callback with my criteria is sent to the server each time I make such a call :

                      dataSource.fetchData(new Criteria("lastStatus","897"));
                      ==>
                      test_one.xml?lastStatus=897&_operationType=fetch&_dataSource=transportResult

                      Comment


                        #26
                        Hi everybody,

                        After some more experience in smart GWT, I'm wondering if it's possible (I think following what's said in this post it is possible, but I don't know how) to use a RPC call instead of a datasource and have a code similar to which shown in the #9th post ...

                        Comment

                        Working...
                        X