Announcement

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

    ValueMap for Boolean error

    Hi,

    I've noticed a render error when I used a valueMap for boolean. See screenshots attached.

    My goal is to store and load boolean but present it to the user as option either Active or Inactive in a SelectItem.

    Code:
    		<field name="active" type="boolean" >
    			<valueMap>
    				<value ID="true">Active</value>
    				<value ID="false">Inactive</value>
    			</valueMap>
    		</field>
    Code:
    statusItem = new SelectItem("active", "Status");
    When there is an empty form the the selectItem renders correctly. But when I load a record into it the it renders 3 values: Active, Active and Inctive.

    The documentation mentions at a page 22:
    Field attribute -> Form control
    valueMap provided -> SelectItem (dropdown)
    type boolean -> CheckboxItem (checkbox)

    if I leave out the type definition the it behaves slightly better. The error from second screenshot dosappears but the first on is still present.

    Code:
    		<field name="active">
    			<valueMap>
    				<value ID="true">Active</value>
    				<value ID="false">Inactive</value>
    			</valueMap>
    		</field>
    I use smartGWT 2011-07-21.

    best regards,
    Zdary
    Attached Files

    #2
    The question is what's the storage engine and what values are being delivered to the client? If instead of true and false, the String "Active" is being delivered to the client as a field value, it's going to cause an extra "Active" entry to appear in the drop-down just as you've shown.

    Comment


      #3
      Hi,

      for storing and loading I use a DMI.
      Code:
      <serverObject lookupStyle="new" className="cz.bcom.smartrise.server.persistence.dmi.UsersDMI"/>
      which uses JPA2(Hibernate) objects
      Code:
      ....
      private Boolean active;
      
      ....
      @Column(name = "Active", nullable = false)
      public Boolean getActive() {
      	return this.active;
      }
      public void setActive(Boolean active) {
      	this.active = active;
      }
      Here is the RPC response. The field in question is shown as "active":true.
      Code:
      {
          "operationId":"usersDS_fetch", 
          "transactionNum":12, 
          "httpResponseCode":200, 
          "transport":"xmlHttpRequest", 
          "status":0, 
          "httpHeaders":{
              "X-Included-Test2":true, 
              "X-Included-Test":true, 
              "Content-Type":"text/plain; charset=utf-8", 
              "Cache-Control":"no-cache", 
              "Pragma":"no-cache", 
              "Expires":"Sat, 23 Jul 2011 09:35:14 GMT", 
              "Content-Encoding":"gzip", 
              "Content-Length":"599", 
              "Server":"Jetty(6.1.x)"
          }, 
          "isStructured":true, 
          "results":{
              "endRow":4, 
              "queueStatus":0, 
              "totalRows":4, 
              "isDSResponse":true, 
              "invalidateCache":false, 
              "status":0, 
              "startRow":0, 
              "data":[
                  {
                      "icon":"ROLE_LOCAL_ADMIN", 
                      "userByCreatedByFirstName":"tester1", 
                      "userGroupName":"ROLE_LOCAL_ADMIN", 
                      "regionDisplayText":"92 - Bratislava Východ", 
                      "userGroupId":1, 
                      "userByCreatedBySurname":"localadmin", 
                      "regionId":1, 
                      "accountLocked":false, 
                      "active":true, 
                      "changePassword":false, 
                      "checkUserIp":false, 
                      "dateOfChange":"2011-06-13T08:54:19", 
                      "dateOfCreation":"2011-06-13T08:54:19", 
                      "email":"supervisor@test.ui", 
                      "id":1, 
                      "lastSuccessfulLogin":"2011-05-24T13:03:10", 
                      "login":"tester1", 
                      "middleName":"", 
                      "name":"tester1", 
                      "surname":"localadmin", 
                      "$81y":{
                          "_checkboxField":{
                              "isNullMarker":true, 
                              "$669":"isc_UserManagementTab_1_0_body", 
                              "$81x":1
                          }, 
                          "icon":{
                              "isNullMarker":true, 
                              "$669":"isc_UserManagementTab_1_0_body", 
                              "$81x":1
                          }, 
                          "name":{
                              "isNullMarker":true, 
                              "$669":"isc_UserManagementTab_1_0_body", 
                              "$81x":1
                          }, 
                          "surname":{
                              "isNullMarker":true, 
                              "$669":"isc_UserManagementTab_1_0_body", 
                              "$81x":1
                          }, 
                          "userGroupId":{
                              "isNullMarker":true, 
                              "$669":"isc_UserManagementTab_1_0_body", 
                              "$81x":1
                          }, 
                          "regionId":{
                              "isNullMarker":true, 
                              "$669":"isc_UserManagementTab_1_0_body", 
                              "$81x":1
                          }, 
                          "active":{
                              "isNullMarker":true, 
                              "$669":"isc_UserManagementTab_1_0_body", 
                              "$81x":1
                          }, 
                          "lastSuccessfulLogin":{
                              "isNullMarker":true, 
                              "$669":"isc_UserManagementTab_1_0_body", 
                              "$81x":1
                          }, 
                          "info":{
                          }
                      }, 
                      "$29a":[
                          {
                          }
                      ]
                  }, 
                  {
                      "icon":"ROLE_VIEWER", 
                      "userByCreatedByFirstName":"tester1", 
                      "userGroupName":"ROLE_VIEWER", 
                      "regionDisplayText":"92 - Bratislava Východ", 
                      "userGroupId":2, 
                      "userByCreatedBySurname":"localadmin", 
                      "regionId":1, 
                      "accountLocked":false, 
                      "active":true, 
                      "changePassword":false, 
                      "checkUserIp":false, 
                      "dateOfChange":"2011-06-13T08:54:19", 
                      "dateOfCreation":"2011-06-13T08:54:19", 
                      "email":"la@test.ui", 
                      "id":2, 
                      "lastSuccessfulLogin":"2011-07-23T09:34:13", 
                      "login":"tester2", 
                      "middleName":"", 
                      "name":"tester2", 
                      "surname":"viewer", 
                      "$81y":{
                          "_checkboxField":{
                              "isNullMarker":true, 
                              "$669":"isc_UserManagementTab_1_0_body", 
                              "$81x":1
                          }, 
                          "icon":{
                              "isNullMarker":true, 
                              "$669":"isc_UserManagementTab_1_0_body", 
                              "$81x":1
                          }, 
                          "name":{
                              "isNullMarker":true, 
                              "$669":"isc_UserManagementTab_1_0_body", 
                              "$81x":1
                          }, 
                          "surname":{
                              "isNullMarker":true, 
                              "$669":"isc_UserManagementTab_1_0_body", 
                              "$81x":1
                          }, 
                          "userGroupId":{
                              "isNullMarker":true, 
                              "$669":"isc_UserManagementTab_1_0_body", 
                              "$81x":1
                          }, 
                          "regionId":{
                              "isNullMarker":true, 
                              "$669":"isc_UserManagementTab_1_0_body", 
                              "$81x":1
                          }, 
                          "active":{
                              "isNullMarker":true, 
                              "$669":"isc_UserManagementTab_1_0_body", 
                              "$81x":1
                          }, 
                          "lastSuccessfulLogin":{
                              "isNullMarker":true, 
                              "$669":"isc_UserManagementTab_1_0_body", 
                              "$81x":1
                          }, 
                          "info":{
                          }
                      }, 
                      "$29a":[
                          {
                          }
                      ]
                  }, 
                  {
                      "icon":"ROLE_LOCAL_ADMIN", 
                      "userByCreatedByFirstName":"tester1", 
                      "userGroupName":"ROLE_LOCAL_ADMIN", 
                      "regionDisplayText":"92 - Bratislava Východ", 
                      "userGroupId":1, 
                      "userByCreatedBySurname":"localadmin", 
                      "regionId":1, 
                      "accountLocked":false, 
                      "active":true, 
                      "changePassword":false, 
                      "checkUserIp":false, 
                      "dateOfChange":"2011-06-13T08:54:19", 
                      "dateOfCreation":"2011-06-13T08:54:19", 
                      "email":"peter_torok@tatrabanka.sk", 
                      "id":3, 
                      "lastSuccessfulLogin":"2011-05-24T11:38:38", 
                      "login":"peter_torok@tatrabanka.sk", 
                      "middleName":"", 
                      "name":"Peter", 
                      "surname":"Török", 
                      "$81y":{
                          "_checkboxField":{
                              "isNullMarker":true, 
                              "$669":"isc_UserManagementTab_1_0_body", 
                              "$81x":1
                          }, 
                          "icon":{
                              "isNullMarker":true, 
                              "$669":"isc_UserManagementTab_1_0_body", 
                              "$81x":1
                          }, 
                          "name":{
                              "isNullMarker":true, 
                              "$669":"isc_UserManagementTab_1_0_body", 
                              "$81x":1
                          }, 
                          "surname":{
                              "isNullMarker":true, 
                              "$669":"isc_UserManagementTab_1_0_body", 
                              "$81x":1
                          }, 
                          "userGroupId":{
                              "isNullMarker":true, 
                              "$669":"isc_UserManagementTab_1_0_body", 
                              "$81x":1
                          }, 
                          "regionId":{
                              "isNullMarker":true, 
                              "$669":"isc_UserManagementTab_1_0_body", 
                              "$81x":1
                          }, 
                          "active":{
                              "isNullMarker":true, 
                              "$669":"isc_UserManagementTab_1_0_body", 
                              "$81x":1
                          }, 
                          "lastSuccessfulLogin":{
                              "isNullMarker":true, 
                              "$669":"isc_UserManagementTab_1_0_body", 
                              "$81x":1
                          }, 
                          "info":{
                          }
                      }, 
                      "$29a":[
                          {
                          }
                      ]
                  }, 
                  {
                      "icon":"ROLE_VIEWER", 
                      "userByCreatedByFirstName":"tester1", 
                      "userGroupName":"ROLE_VIEWER", 
                      "regionDisplayText":"92 - Bratislava Východ", 
                      "userGroupId":2, 
                      "userByCreatedBySurname":"localadmin", 
                      "regionId":1, 
                      "accountLocked":false, 
                      "active":true, 
                      "changePassword":false, 
                      "checkUserIp":true, 
                      "dateOfChange":"2011-06-13T08:54:19", 
                      "dateOfCreation":"2011-06-13T08:54:19", 
                      "email":"peter_torok@tatrabanka.sk", 
                      "id":4, 
                      "lastSuccessfulLogin":"2011-05-24T11:38:38", 
                      "login":"Livia_Sokolovská@tatrabanka.sk", 
                      "middleName":"", 
                      "name":"Livia", 
                      "surname":"Sokolovská", 
                      "$81y":{
                          "_checkboxField":{
                              "isNullMarker":true, 
                              "$669":"isc_UserManagementTab_1_0_body", 
                              "$81x":1
                          }, 
                          "icon":{
                              "isNullMarker":true, 
                              "$669":"isc_UserManagementTab_1_0_body", 
                              "$81x":1
                          }, 
                          "name":{
                              "isNullMarker":true, 
                              "$669":"isc_UserManagementTab_1_0_body", 
                              "$81x":1
                          }, 
                          "surname":{
                              "isNullMarker":true, 
                              "$669":"isc_UserManagementTab_1_0_body", 
                              "$81x":1
                          }, 
                          "userGroupId":{
                              "isNullMarker":true, 
                              "$669":"isc_UserManagementTab_1_0_body", 
                              "$81x":1
                          }, 
                          "regionId":{
                              "isNullMarker":true, 
                              "$669":"isc_UserManagementTab_1_0_body", 
                              "$81x":1
                          }, 
                          "active":{
                              "isNullMarker":true, 
                              "$669":"isc_UserManagementTab_1_0_body", 
                              "$81x":1
                          }, 
                          "lastSuccessfulLogin":{
                              "isNullMarker":true, 
                              "$669":"isc_UserManagementTab_1_0_body", 
                              "$81x":1
                          }, 
                          "info":{
                          }
                      }, 
                      "$29a":[
                          {
                          }
                      ]
                  }
              ]
          }, 
          "isDSResponse":true, 
          "invalidateCache":false, 
          "data":[
              {
                  "icon":"ROLE_LOCAL_ADMIN", 
                  "userByCreatedByFirstName":"tester1", 
                  "userGroupName":"ROLE_LOCAL_ADMIN", 
                  "regionDisplayText":"92 - Bratislava Východ", 
                  "userGroupId":1, 
                  "userByCreatedBySurname":"localadmin", 
                  "regionId":1, 
                  "accountLocked":false, 
                  "active":true, 
                  "changePassword":false, 
                  "checkUserIp":false, 
                  "dateOfChange":"2011-06-13T08:54:19", 
                  "dateOfCreation":"2011-06-13T08:54:19", 
                  "email":"supervisor@test.ui", 
                  "id":1, 
                  "lastSuccessfulLogin":"2011-05-24T13:03:10", 
                  "login":"tester1", 
                  "middleName":"", 
                  "name":"tester1", 
                  "surname":"localadmin", 
                  "$81y":{
                      "_checkboxField":{
                          "isNullMarker":true, 
                          "$669":"isc_UserManagementTab_1_0_body", 
                          "$81x":1
                      }, 
                      "icon":{
                          "isNullMarker":true, 
                          "$669":"isc_UserManagementTab_1_0_body", 
                          "$81x":1
                      }, 
                      "name":{
                          "isNullMarker":true, 
                          "$669":"isc_UserManagementTab_1_0_body", 
                          "$81x":1
                      }, 
                      "surname":{
                          "isNullMarker":true, 
                          "$669":"isc_UserManagementTab_1_0_body", 
                          "$81x":1
                      }, 
                      "userGroupId":{
                          "isNullMarker":true, 
                          "$669":"isc_UserManagementTab_1_0_body", 
                          "$81x":1
                      }, 
                      "regionId":{
                          "isNullMarker":true, 
                          "$669":"isc_UserManagementTab_1_0_body", 
                          "$81x":1
                      }, 
                      "active":{
                          "isNullMarker":true, 
                          "$669":"isc_UserManagementTab_1_0_body", 
                          "$81x":1
                      }, 
                      "lastSuccessfulLogin":{
                          "isNullMarker":true, 
                          "$669":"isc_UserManagementTab_1_0_body", 
                          "$81x":1
                      }, 
                      "info":{
                      }
                  }, 
                  "$29a":[
                      {
                      }
                  ]
              }, 
              {
                  "icon":"ROLE_VIEWER", 
                  "userByCreatedByFirstName":"tester1", 
                  "userGroupName":"ROLE_VIEWER", 
                  "regionDisplayText":"92 - Bratislava Východ", 
                  "userGroupId":2, 
                  "userByCreatedBySurname":"localadmin", 
                  "regionId":1, 
                  "accountLocked":false, 
                  "active":true, 
                  "changePassword":false, 
                  "checkUserIp":false, 
                  "dateOfChange":"2011-06-13T08:54:19", 
                  "dateOfCreation":"2011-06-13T08:54:19", 
                  "email":"la@test.ui", 
                  "id":2, 
                  "lastSuccessfulLogin":"2011-07-23T09:34:13", 
                  "login":"tester2", 
                  "middleName":"", 
                  "name":"tester2", 
                  "surname":"viewer", 
                  "$81y":{
                      "_checkboxField":{
                          "isNullMarker":true, 
                          "$669":"isc_UserManagementTab_1_0_body", 
                          "$81x":1
                      }, 
                      "icon":{
                          "isNullMarker":true, 
                          "$669":"isc_UserManagementTab_1_0_body", 
                          "$81x":1
                      }, 
                      "name":{
                          "isNullMarker":true, 
                          "$669":"isc_UserManagementTab_1_0_body", 
                          "$81x":1
                      }, 
                      "surname":{
                          "isNullMarker":true, 
                          "$669":"isc_UserManagementTab_1_0_body", 
                          "$81x":1
                      }, 
                      "userGroupId":{
                          "isNullMarker":true, 
                          "$669":"isc_UserManagementTab_1_0_body", 
                          "$81x":1
                      }, 
                      "regionId":{
                          "isNullMarker":true, 
                          "$669":"isc_UserManagementTab_1_0_body", 
                          "$81x":1
                      }, 
                      "active":{
                          "isNullMarker":true, 
                          "$669":"isc_UserManagementTab_1_0_body", 
                          "$81x":1
                      }, 
                      "lastSuccessfulLogin":{
                          "isNullMarker":true, 
                          "$669":"isc_UserManagementTab_1_0_body", 
                          "$81x":1
                      }, 
                      "info":{
                      }
                  }, 
                  "$29a":[
                      {
                      }
                  ]
              }, 
              {
                  "icon":"ROLE_LOCAL_ADMIN", 
                  "userByCreatedByFirstName":"tester1", 
                  "userGroupName":"ROLE_LOCAL_ADMIN", 
                  "regionDisplayText":"92 - Bratislava Východ", 
                  "userGroupId":1, 
                  "userByCreatedBySurname":"localadmin", 
                  "regionId":1, 
                  "accountLocked":false, 
                  "active":true, 
                  "changePassword":false, 
                  "checkUserIp":false, 
                  "dateOfChange":"2011-06-13T08:54:19", 
                  "dateOfCreation":"2011-06-13T08:54:19", 
                  "email":"peter_torok@tatrabanka.sk", 
                  "id":3, 
                  "lastSuccessfulLogin":"2011-05-24T11:38:38", 
                  "login":"peter_torok@tatrabanka.sk", 
                  "middleName":"", 
                  "name":"Peter", 
                  "surname":"Török", 
                  "$81y":{
                      "_checkboxField":{
                          "isNullMarker":true, 
                          "$669":"isc_UserManagementTab_1_0_body", 
                          "$81x":1
                      }, 
                      "icon":{
                          "isNullMarker":true, 
                          "$669":"isc_UserManagementTab_1_0_body", 
                          "$81x":1
                      }, 
                      "name":{
                          "isNullMarker":true, 
                          "$669":"isc_UserManagementTab_1_0_body", 
                          "$81x":1
                      }, 
                      "surname":{
                          "isNullMarker":true, 
                          "$669":"isc_UserManagementTab_1_0_body", 
                          "$81x":1
                      }, 
                      "userGroupId":{
                          "isNullMarker":true, 
                          "$669":"isc_UserManagementTab_1_0_body", 
                          "$81x":1
                      }, 
                      "regionId":{
                          "isNullMarker":true, 
                          "$669":"isc_UserManagementTab_1_0_body", 
                          "$81x":1
                      }, 
                      "active":{
                          "isNullMarker":true, 
                          "$669":"isc_UserManagementTab_1_0_body", 
                          "$81x":1
                      }, 
                      "lastSuccessfulLogin":{
                          "isNullMarker":true, 
                          "$669":"isc_UserManagementTab_1_0_body", 
                          "$81x":1
                      }, 
                      "info":{
                      }
                  }, 
                  "$29a":[
                      {
                      }
                  ]
              }, 
              {
                  "icon":"ROLE_VIEWER", 
                  "userByCreatedByFirstName":"tester1", 
                  "userGroupName":"ROLE_VIEWER", 
                  "regionDisplayText":"92 - Bratislava Východ", 
                  "userGroupId":2, 
                  "userByCreatedBySurname":"localadmin", 
                  "regionId":1, 
                  "accountLocked":false, 
                  "active":true, 
                  "changePassword":false, 
                  "checkUserIp":true, 
                  "dateOfChange":"2011-06-13T08:54:19", 
                  "dateOfCreation":"2011-06-13T08:54:19", 
                  "email":"peter_torok@tatrabanka.sk", 
                  "id":4, 
                  "lastSuccessfulLogin":"2011-05-24T11:38:38", 
                  "login":"Livia_Sokolovská@tatrabanka.sk", 
                  "middleName":"", 
                  "name":"Livia", 
                  "surname":"Sokolovská", 
                  "$81y":{
                      "_checkboxField":{
                          "isNullMarker":true, 
                          "$669":"isc_UserManagementTab_1_0_body", 
                          "$81x":1
                      }, 
                      "icon":{
                          "isNullMarker":true, 
                          "$669":"isc_UserManagementTab_1_0_body", 
                          "$81x":1
                      }, 
                      "name":{
                          "isNullMarker":true, 
                          "$669":"isc_UserManagementTab_1_0_body", 
                          "$81x":1
                      }, 
                      "surname":{
                          "isNullMarker":true, 
                          "$669":"isc_UserManagementTab_1_0_body", 
                          "$81x":1
                      }, 
                      "userGroupId":{
                          "isNullMarker":true, 
                          "$669":"isc_UserManagementTab_1_0_body", 
                          "$81x":1
                      }, 
                      "regionId":{
                          "isNullMarker":true, 
                          "$669":"isc_UserManagementTab_1_0_body", 
                          "$81x":1
                      }, 
                      "active":{
                          "isNullMarker":true, 
                          "$669":"isc_UserManagementTab_1_0_body", 
                          "$81x":1
                      }, 
                      "lastSuccessfulLogin":{
                          "isNullMarker":true, 
                          "$669":"isc_UserManagementTab_1_0_body", 
                          "$81x":1
                      }, 
                      "info":{
                      }
                  }, 
                  "$29a":[
                      {
                      }
                  ]
              }
          ], 
          "startRow":0, 
          "endRow":4, 
          "totalRows":4
      }

      Comment


        #4
        Hi,

        do you have any thoughts about this one? What went wrong and how can I fix it?

        Cheers,
        Zdary

        Comment


          #5
          The problem is to do with how the valueMap is being represented on the client in JavaScript. Essentially the SelectItem is failing to recognize that the boolean true/false values from the record are already represented in the valueMap you supply.

          We've made a local change that should resolve this. It will be present in the next nightly build -- Aug 9 or greater, in the 3.x branch:

          http://www.smartclient.com/builds/SmartGWT/3.x

          Give this a try and let us know if it doesn't get this working as expected.

          -----
          Update: This code was further reworked on Aug 10th so please try a nightly dated Aug 11 or greater to be sure you're working with the latest logic.
          Last edited by Isomorphic; 10 Aug 2011, 12:58.

          Comment


            #6
            Hi,

            thanks it works

            Cheers,
            Zdary

            Comment


              #7
              Hi,


              Filter above the grid renders correctly Active/Inactive text in a SelectItem but the wdith is too short.
              The grid itself uses a wrong renderer. It should have been text but it is still checkbox.
              When I edit the records and use the SelectItem the values are correctly offered.

              Screenshot attached.

              Code:
              <DataSource ID="usersDS" dropExtraFields="true">  
              	<fields>
              
              ...
              		<field name="active" type="boolean" >
              			<valueMap>
              				<value ID="true">Active</value>
              				<value ID="false">Inactive</value>
              			</valueMap>
              		</field>
              ...
              	</fields>
              </DataSource>
              retested on smartGWT 31-10-2011

              if I change the DS definition to
              Code:
              <field name="active">
              then the grid behaves correctly, but there will be the problem while editing the record.

              best regards,
              Zdary

              EDIT: This has nothing to do with JPA. It happens for any DS.
              Attached Files
              Last edited by zdary; 2 Nov 2011, 01:35.

              Comment


                #8
                Can I add something to the DS field definition so that the grid would use the value map provided instead of the checkbox?

                thank you,
                Zdary

                Comment


                  #9
                  You could get this working by specifying an explicit cellFormatter on the field

                  Comment


                    #10
                    A quick update. We're also making a change to the 3.0 branch such that calling 'setSuppressValueIcon(true)' on a boolean field will suppress the checkbox image and show the value as text (including respecting any valueMap). This will be the case in nightly builds going forward in that branch

                    Comment


                      #11
                      Great, thank you

                      Comment

                      Working...
                      X