Announcement

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

  • learn_smartgwt
    replied
    I am not supporting the idea to support that behavior in DataSource.get(). I was saying that's that's how it should behave based on new API understanding.

    But i would love to see a DataSource.load() method should also take Criteria as an argument. That would be very helpful in many cases.

    Thanks for advise. I will cerate the new thread will post my use case.

    Thanks again,

    Leave a comment:


  • Isomorphic
    replied
    The docs are correct and the behavior is as designed. This is a *server* API and every server-side call to retrieve a DataSource goes through this API.

    It would be an extremely bad idea to have every client-side call to DataSource.get() initiate a network connection to load DataSource definitions. By design, this only happens if you ask for it (the forceReload parameter of DataSource.load()).

    The DSRequest parameter is there for access to servlet context, for HTTP session access, caching of intermediate results, and similar reasons. It is absolutely not the intent of this API to regenerate DataSources per request, in fact, the docs go into significant depth on DataSource pooling.

    Once again, if you have an actual use case you're trying to implement and you need advice on what APIs to use, explain that use case in a new thread - and explain it with reference to an actual application problem that you would like to solve, and not in terms of this particular API.

    Leave a comment:


  • learn_smartgwt
    replied
    Originally posted by Isomorphic
    Oh, was your expectation that every time the server is contacted for data loading, all DataSource definitions are reloaded?
    Yes. That's what i am expecting from API. Below is what's written in your java doc.

    "The framework will call the getDataSource method of registered DynamicDSGenerators whenever it needs to obtain a DataSource, giving user code a means of generating DataSource definitions at runtime, rather than (or as well as) providing them as .ds.xml files in the filesystem."


    And if that's not the intended behavior then i would say it's a little disconnect in design.

    I mean in case where i need to load data source definition once then
    * I would use .ds.xml file for static ones
    * and can use jsp for dynamic generated data sources which would load once per user per SESSION

    Hence I would not need this API. But if we look at the beauty of this API is - it ask for updated data source definition per user REQUEST and provide opportunity to developer to modify data source definition per user request (NOT just per user session).

    If i would take your argument that this API is designed to load data source once then why would it call DSGeneratoer per request? It call this method at application start up and should never ever call it but it does.
    Also, why would this API require datasource id and DSRequest as parameter? My assumption is your awesome architect designed it to provide us an opportunity to modify data source defination per request.

    I think API design is right. Either I am missing something on how to use it at client side or there is an bug in DataSource.get() method.

    Having this API in 2.4; i think updated DataSource.get() method should always first check with server for updated datasource defination and if server returns null then it should look into locally loaded data sources and if not found then should throw null pointer exception. Isn't it?

    And DataSource.load() won't help us as it does the same think what DataSourceLoader does at bootstrap. It doesn't take request as parameter and it designed to lazy load datasources (may be to boot application load time if you have too many datasources to start with ).

    Ya! an alternative to DynamicDSGenerator API could be to provide one more DataSource.load() method which will take request as an argument (along with datasource id, and properties). DynamicDSGenerator forces every data source lookup to go through with server but adding this load method will give the control to API users to when to load updated data source definition and when to use existing one.
    Last edited by learn_smartgwt; 17 Feb 2011, 13:30.

    Leave a comment:


  • Isomorphic
    replied
    Oh, was your expectation that every time the server is contacted for data loading, all DataSource definitions are reloaded? This expectation is not created anywhere in the docs, rather, DataSources are loaded once. You can force a DataSource to reload with the forceReload parameter of DataSource.load(), or you can switch to a different DataSource ID. Both approaches require rebinding any DataBoundComponents.

    Note that the usage in your sample (generating DataSource fields on the fly for any criteria coming from the client) basically doesn't make sense and opens up a number of security holes. Whatever problem you were trying to solve with that approach, start a new thread for it if you need help, as we've established here that the DynamicDSGenerator API is working as designed and as documented.

    Leave a comment:


  • learn_smartgwt
    replied
    Originally posted by Isomorphic
    These logs show a successful SQL query executed by your dynamically generated DataSource, and your sample does not demonstrate the issue you're claiming.

    You may have confused yourself because you previously were registering your DynamicDSGenerator only when IDACall is invoked. That's obviously too late since IDACall would typically be invoked after the DataSourceLoader servlet. This is why we suggest registering your DynamicDSGenerator via a servlet that has <load-on-startup> set (but after the Init servlet).
    <b>
    Thanks for prompt reply. You are right that's what my problem is it's working fine at server but client completely ignores updated(dynamically generated ds) datasource.
    </b>

    Please correct me if i am wrong but the behavior what i am expecting for this standalone example is :
    When example loads initially the UI should look like attached screen shoot. But when i check the one of the check box above grid (Let's say "Name"), the "Name" as field should get added to my data source and SHOULD BE VISIBLE IN GRID AS LAST COLUMN.

    Please note that server is adding this column in datasource (i can see that in log) but client is NOT HONORING UPDATED DATASOURCE DEFINATION; it uses previously loaded definition.
    Attached Files

    Leave a comment:


  • Isomorphic
    replied
    These logs show a successful SQL query executed by your dynamically generated DataSource, and your sample does not demonstrate the issue you're claiming.

    You may have confused yourself because you previously were registering your DynamicDSGenerator only when IDACall is invoked. That's obviously too late since IDACall would typically be invoked after the DataSourceLoader servlet. This is why we suggest registering your DynamicDSGenerator via a servlet that has <load-on-startup> set (but after the Init servlet).

    Leave a comment:


  • learn_smartgwt
    replied
    Originally posted by Isomorphic
    You should all try logging your generated DataSource definitions - this "standalone test case" looks like it just generates an invalid one (multiple fields named the same thing).
    I log generated DS to server console using following line in MyDataSourceLoader class.
    System.out.println("Xml:" + stringBuffer.toString());

    This is a working code. Generated datasource are completely valid.

    Below is the logged datasource what is being generated at application load time - please note Name, Email & Salary fields are missing.
    Code:
    <DataSource    ID="employees"    serverType="sql"    tableName="employeeTable"    recordName="employee"    testFileName="/examples/shared/ds/test_data/employees.data.xml"    titleField="Name">    <fields>        <field name="EmployeeId"      title="Employee ID"     type="integer"  primaryKey="true"  required="true"/>        <field name="ReportsTo"       title="Manager"         type="integer"  required="true"                foreignKey="employees.EmployeeId"  rootValue="1" detail="true"/>        <field name="Job"             title="Title"           type="text"     length="128"/>         <field name="EmployeeType"    title="Employee Type"   type="text"     length="40"/>        <field name="EmployeeStatus"  title="Status"          type="text"     length="40"/>        <field name="OrgUnit"         title="Org Unit"        type="text"     length="128"/>        <field name="Gender"          title="Gender"          type="text"     length="7">            <valueMap>                <value>male</value>                <value>female</value>            </valueMap>        </field>        <field name="MaritalStatus"   title="Marital Status"  type="text"     length="10">            <valueMap>                <value>married</value>                <value>single</value>            </valueMap>        </field>    </fields><operationBindings><operationBinding operationType="fetch"><whereClause> Gender = 'male' </whereClause></operationBinding></operationBindings></DataSource>
    And Below is the logged datasource what is being generated when you check a check box on screen and refresh the grid. Please note that Name, Email & Salary fields are available.
    Code:
    <DataSource    ID="employees"    serverType="sql"    tableName="employeeTable"    recordName="employee"    testFileName="/examples/shared/ds/test_data/employees.data.xml"    titleField="Name">    <fields>        <field name="EmployeeId"      title="Employee ID"     type="integer"  primaryKey="true"  required="true"/>        <field name="ReportsTo"       title="Manager"         type="integer"  required="true"                foreignKey="employees.EmployeeId"  rootValue="1" detail="true"/>        <field name="Job"             title="Title"           type="text"     length="128"/>         <field name="EmployeeType"    title="Employee Type"   type="text"     length="40"/>        <field name="EmployeeStatus"  title="Status"          type="text"     length="40"/>        <field name="OrgUnit"         title="Org Unit"        type="text"     length="128"/>        <field name="Gender"          title="Gender"          type="text"     length="7">            <valueMap>                <value>male</value>                <value>female</value>            </valueMap>        </field>        <field name="MaritalStatus"   title="Marital Status"  type="text"     length="10">            <valueMap>                <value>married</value>                <value>single</value>            </valueMap>        </field> <field name="Name"   type="text"     length="128"/> <field name="Email"   type="text"     length="128"/> <field name="Salary"   type="text"     length="128"/>    </fields><operationBindings><operationBinding operationType="fetch"><whereClause> Gender = 'male' </whereClause></operationBinding></operationBindings></DataSource>
    Also please find the attached server log also.

    Thanks,
    Attached Files

    Leave a comment:


  • Isomorphic
    replied
    You should all try logging your generated DataSource definitions - this "standalone test case" looks like it just generates an invalid one (multiple fields named the same thing).

    Leave a comment:


  • learn_smartgwt
    replied
    @abbottk2000 - I would disagree with you. All wiring works fine if you do it write.

    @Isomorphic - Either we are missing something on how to use the datasource at client side otherwise there is definetly something wrong with API. All works fine i can even see modified datasource at server side but client completely ignore it and uses the earlier loaded version.

    I have replicated the issue in BuiltInDS example. Hope this will help to pin point the issue.
    Attached Files

    Leave a comment:


  • Isomorphic
    replied
    Your assertions are definitively incorrect and many other users are successfully using this API. While a sample is on the way (no ETA), what you need to do if you think there's a bug is to produce a standalone test case. This will allow us to identify usage errors in your code, if any.

    Leave a comment:


  • abbottk2000
    replied
    All,

    I am using the eval smartgwtee 2.4. Tried 2.5 as well.

    I followed the example of the earlier poster and have come to the same conclusions:
    1) Unless at least a skeleton of a datasource id is loaded through the DataSourceServlet (from the initial html) file, the DynamicDSGenerator is never called! As such a null datasource is returned immediately from DataSource.get(dsName)

    2) If the DynamicDSGenerator is registered as :
    DataSource.addDynamicDSGenerator(new MyDSGenerator(), "PREFIX")
    rather than:
    DataSource.addDynamicDSGenerator(new MyDSGenerator())

    it is never called!

    I would like to suggest that Isomorphic provide a simple but complete example of DynamicDSGenerator in action that works (perhaps based on the BuiltinDS sample and the embedded HSQLDB)

    In addition, we have seen much mention of DataSource.load(). We would like to suggest that it be made clear that
    (1) this is a client side call and
    (2) see a complete example of where this works.

    Each time that we try make this call, we get a DataSourceServlet 'not loaded' error, when it is clear that the DataSourceServlet has been loaded (and works) as it has loaded datasources specified in the .html file.

    Regards.

    Leave a comment:


  • Isomorphic
    replied
    No empty file is required and you use the DataSourceLoader servlet normally.

    Other than that, we need logs to help - if you need confidential treatment of issue reports, that is available with Enterprise Support.

    Leave a comment:


  • learn_smartgwt
    replied
    Originally posted by Isomorphic
    Indicate version and browser, and show the complete server-side log for the request that ends in the exception, including the exception itself (do not trim anything). Always do this.
    Thanks for response. I can't post server log due to sensitive information. But i would height appreciate and will try to find the issue myself if you can please guide me how to load & use dynamic datasource at client side.

    Below are my questions?
    1. Do i need to create a empty file with same datasource id under ds folder?
    2. Do i need to add this datasource id in html boot strap to load via DataSourceLoader?dataSource= syntax ? if not then how to make it available so DataSource.get() can create the instance from server?

    In my case subclassing to IDACall and register Dynamic generator works fine as i can see all the calls related to system as well as project ds going through this generator.

    I am using SmartGWt 2.4 eval version with IE 7 browser.

    Thanks again.

    Leave a comment:


  • Isomorphic
    replied
    Indicate version and browser, and show the complete server-side log for the request that ends in the exception, including the exception itself (do not trim anything). Always do this.

    Leave a comment:


  • learn_smartgwt
    replied
    I am still struggling to get this new API working. Could someone please point me if i am missing something? What i did is:

    1. Extended IDACall servlet and registered DynamicDSGenerator as below.
    public class MyCallServlet extends IDACall {
    public MyCallServlet (){
    super();
    DataSource.addDynamicDSGenerator(new MyDynamicDSGenerator(), "My");
    }
    }

    2. And my MyDynamicDSGenerator class looks like below.
    public final class MyDynamicDSGenerator implements DynamicDSGenerator {
    public DataSource getDataSource(String id, DSRequest dsRequest) {
    DataSource dataSource = null;
    if(id != null && id.startsWith("My")) {
    try {
    String xml = createMySearchDataSource(id, dsRequest);
    dataSource = DataSource.fromXML(xml);
    } catch (Exception e) {
    logger.log(Level.SEVERE, e.getMessage(), e);
    }

    }
    }
    }

    Now the problem cases are -
    If i mention datasource name in html boot strap using "DataSourceLoader?dataSource=" syntax and not include anything with that name under ds folder then i get "Unable to Load Exception"
    And if i provide a empty file for this datasource (MySearch) under /ds folder then it doesn't load fresh copy for the same datasource from server for every request it's being used.
    And if i don't mention datasource name in html boot strap but try to access the datasource in my code assuming that if it doesn't exists then SmartGWt will load it from server but it doesn't and i get NullPointerException.

    May i missing something? Kindly help.

    Thanks,
    Last edited by learn_smartgwt; 15 Feb 2011, 08:07.

    Leave a comment:

Working...
X