Announcement

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

    Fetch changes formItem type

    Be sure your post includes:

    1. SmartGWT 2.2

    3. No reported error/warning

    4. No reported error/warning


    We're trying to fetch data to a DynamicForm. The form is built before we fetch with various FormItems (mostly TextItems and StaticTextItems). We are using a RestDataSource built from an XSD which we use to define our data. After the fetch has been executed all the formtypes have changed.
    They have all become editable textfields, even the ones created as StaticTextItems. The entire form seems to be destroyed and rebuilt by the fetch with different formitems.

    To us this is really weird and I can't figure out what's causing this. We don't want to determine the forms from the server side we just want to get data from the fetch plugged into the formItems.

    This is the code we use to fetch data for the form. We fetch the DataSource first, basically creating it from an XSD (That's the DataSourceFactory's job) and then after we get the structured DataSource we fetch on it.
    Code:
       @Override
        public void fetchData(Criteria criteria) {
            final Criteria crt = criteria;
            //if DS XSD is not loaded then get XSD and fetch Data on callback
             if (getDataSource() == null) {
                // Call the DataSourceFactory to create a DataSource. This can be an asynchronous
                DataSourceFactory.createDataSource(getDSSchemaURL(), getDSName(), new DSReadyCallback() {
    
                    public void execute(WebAppRestDataSource ds) {
    
                        setDataSource(ds);
                        BaseDynamicForm.super.fetchData(crt);
    
                    }
                });
            } else {
                super.fetchData(crt);
        }
        }

    This is our request
    Code:
    {
    
        "actionURL":"/WPDemo/webportfolio/servlets/WPServlet?RequestType=WebAppRequest", 
    
        "showPrompt":true, 
    
        "transport":"xmlHttpRequest", 
    
        "useSimpleHttp":true, 
    
        "promptStyle":"dialog", 
    
        "httpMethod":"POST", 
    
        "contentType":"text/xml", 
    
        "httpHeaders":{
    
            "login":"", 
    
            "password":""
    
        }, 
    
        "sendNoQueue":true, 
    
        "bypassCache":true, 
    
        "callback":{
    
            "target":null, 
    
            "methodName":"$37c"
    
        }, 
    
        "serverOutputAsString":true, 
    
        "data":"\r<request>\r    <data>\r        <EDITACCOUNTFIDS>\r            <ID>64</ID>\r            <NAME></NAME>\r            <SERVICE_CATEGORY></SERVICE_CATEGORY>\r            <USERLOGIN_URL></USERLOGIN_URL>\r        </EDITACCOUNTFIDS>\r    </data>\r    <dataSource>rds_EDITACCOUNTFIDS</dataSource>\r    <operationType>fetch</operationType>\r    <oldValues></oldValues>\r</request>"
    
    }

    This is the response
    Code:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    
    <response>
    
        <status>0</status>
    
        <data>
    
            <record>
    
                <ID>64</ID>
    
                <NAME>Babson Funds</NAME>
    
                <SERVICE_CATEGORY>Investment</SERVICE_CATEGORY>
    
                <USERLOGIN_URL>https://www3.financialtrans.com/tf/FANWeb?tx=Disclaim&amp;cz=6010001181413</USERLOGIN_URL>
    
            </record>
    
        </data>
    
    </response>
    After the response the data is put into the correct places but all of the StaticTextItems have been transformed into TextItems and any FormItem that didn't match up with the DataSource has been destroyed.
    Originally the Form had 6 items: 3 Decorative StatictextItems we used as Labels and 3 StaticTextItems that were supposed to match the returning data (ID will be a hidden field but we hadn't added it to the form yet)

    I was under the impression that if the system couldn't match a field in the Response it would throw it away, not create new fields and destroy the old ones to make the DynamicForm match the dataSource.

    Can anyone shed some light on this strange behavior?
    Thanks
Working...
X