Announcement

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

    DSRequest.setOmitNullMapValuesInResponse() appears to do nothing.

    Hello,
    I could use a little clarification on setOmitNullMapValuesInResponse() because it appears to have no impact on the data in the response.

    I'm using SmartGWT 3.1p v8.3p_2013-04-01/PowerEdition Deployment with Firefox 10.

    Lets say I run a query against a table
    Code:
     Select emp_id, first_name, last_name, dob from emp order by emp_id
    and the data in the emp table is:

    Code:
    emp_id     first_name     last_name          title
    1             bob            smith           null
    2             jim            jones          mr
    3             fred           jones          mr
    In the Developer Consol when I track RPC's I can see the Response is:

    Code:
    data:[
    	{
    		emp_id:1,
    		first_name:"bob",
    		last_name:"smith"
    	},
    	{
    		emp_id:2,
    		first_name:"jim",
    		last_name:"jones",
    		title:"mr"
    	},
    	{
    		emp_id:3,
    		first_name:"fred",
    		last_name:"jones",
    		title:"mr"
    	}
    ]
    My question is, for emp_id 1 why does the response not look like this:

    Code:
    	{
    		emp_id:1,
    		first_name:"bob",
    		last_name:"smith",
    		[b]title:null[/b] 
    	},
    I would like the title:null attribute to appear. I was thinking that setOmitNullMapValuesInResponse(false) would make that happen but it does not. It there a way to get the response to return the null attributes? Please let me know if you need any other information.

    #2
    omitNullMapValuesInResponse affects what happens when values are supplied as Maps.

    Currently, the only way to take a null DB column and have it delivered to the client would be to add DMI logic that adds an explicit null key to the records (via dsResponse.getData(), modifying the data, then calling dsResponse.setData()).

    Comment


      #3
      Ok, thanks for the clarification. I will try the approach you described.

      Comment


        #4
        I have utilized the approach you described and was able to get it to work. As a follow on question, on the server I call:

        List<Map<String, Object>> recordList = dsResponse.getData();

        as you describe, then iterate over recordList to modify as needed. How is the order of keys in the map determined on a per record basis? The Map is not in the order of the select clause, table structure, alphabetical, or any other pattern that I could think of. Is this just determined randomly? And is there any way to change the order?

        Comment


          #5
          There's no particular order, as a HashMap is being used.

          Comment


            #6
            Ahh, I see. Ok thanks.

            Comment


              #7
              Hello, I was just trying the omitNullMapValuesInResponse and I've found this thread.

              I'm not sure I understand correctly this sentence:
              Originally posted by Isomorphic View Post
              omitNullMapValuesInResponse affects what happens when values are supplied as Maps.
              do you mean that it has no effect when doing a fetch which returns a list of maps? (which was the effect I was looking for)

              Comment


                #8
                Yes, when doing a fetch that provides a List of Maps, omitNullMapValuesInResponse takes effect.

                It has no effect when data is delivered as beans.

                It has no effect on what happens in the SQL query.

                Comment


                  #9
                  thanks, actually I didn't succeed in delivering nulls to client, but I see in the docs that:
                  Code:
                  [LIST][*]SQL nulls never make it to dsResponse.data[/LIST]
                  So, since I'm using SQLDataSource, I think it's not feasible, right?

                  Comment


                    #10
                    You could manually inject the nulls into dsResponse.data with a DMI if you want, however, delivering that extra data seems a bit of a waste; the property omitNullMapValuesInResponse is there to *remove* nulls, to avoid such data being sent needlessly.

                    Comment

                    Working...
                    X