Announcement

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

    DSResponse with List of beans not being serialized

    I've made my own flavor of spring example found at http://localhost:8080/examples/server_integration/index.html#springDSHiberateDMI.

    My spring service returns a list of beans. I see the DMI post in firebug and response is a data array with only empty items. So the fetch method (included below) works fine. It returns a DSResponse containing a list of CatalogView objects, which I've confirmed are all populated with actual data.

    Something must be going wrong in the way smartclient server serializes the CatalogView beans.

    Note that when I rework the example to use the supplyItemSpringDMI it works fine.
    Thanks in advance,
    Stefaan

    blurbs of smartclient server logging:
    Code:
    === 2010-04-06 15:25:08,564 [or22] INFO  RequestContext - URL: '/isomorphic/IDACall', User-Agent: 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3': Moz (Gecko) with Accept-Encoding header
    === 2010-04-06 15:25:08,566 [or22] DEBUG XML - Parsed XML from (in memory stream): 2ms
    === 2010-04-06 15:25:08,568 [or22] DEBUG RPCManager - Processing 1 requests.
    === 2010-04-06 15:25:08,568 [or22] DEBUG RPCManager - Request #1 (DSRequest) payload: {
        criteria:{},
        operationConfig:{dataSource:"SalesLotCatalogDMI", operationType:"fetch", textMatchStyle:"substring"},
        startRow:0,
        endRow:999,
        componentId:"boundList",
        appID:"builtinApplication",
        operation:"SalesLotCatalogDMI_fetch",
        oldValues:{}
    }
    === 2010-04-06 15:25:08,568 [or22] INFO  IDACall - Performing 1 operation(s)
    === 2010-04-06 15:25:08,569 [or22] INFO  ServerObject - DMI on Spring bean: adminController
    === 2010-04-06 15:25:08,569 [or22] DEBUG Reflection - adaptArgsAndInvoke:
    
     public com.isomorphic.datasource.DSResponse com.asm.shop.services.AdminController.fetch(com.isomorphic.datasource.DSRequest) throws java.lang.Exception
    
    requiredArgs: [] optionalArgs: [com.isomorphic.servlet.RequestContext, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, javax.servlet.ServletContext, javax.servlet.http.HttpSession, com.isomorphic.rpc.RPCManager, com.isomorphic.datasource.DSRequest, com.isomorphic.datasource.DataSource, java.util.Map]
    === 2010-04-06 15:25:08,570 [or22] DEBUG Reflection - checking whether type: com.isomorphic.servlet.RequestContext fulfills type: com.isomorphic.datasource.DSRequest
    === 2010-04-06 15:25:08,570 [or22] DEBUG Reflection - checking whether type: javax.servlet.http.HttpServletRequest fulfills type: com.isomorphic.datasource.DSRequest
    === 2010-04-06 15:25:08,570 [or22] DEBUG Reflection - checking whether type: javax.servlet.http.HttpServletResponse fulfills type: com.isomorphic.datasource.DSRequest
    === 2010-04-06 15:25:08,570 [or22] DEBUG Reflection - checking whether type: javax.servlet.ServletContext fulfills type: com.isomorphic.datasource.DSRequest
    === 2010-04-06 15:25:08,570 [or22] DEBUG Reflection - checking whether type: javax.servlet.http.HttpSession fulfills type: com.isomorphic.datasource.DSRequest
    === 2010-04-06 15:25:08,570 [or22] DEBUG Reflection - checking whether type: com.isomorphic.rpc.RPCManager fulfills type: com.isomorphic.datasource.DSRequest
    === 2010-04-06 15:25:08,570 [or22] DEBUG Reflection - checking whether type: com.isomorphic.datasource.DSRequest fulfills type: com.isomorphic.datasource.DSRequest
    === 2010-04-06 15:25:08,570 [or22] DEBUG Reflection - Successfully adapted optional arg type: com.isomorphic.datasource.DSRequest to type: com.isomorphic.datasource.DSRequest
    === 2010-04-06 15:25:08,570 [or22] DEBUG Reflection - method takes: 1 args.  I've assembled: 1 args
    === 2010-04-06 15:25:08,571 [or22] DEBUG Reflection - invoking method:
    com.isomorphic.datasource.DSResponse com.asm.shop.services.AdminController.fetch(com.isomorphic.datasource.DSRequest) throws java.lang.Exception
    
    with arg types: com.isomorphic.datasource.DSRequest
    06 apr 2010 15:25:08,571 [INFO ] [com.asm.shop.services.AdminController] - procesing DMI fetch operation
    06 apr 2010 15:25:08,982 [INFO ] [com.asm.shop.services.GridQueryController] - adminDownload - firstResult: 0, maxResults:1.000, resultListCount:1.000
    === 2010-04-06 15:25:08,982 [or22] INFO  DSResponse - DSResponse: List with 1000 items
    === 2010-04-06 15:25:08,982 [or22] DEBUG RPCManager - Content type for RPC transaction: text/plain; charset=UTF-8
    === 2010-04-06 15:25:08,982 [or22] DEBUG RPCManager - DMI response, dropExtraFields: true

    my jsp page:

    Code:
        <isomorphic:loadDS ID="SalesLotCatalogDMI"/>
        <%--<isomorphic:loadDS ID="supplyItemSpringDMI"/>--%>
    
    
            VStack.create({
                 left:50, top:75,
                 width:"70%",
                 membersMargin:20,
                 members:[
    
    
                     // databound ListGrid
                     //   * click records to edit in boundForm and view in boundViewer
                     //   * double-click record to edit inline (Return or arrow/tab off current row to save)
                     ListGrid.create({
                         ID:"boundList",
                         autoDraw: true,
                         dataSource: SalesLotCatalogDMI,
                         height:200,
                         canEdit:true,
                         selectionChanged : function (record, state) {
                             if (this.selection.anySelected()) {
                                 deleteBtn.enable();
                                 saveBtn.setDisabled(this.selection.multipleSelected());
                                 boundForm.editRecord(record);
                                 boundViewer.viewSelectedData(this);
                             } else {
                                 deleteBtn.disable();
                                 saveBtn.disable();
                             }
                         }
                     })
    
    
                 ]
             });
    
             boundList.filterData();
    My datasource:

    Code:
    <!-- **************************************************************************** -->
    <!-- FILE: /examples/shared/ds/supplyItemSpringDMI.ds.xml -->
    <!-- **************************************************************************** -->
    
    <DataSource
            ID="SalesLotCatalogDMI"
            serverType="generic"
            >
    
    
        <DataSource ID="CatalogView">
            <fields>
                <field name="uid" type="text" hidden="true"></field>
                <field name="weight" type="float" title="Weight"></field>
                <field name="location" type="text" title="Location"></field>
                <field name="quantityRequested" type="integer" title="Quan. Requested" ></field>
                <field name="collection" type="text" length="20"></field>
                <field name="penaltyPoints" type="float"></field>
                <field name="productTypeTemplate" type="text"></field>
                <field name="type" type="text"></field>
                <field name="grossPrice" type="float"></field>
                <field name="quantityAvailable" type="integer"></field>
                <field name="refExists" type="boolean"></field>
                <field name="customerSalesLevelDisounct" type="float"></field>
                <field name="oldQuantityRequested" type="integer"></field>
                <field name="oldNetPrice" type="float"></field>
                <field name="totalNetPrice" type="float"></field>
                <field name="bearingNumber" type="text"></field>
                <field name="basketId" type="integer"></field>
                <field name="packingQuantity" type="integer"></field>
                <field name="lotNr" type="text"></field>
                <field name="priceChanged" type="boolean"></field>
                <field name="removedFromBasket" type="boolean"></field>
                <field name="netPrice" type="float"></field>
                <field name="quantityChanged" type="boolean"></field>
                <field name="oldDiscount" type="float"></field>
                <field name="oldTotalNetPrice" type="float"></field>
                <field name="subClass" type="text"></field>
                <field name="brand" type="text"></field>
                <field name="discountPercent" type="float"></field>
                <field name="packingCode" type="text"></field>
                <field name="quoteRow" type="boolean"></field>
            </fields>
        </DataSource>
    
    
        <serverObject lookupStyle="spring" bean="adminController"/>
    
    
        <!-- You can define an operationBindings section to bind operation names to server method
             (potentially additionally discriminated by the operationId).
             In the absense of this section, the server will look for a server method named after
             the operationType.
        -->
        <operationBindings>
            <binding operationType="fetch" serverMethod="fetch">
            <serverObject  lookupStyle="spring" bean="adminController"/>
            </binding>
        </operationBindings>
    </DataSource>
    the CatalogView bean:
    Code:
    package com.asm.model;
    
    import org.granite.messaging.amf.io.util.externalizer.annotation.ExternalizedBean;
    import org.springframework.util.Assert;
    import org.apache.commons.lang.StringUtils;
    
    import javax.persistence.EntityListeners;
    import java.io.Serializable;
    
    /**
     * User: stefaan
     * Date: Sep 23, 2009
     * Time: 12:03:39 PM
     * Catalog view class for data binding with client
     */
    //@MappedSuperclass
    //@Entity
    
    
    public class CatalogView implements Serializable {
        private static final long serialVersionUID = 42L;
    
        private String lotNr;
        private String uid;
        private String bearingNumber;
        private String brand;
        private String productTypeTemplate;
        private Double weight;
        private String collection;
        private String subClass;
        private String type;
        private String packingCode;
        private Integer quantityAvailable;
    
        private Double grossPrice;
    
        private Integer oldQuantityRequested = 0;
        private Double oldDiscount = 0.0;
        private Double oldNetPrice = 0.0;
        private Double oldTotalNetPrice = 0.0;
    
        private Integer quantityRequested = 0;
        private Double discountPercent = 0.0;
        private Double netPrice = 0.0;
        private Double totalNetPrice = 0.0;
    
        private boolean priceChanged = false;
        private boolean quantityChanged = false;
    
        private Integer packingQuantity;
        private double penaltyPoints;
        private String location;
        private Double customerSalesLevelDisounct;
        private long basketId;
        private boolean refExists;
        private boolean removedFromBasket;
        private boolean quoteRow;
    
        public CatalogView() {
        }
    
        public CatalogView(long basketId, long lotNr, String bearingNumber, String brand, String productTypeTemplate, Double weight,
                           String collection, String subClass, String type, String packingCode, Integer quantityAvailable,
                           Double grossPrice, Integer packingQuantity,
                           double penaltyPoints, String location, Double customerSalesLevelDisounct, Double oldDiscount,
                           Double discountPercent, Integer oldQuantityRequested, Integer quantityRequested,
                           Double oldTotalNetPrice,
                           Double totalNetPrice, Double oldNetPrice, Double netPrice, boolean refExists, boolean priceChanged, boolean
                        quantityChanged, boolean removedFromBasket, boolean quoteRow) {
            this.basketId = basketId;
            this.refExists = refExists;
            this.priceChanged = priceChanged;
            this.quantityChanged = quantityChanged;
            this.removedFromBasket = removedFromBasket;
            this.quoteRow = quoteRow;
            this.lotNr = String.valueOf(lotNr);
    //        this.uid = StringUtils.rightPad(String.valueOf(lotNr), 10,'c' ) + location;
               StringBuffer buffer = new StringBuffer();
            buffer.append(basketId).append('-').append(lotNr).append("-").append(location);
            this.uid = buffer.toString();
            Assert.notNull(location, "Null location not acceptable. Necessary for implementation of uuid");
            Assert.isTrue(lotNr != 0, "lotNr may not be zero.  Necessary for implementation of uuid");
            this.bearingNumber = bearingNumber;
            this.brand = brand;
            this.productTypeTemplate = productTypeTemplate;
            this.weight = weight;
            this.collection = collection;
            this.subClass = subClass;
            this.type = type;
            this.packingCode = packingCode;
            this.quantityAvailable = quantityAvailable;
            this.grossPrice = grossPrice;
            this.packingQuantity = packingQuantity;
            this.penaltyPoints = penaltyPoints;
            this.location = location;
            this.customerSalesLevelDisounct = customerSalesLevelDisounct;
    //        this.discountPercent = customerSalesLevelDisounct * penaltyPoints/100;
            this.oldDiscount = oldDiscount;
            this.oldQuantityRequested = oldQuantityRequested == null ? 0 : oldQuantityRequested;
            this.oldNetPrice = oldNetPrice;
            this.oldTotalNetPrice = oldTotalNetPrice == null ? 0d : oldTotalNetPrice;
    
            this.discountPercent = discountPercent;
            this.quantityRequested = quantityRequested == null ? 0 : quantityRequested;
            this.netPrice = netPrice;
            this.totalNetPrice = totalNetPrice == null ? 0d : totalNetPrice;
    
        }
    
        public String getLotNr() {
            return lotNr;
        }
    
        public void setLotNr(String lotNr) {
            this.lotNr = lotNr;
        }
    
        public String getUid() {
            return uid;
        }
    
        public void setUid(String uid) {
            this.uid = uid;
        }
    
        public String getBearingNumber() {
            return bearingNumber;
        }
    
        public void setBearingNumber(String bearingNumber) {
            this.bearingNumber = bearingNumber;
        }
    
        public String getBrand() {
            return brand;
        }
    
        public void setBrand(String brand) {
            this.brand = brand;
        }
    
        public String getProductTypeTemplate() {
            return productTypeTemplate;
        }
    
        public void setProductTypeTemplate(String productTypeTemplate) {
            this.productTypeTemplate = productTypeTemplate;
        }
    
        
    
        public Double getWeight() {
            return weight;
        }
    
        public void setWeight(Double weight) {
            this.weight = weight;
        }
    
        public String getCollection() {
            return collection;
        }
    
        public void setCollection(String collection) {
            this.collection = collection;
        }
    
        public String getSubClass() {
            return subClass;
        }
    
        public void setSubClass(String subClass) {
            this.subClass = subClass;
        }
    
        public String getType() {
            return type;
        }
    
        public void setType(String type) {
            this.type = type;
        }
    
        public String getPackingCode() {
            return packingCode;
        }
    
        public void setPackingCode(String packingCode) {
            this.packingCode = packingCode;
        }
    
        public Integer getQuantityAvailable() {
            return quantityAvailable;
        }
    
        public void setQuantityAvailable(Integer quantityAvailable) {
            this.quantityAvailable = quantityAvailable;
        }
    
        public Double getGrossPrice() {
            return grossPrice;
        }
    
        public void setGrossPrice(Double grossPrice) {
            this.grossPrice = grossPrice;
        }
    
        public Integer getPackingQuantity() {
            return packingQuantity;
        }
    
        public void setPackingQuantity(Integer packingQuantity) {
            this.packingQuantity = packingQuantity;
        }
    
        public double getPenaltyPoints() {
            return penaltyPoints;
        }
    
        public void setPenaltyPoints(double penaltyPoints) {
            this.penaltyPoints = penaltyPoints;
        }
    
        public Integer getOldQuantityRequested() {
            return oldQuantityRequested;
        }
    
        public void setOldQuantityRequested(Integer oldQuantityRequested) {
            this.oldQuantityRequested = oldQuantityRequested;
        }
    
        public Double getOldDiscount() {
            return oldDiscount;
        }
    
        public void setOldDiscount(Double oldDiscount) {
            this.oldDiscount = oldDiscount;
        }
    
        public Double getOldNetPrice() {
            return oldNetPrice;
        }
    
        public void setOldNetPrice(Double oldNetPrice) {
            this.oldNetPrice = oldNetPrice;
        }
    
        public String getLocation() {
            return location;
        }
    
        public void setLocation(String location) {
            this.location = location;
        }
    
        public Double getOldTotalNetPrice() {
            return oldTotalNetPrice;
        }
    
        public void setOldTotalNetPrice(Double oldTotalNetPrice) {
            this.oldTotalNetPrice = oldTotalNetPrice;
        }
    
        public Integer getQuantityRequested() {
            return quantityRequested;
        }
    
        public void setQuantityRequested(Integer quantityRequested) {
            this.quantityRequested = quantityRequested;
        }
    
        public Double getDiscountPercent() {
            return discountPercent;
        }
    
        public void setDiscountPercent(Double discountPercent) {
            this.discountPercent = discountPercent;
        }
    
        public Double getNetPrice() {
            return netPrice;
        }
    
        public void setNetPrice(Double netPrice) {
            this.netPrice = netPrice;
        }
    
        public Double getTotalNetPrice() {
            return totalNetPrice;
        }
    
        public void setTotalNetPrice(Double totalNetPrice) {
            this.totalNetPrice = totalNetPrice;
        }
    
        public boolean isPriceChanged() {
            return priceChanged;
        }
    
        public void setPriceChanged(boolean priceChanged) {
            this.priceChanged = priceChanged;
        }
    
        public boolean isQuantityChanged() {
            return quantityChanged;
        }
    
        public void setQuantityChanged(boolean quantityChanged) {
            this.quantityChanged = quantityChanged;
        }
    
        public Double getCustomerSalesLevelDisounct() {
            return customerSalesLevelDisounct;
        }
    
        public void setCustomerSalesLevelDisounct(Double customerSalesLevelDisounct) {
            this.customerSalesLevelDisounct = customerSalesLevelDisounct;
        }
    
        public boolean isRefExists() {
            return refExists;
        }
    
        public void setRefExists(boolean refExists) {
            this.refExists = refExists;
        }
    
        public boolean isQuoteRow() {
            return quoteRow;
        }
    
        public void setQuoteRow(boolean quoteRow) {
            this.quoteRow = quoteRow;
        }
    
        public boolean isRemovedFromBasket() {
            return removedFromBasket;
        }
    
        public void setRemovedFromBasket(boolean removedFromBasket) {
            this.removedFromBasket = removedFromBasket;
        }
    
    //    public boolean equals(Object o) {
    //        return (o == this || (o instanceof org.granite.tide.IUID && getUid().equals(((org.granite.tide.IUID) o).getUid())));
    //    }
    //
    //    @Override
    //    public int hashCode() {
    //        return getUid().hashCode();
    //    }
    
        public long getBasketId() {
            return basketId;
        }
    
        public void setBasketId(long basketId) {
            this.basketId = basketId;
        }
    }
    method in my spring bean being hit:
    Code:
         public DSResponse fetch(DSRequest dsRequest)
                throws Exception {
            log.info("procesing DMI fetch operation");
            DSResponse dsResponse = new DSResponse(dsRequest == null ? (DataSource) null :
                    dsRequest.getDataSource());
    
    
            // DataSource protocol: get filter criteria
            String itemName = (String) dsRequest.getFieldValue("itemName");
    
            // DataSource protocol: get requested row range
            int startRow = (int) dsRequest.getStartRow();
            int endRow = (int) dsRequest.getEndRow();
    
            String salesLevel = "BNA";
            ModelMap map = salesAdminService.getLots(salesLevel, new HashMap(),startRow, endRow-startRow+1, null, false);
            List<CatalogView> matchingItems = (List) map.get("resultList");
    //        List matchingItems = criteria.list();
    
            // DataSource protocol: return matching item beans
            dsResponse.setData(matchingItems);
            // tell client what rows are being returned, and what's available
            dsResponse.setStartRow(startRow);
            dsResponse.setEndRow(endRow);
            dsResponse.setTotalRows(matchingItems.size());
    
            return dsResponse;
        }

    #2
    You've got some kind of double DataSource tag - don't do that, just have a single DataSource tag with <fields> directly underneath. See any sample DataSource.

    Comment


      #3
      Stupid mistake. Please forgive me.

      Comment

      Working...
      X