Announcement

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

    Unable to get displayField value different from valueField in a SelectItem

    Unable to get displayField to show up as the selected option with a datasource.

    I believe this was working before switching from LGPL to SmartGwtPro

    Code:
    productTypeSelectItem = new SelectItem("productType", "Product Type");
    productTypeSelectItem.setAllowEmptyValue(true);
    productTypeSelectItem.setOptionDataSource(DataSource.get("customerCache"));
    productTypeSelectItem.setValueField("productType");
    productTypeSelectItem.setDisplayField("description");
    Code:
    <DataSource
            ID="customerCache"
            tableName="customerCache"
            schemaBean="...CustomerCache"
    >
    
        <serverObject className="...dmi.CustomerCacheDmi"/>
    
        <fields>
    
            <field name="cacheId"           title="Cache ID"        type="integer"  primaryKey="true" />
            <field name="applicationCode"   title="Application"     type="enum"     required="true" />
            <field name="productType"       title="Product Type"    type="enum"     required="true" />
            <field name="description"       title="Description"     type="text"     required="true" />
            <field name="displayEnabled"    title="Display Enabled" type="boolean" />
            <field name="cacheEnabled"      title="Cache Enabled"   type="boolean" />
            <field name="orderBy"           title="Order By"        type="integer" />
    
        </fields>
    </DataSource>
    See screen-capture with what select option displays.

    SmartGWTPro 2.5
    Attached Files

    #2
    Am I the only one that is having this problem when values fetch from DataSource? Still haven't found a solution.

    Comment


      #3
      First steps to analyze this would be to look at the differences in what data your server is returning. To get help with that, post the data your server is returning.

      What might the problem here is that the fetchMissingValues behavior is triggering an initial request to get the display value for just one record (the initially selected one) and your server is messing up that response somehow.

      Comment


        #4
        Here is the response by the server

        Code:
        //isc_RPCResponseStart-->[{endRow:1,queueStatus:0,totalRows:7,isDSResponse:true,invalidateCache:false,status:0,startRow:0,data:[{applicationCode:"PRR",cacheEnabled:true,cacheId:102,description:"Submission Form (Preview)",displayEnabled:true,key:"PRR-URL_SUBMISSION",orderBy:11,productType:"URL_SUBMISSION"},{applicationCode:"PRR",cacheEnabled:true,cacheId:103,description:"Duplicate Submission",displayEnabled:true,key:"PRR-URL_DUPLICATE_SUBMISSION",orderBy:12,productType:"URL_DUPLICATE_SUBMISSION"},{applicationCode:"PRR",cacheEnabled:true,cacheId:104,description:"Display With Content",displayEnabled:true,key:"PRR-URL_HAS_CONTENT",orderBy:13,productType:"URL_HAS_CONTENT"},{applicationCode:"PRR",cacheEnabled:true,cacheId:110,description:"Display No Content",displayEnabled:true,key:"PRR-URL_NO_CONTENT",orderBy:14,productType:"URL_NO_CONTENT"},{applicationCode:"PRR",cacheEnabled:false,cacheId:112,description:"Sample Display",displayEnabled:true,key:"PRR-SAMPLE_DISPLAY",orderBy:15,productType:"SAMPLE_DISPLAY"},{applicationCode:"PRR",cacheEnabled:false,cacheId:113,description:"Sample Submission Container",displayEnabled:true,key:"PRR-SAMPLE_CONTAINER",orderBy:16,productType:"SAMPLE_CONTAINER"},{applicationCode:"PRR",cacheEnabled:false,cacheId:114,description:"Sample Submission",displayEnabled:true,key:"PRR-SAMPLE_SUBMISSION",orderBy:17,productType:"SAMPLE_SUBMISSION"}]}]//isc_RPCResponseEnd
        Here is Request operation

        Code:
        _transaction
        <transaction xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" xsi:type="xsd:Object">
            <transactionNum xsi:type="xsd:long">5</transactionNum>
            <operations xsi:type="xsd:List">
                <elem xsi:type="xsd:Object">
                    <criteria xsi:type="xsd:Object">
                        <applicationCode>PRR</applicationCode>
                        <displayEnabled xsi:type="xsd:boolean">true</displayEnabled>
                    </criteria>
                    <operationConfig xsi:type="xsd:Object">
                        <dataSource>customerCache</dataSource>
                        <operationType>fetch</operationType>
                        <textMatchStyle>startsWith</textMatchStyle>
                    </operationConfig>
                    <sortBy xsi:type="xsd:List">
                        <elem>orderBy</elem>
                    </sortBy>
                    <componentId>isc_PickListMenu_0</componentId>
                    <appID>builtinApplication</appID>
                    <operation>customerCache_fetch</operation>
                    <oldValues xsi:type="xsd:Object">
                        <applicationCode>PRR</applicationCode>
                        <displayEnabled xsi:type="xsd:boolean">true</displayEnabled>
                    </oldValues>
                </elem>
            </operations>
        </transaction>

        Comment


          #5
          Okay, got it to work ....however, here's the bug.
          It doesn't work unless the "value" is the primary key.

          Code:
          <field name="cacheId"           title="Cache ID"        type="integer" />
          <field name="applicationCode"   title="Application"     type="enum" />
          <field name="productType"       title="Product Type"    type="enum" primaryKey="true" />
          <field name="description"       title="Description"     type="text" />
          <field name="displayEnabled"    title="Display Enabled" type="boolean" />
          <field name="cacheEnabled"      title="Cache Enabled"   type="boolean" />
          <field name="orderBy"           title="Order By"        type="integer" />
          EDIT: never mind - thought it was working when changing primary key.
          But really why it started working was changing the setValueField("cacheId");
          setValueField doesn't seem to work with text or enum fields!?
          Last edited by micsky; 18 Nov 2011, 11:50.

          Comment


            #6
            No, value doesn't need to be a primaryKey, but it does need to be a unique value or the request to the server to find out the displayValue is necessarily ambiguous (in other words - not a framework limitation, just a natural requirement).

            Comment


              #7
              Understood. Value is unique within the response from the server (made sure no other fetches occur check may contain dups). It just don't seem to work if both value and display are text or enum fields.

              To work around the problem I changed my implementation to instead save the field ID and not the enum value; this works for me and I suppose overall a better solution anyway.

              Thanks for the response. Cheers.

              Comment

              Working...
              X