Announcement

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

    How to hang params on DSRequest generated by editable ListGrid

    I have a SQLDataSource that needs some extra parameters passed to it for all operations. I'm loading records from the datasource into a ListGrid for editing. On the fetch I'm manually adding the parameters using DSRequest.setParams() and using the version of fetchData() that takes a customized DSRequest object. My question is, how to I customize the DSRequest that is generated automatically by the ListGrid when a row is updated or added?

    #2
    You probably want to intercept this server-side. You can tell the request is coming from a particular ListGrid by setting a fetchOperation on that grid, which will then arrived as dsRequest.operationId.

    Comment


      #3
      It isn't enough that I know which grid sent the request. I need to pass a variable bit of data from the client. I've tried calling DataSource.setDefaultParams() on the datasource the grid is bound to. That seems like it is exactly what I need. But the DSRequest I receive doesn't have the params.
      Last edited by jay.l.fisher; 5 Jul 2010, 15:23.

      Comment


        #4
        setDefaultParams() isn't a particularly good approach here since it depends on knowing exactly when the grid initiates requests (which could be messy with paging).

        You could instead call setEditValue() to add extra values to the data saved with each edited row.

        Comment


          #5
          The data I need to pass is not something unique to each row. It really is a datasource level variable that gets referred to in Velocity template in the ds.xml. The server needs it on every DSRequest for that datasource, not at the row level. That sounds like what setDefaultParams() is for, correct?

          I was hoping for some way to customize the DSRequests that a particular ListGrid generates, but if that isn't possible, a way to customize all DSRequests for the datasource will do. I've tried setDefaultParams on the data source, but no params are getting passed on the DSRequests. Is there more to it that simply calling DataSource.setDefaultParams(map)?
          Last edited by jay.l.fisher; 6 Jul 2010, 13:16.

          Comment


            #6
            True, setEditValues() would produce a (relatively trivial) amount of extra data. We can look into setDefaultParams not behaving as expected if you can create a test case to try out.

            Comment


              #7
              I asked the same question here http://forums.smartclient.com/showthread.php?t=12124. I was told setDefaultParams is the way to go. However I am not seeing parameters I pass

              Comment


                #8
                I've tried adding setDefaultParams() in a couple of different places and don't see the params showing up on the request in any of them. Here is a relatively simple one.
                Code:
                DataSource ipMrVenDS = DataSource.get("IPMRVEN");
                myVendorGrid = new ListGrid();
                myVendorGrid.setHeight100();
                myVendorGrid.setWidth100();
                myVendorGrid.setDataSource(ipMrVenDS);
                Map extras = new HashMap();
                extras.put("MyParameter", "Where are you?");
                ipMrVenDS.setDefaultParams(extras);
                myVendorGrid.setFields(new ListGridField("VVEN"),
                		new ListGridField("VNAM"));
                myVendorGrid.setShowFilterEditor(true);
                myVendorGrid.setAutoFetchData(false);
                When I use the filter editor to initiate a fetch on the ListGrid I get this DSRequest in the dev console. No params.
                Code:
                {
                    "actionURL":"http://127.0.0.1:8888/ipgui/sc/IDACall", 
                    "showPrompt":true, 
                    "prompt":"Finding Records that match your criteria...", 
                    "transport":"xmlHttpRequest", 
                    "promptStyle":"dialog", 
                    "bypassCache":true, 
                    "data":{
                        "criteria":{
                        }, 
                        "operationConfig":{
                            "dataSource":"IPMRVEN", 
                            "repo":null, 
                            "operationType":"fetch", 
                            "textMatchStyle":"substring"
                        }, 
                        "startRow":0, 
                        "endRow":75, 
                        "componentId":"isc_IpListGrid_13", 
                        "appID":"builtinApplication", 
                        "operation":"IPMRVEN_fetch", 
                        "oldValues":{
                        }
                    }
                }

                Comment


                  #9
                  Just checking - you do realize they are HTTP parameters? They'd be in the URL, not the request body, and you would access them via httpServletRequest.getParameter().

                  Comment


                    #10
                    I see. That's where I was mistaken. Can those be accessed by Velocity code in the ds.xml the way that DSRequest.setParams() can?

                    Comment


                      #11
                      Yes - the servletRequest is one of the available variables.

                      Comment


                        #12
                        I realized that right after asking the question. But I still don't see them anywhere. In the Velocity code I'm using $httpParameters.FileGroupSuffix to reference the param I'm setting with setDefaultParams() and it is empty.

                        I'll try changing it to $servletRequest.getParameter("FileGroupSuffix"). Is that the right format? Or do I not need the quotes?

                        Comment


                          #13
                          $servletRequest.getParameter("FileGroupSuffix") doesn't work and neither does $servletRequest.getParameter(FileGroupSuffix).

                          Comment


                            #14
                            Is this a bug or could I be doing something wrong? My code is pretty simple, but if I should try something different please let me know. I'm stuck.

                            Comment


                              #15
                              I hate to be a pest but I really need to get this working. Any advice on what to try next? Any additional info needed from me?

                              Comment

                              Working...
                              X