Hello,
I have a similar need in my project. I need to create the datasource on the
fly depending on the user's preference settings and also access privileges.
I was able to successfully populate the datasource with the additional
custom fields (definition only).
The problem I have is related to loading the data from the tables.
In my case, the extra fields do not correspond to table columns, but instead
they correspond to table rows (data). I have 2 tables - ProductMaster
and ProductDetails table.
<DataSource
dbName="Oracle"
tableName="PRODUCT_MASTER"
ID="PRODUCT_MASTER"
serverType="sql"
>
<fields>
<field primaryKey="true" name="PRD_ID" type="sequence"></field>
<field name="NAME" title="Name" length="50" type="text"></field>
<field name="CATEGORY" title="Category" length="50" type="text"></field>
<field name="PRICE" title="Price" length="10" type="number"></field>
</fields>
<serverObject lookupStyle="spring" bean="prdMasterDataDao"/>
</DataSource>
<DataSource
dbName="Oracle"
tableName="PRODUCT_DETAILS"
ID="PRODUCT_DETAILS"
serverType="sql"
>
<fields>
<field primaryKey="true" name="PRD_ATTR_ID" type="sequence"></field>
<field primaryKey="true" name="PRD_ID" type="sequence"></field>
<field name="PRD_ATTR_KEY" length="20" type="text"></field>
<field name="PRD_ATTR_VALUE" length="50" type="text"></field>
</fields>
<serverObject lookupStyle="spring" bean="prdDetailsDataDao"/>
</DataSource>
The reason behind this table structure is that each customer might have
unique catalog fields related to each product. I want to load the productGrid
as below (2 examples relating to 2 different customers):
ID Name Category Price Units Brand Manufacturer
1 N1 C1 $1.00 LB B1 M1
2 N2 C2 $0.50 KG B2 M2
ID Name Category Price Units Weight StorageCriteria
3 N3 C1 $5.00 Litres 1.0 -5F to 75F
4 N4 C3 $2.00 KG 1.0 Below 75F
I am now stuck at trying to creating/populating the grids as shown below.
Any pointers would be much appreciated.
Thanks & Regards.
Announcement
Collapse
No announcement yet.
X
-
For now, we'd recommend using a separate approach for configuring your code vs setting this property in server.properties and just ensuring the values stay in sync. We may later add some convenience methods to help discovering these settings at runtime.
Leave a comment:
-
Originally posted by IsomorphicYou don't want to be using BuiltinRPC.saveSharedXML() - this is for Visual Builder only and not a documented API. Simply use normal Java IO to save to the filesystem.
Leave a comment:
-
You don't want to be using BuiltinRPC.saveSharedXML() - this is for Visual Builder only and not a documented API. Simply use normal Java IO to save to the filesystem.
Leave a comment:
-
Originally posted by IsomorphicYes, you can generate it just once and save it.
BuiltinRPC.saveSharedXML, but never mind.)
DataSource.execute() is still there, with the same behavior, and is still the override point we suggest for many use cases. What makes you think it was removed?Last edited by csillag; 20 Dec 2009, 06:21.
Leave a comment:
-
Originally posted by IsomorphicYes, you can generate it just once and save it.
Originally posted by IsomorphicDataSource.execute() is still there, with the same behavior, and is still the override point we suggest for many use cases. What makes you think it was removed?
smartgwtpro-2.0/doc/server/javadoc/com/isomorphic/datasource/DataSource.html
Leave a comment:
-
Yes, you can generate it just once and save it. Think carefully about clustering however (need to make sure all servers generate the same file).
Regardless, you don't have to "duplicate" logic. Call the same logic from both places instead.
There is no separate call to load the DataSource. See previous comments about having a jsp or servlet that returns the same thing that the built-in DataSourceLoader servlet returns - you just target just a .jsp or servlet with a <script src=> tag in your host .html file.
DataSource.execute() is still there, with the same behavior, and is still the override point we suggest for many use cases. What makes you think it was removed?
Leave a comment:
-
Originally posted by jay.l.fisherI've made more progress and am sure that I'm executing my new code on the server side, but it seems that the IDACall.handleDSRequest method is only called when requesting the actual data from the data source, not the data source definition. Is IDACall the right servlet to be subclassing and if so, am I overriding the correct method?
Leave a comment:
-
Further questions about doing this
Originally posted by Isomorphic...
To generate a DataSource dynamically server-side, create the XML on the fly on the server and pass it to DataSource.fromXML(). You must do this in the server-side processing chain *before* the DataSource would need to be accessed for the first time, that is, you'll need to create your own servlet that creates the RPCManager class, calls getRequests(), and iterates through them.
Can't this be done just once, outside the chain, when server server side is initializing? (I thought I generate the new DS XML, save it in the usual directory, and then let things go the usual way.)
If your DataSource file remains at the same location and is in the same format, nothing changes about client-side behavior, but the client will only see the fields declared in the actual file.
To make the client see the dynamic fields, create a .jsp or servlet that produces the same thing the DataSourceLoader servlet produces (JavaScript DataSource definitions) by again calling DataSource.fromXML() with dynamic XML and now also using JSTranslater.toJS() to transform the dynamic DataSource to JS (which the JSP or servlet should stream back as its HTTP response). Then just point a <script src=> tag at the URL of this servlet/.jsp
generate the XML DataSource definition dynamically and call DataSource.fromXML(). You can then take the DSRequest and pass it to DataSource.execute().
In my version (SmargGWT-Pro, 2.0), the class com.isomorphic.datasource.DataSource no longer has an "execute" method.
Where did it go?
Leave a comment:
-
DMI did not work at all so i ended up adding serverConstructor and that did the job. It works now.
But my biggest question still stand - In my case Data source is not just generated once for a single run instance instead it has to be generated based on user logged in and few runtime parameters so how can we make sure that JSP call and custom IDACAll servlet will always return same information?
Can you please point us in right direction?
Leave a comment:
-
Okay, i also have integrated client side using a jsp but the problem i have is - it doesn't seem to find out DMI fetch operation.
And the error i get is "Operation fetch is not supported" even although operation binding is defined in the data source.
Also. in my case Data source is not just generated once for a single run instance instead it has to be generated based on user logged in and few runtime parameters so how can we make sure that JSP call and custom IDACAll servlet will always return same information?
Please suggest.Last edited by rathiandi; 25 Nov 2009, 13:31.
Leave a comment:
-
Originally posted by jay.l.fisherSuccess!! Thanks for your help.
I am also dealing with same problem but unlike Jay i have to generate data source based on few parameters coming from client every time.
Jay - Can you please post your client side integration code?
Thanks,
Leave a comment:
-
No; DataSource.fromXML() is not dynamically registering a DataSource or anything similar. Once the .jsp / servlet has completed the response to the client, the server still does not know anything about your dynamic DataSource.
Leave a comment:
Leave a comment: