Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

Dynamic DataSources

$
0
0
Smartclient version 9.1-p


Hi,
for the evaluation of the product I have tried the following functionality: http://www.smartclient.com/#FSeditab...SideDataSource (notice: the example not work correctly!)

In web.xml i have declared the init servlet in this way:
Code:

 
  <servlet>
        <servlet-name>DynamicDS</servlet-name>
        <servlet-class>com.isomorphic.DynamicDS</servlet-class>
        <load-on-startup>3</load-on-startup>
    </servlet>


In DynamicDS.java:
Code:

        ...
        private final String SUFFIX_DYNAMIC="dynamic"

        public void init(ServletConfig servletConfig) throws ServletException{
               
                super.init(servletConfig);

                DynamicDSGenerator ddsg = new DynamicDSGenerator(){
                        @Override
                        public DataSource getDataSource(String id, DSRequest dsRequest){
                               
                                try{
                                        if (id.equalsIgnoreCase(SUFFIX_DYNAMIC)) {
                                                //method used to construct xml relative to dasasource
                                                makeDs(dsRequest);
                                                Document xml = composeDataSource();
                                                String prettyPrint = serializeInString(xml);

                                                return  DataSource.fromXML(prettyPrint);
                                        }else
                                                return null;
                                }catch (Exception e){
                                        e.printStackTrace();
                                        return null;
                                }
                        }
                };
                DataSource.addDynamicDSGenerator(ddsg, SUFFIX_DYNAMIC);
        }

*makeDS(dsRequest):
In the dynamic construction of the datasource (makeDs()) I have defined the following features:
-added new fields
-added the class to serverObject with attribute className="..." and lookupStyle="new"

className is defined the java class for fetch/add/update/remove method.

When press button the javascript to execute is the follow:
Code:

...
                isc.DataSource.create({
                        ID:"exampledynamic",
                        fields:[
                                {name:"prova", title:"prova"}
                                ]
                });

                isc.ListGrid.create({
                        ID: "eventDateGrid",
                        top: 80,
                        left:10,
                        width:1024,
                        height:350,
                        autoDraw: true,
                        alternateRecordStyles:true,
                        dataSource: exampledynamic,
                        autoFetchData: true,
                        showFilterEditor: true,
                        invalidateCache: true,
                        filterOnKeypress: true
                });
               

        var crit = {
                  _constructor:"AdvancedCriteria",
                  operator:"and",
                  criteria:[
                      // this is a Criterion
                      { fieldName:"toServer", operator:"iContains", value:"value"}
                  ]
        };
       
        eventDateGrid.fetchData(crit, callbackEventDateGridFetch);
       
        function callbackEventDateGridFetch(){
                        say("2 - eventGrid data fetched.");
        }
                ...

The problem is the following:
The DSRequest and DSResponse are processed correctly (I have analyzed the flow in debug mode: both server side and client side), but the graphics (smartclient component) in this case "ListGrid" is not updated is not updated with new field whereas the old field (in this case "prova") is enhanced with right data. Where am I wrong? What should I do more?

PS: It does not appear any error (both java side, both side javscript).

Viewing all articles
Browse latest Browse all 4756

Trending Articles