Announcement

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

    Some trouble with server-side oldValues...

    Hi

    i have a problem with Float fields inside the oldValues collection at the server-side RPCRequest object.

    if the Float's value is for instance 137.0 - it becomes a Long with the value of 137 inside the oldValues collection. Inside the data collection however it becomes a Double with the value of 137.0 which i think is the right behavior.

    if the Float has a value of 137.15 (with decimal digits) in both collections (oldValues and data) it becomes a double with value of 137.15

    i'd like to have always Double values at server-side for client-side Float fields.

    any hints?

    #2
    Hi rothmich,

    That seems like it could only happen if the data was originally delivered to the browser as a Long value (no decimal point) - is that the case?

    Comment


      #3
      Hi Isomorphic,

      thank you for the quick response.

      the following line is copied from console-rpc-response-raw tab and shows a field which has that problem:

      Code:
      minileaseRate:137.0,
      as you can see, the decimal point is there. this is captured from the initial data load of a ListGrid.

      the whole record is handled by a ValuesManager and displayed by some DynamicForms.
      with ValuesManager.saveData() the record has been sent to the server with the described behavior
      for the Float fields.

      this is the update request which has been sent (somewhat shortened). as you can see, the field has no decimal point in both collections (values + oldValues).
      the field's value was not edited/changed - just ValuesManager.saveData() was executed.
      Code:
          data:{
              criteria:{
                  id:40
              }, 
              values:{
                  id:40, 
                  minileaseRate:137, 
              }, 
              operationConfig:{
                  dataSource:"VehicleDataSource", 
                  operationType:"update"
              }, 
              appID:"builtinApplication", 
              operation:"VehicleDataSource_update", 
              oldValues:{
                  id:40, 
                  minileaseRate:137, 
              }
          }
      as already told, the oldValues field becomes a Long and the values field becomes a Double at the server-side.
      Last edited by rothmich; 29 Dec 2008, 14:31.

      Comment


        #4
        any more ideas, where this problem could be sourced from?

        I'd greatly appreciate any hint.

        Comment


          #5
          Hi rothmich,

          The problem is basically that on the client side there is no distinction between a Float and a Long (there is only Number).

          A somewhat circuitous way to ensure that the oldValues match your DataSource field types would be to form a new DSRequest() from them and validate that. This changes the values to the appropriate types if they are not already.

          Comment


            #6
            Hi Isomorphic,

            many thanks for solving my problem.

            maybe someone likes a sample:

            Code:
                public static Map<String,Object> extractOldValues(DSRequest dsRequest) {
                    DSRequest localDSRequest = new DSRequest(dsRequest.getDataSourceName(),
                                                             dsRequest.getOperationType());
                    localDSRequest.setValues(dsRequest.getOldValues());
                    try {
                        localDSRequest.validate();
                    } catch(Exception ex) {
                        System.out.println(ex.getMessage());
                        ex.printStackTrace();
                    }
                    return localDSRequest.getValues();
                }

            Comment

            Working...
            X