Anytime after the Init Servlet has run. For example, a Servlet set to load-on-startup, but which runs after the Init Servlet.
Announcement
Collapse
No announcement yet.
X
-
Ok, I think the settings are now correct, but now I have the next problem.
If I understood you correctly, these are the steps to be done:
Code:/sc/DataSourceLoader?dataSource=DYNAMIC_DS
Since I register the generator, it will first try to get the datasource from the generator:
Code:public DataSource getDataSource(String id, DSRequest dsRequest) { .getSession().getAttribute("mandantId")); LOG.info("Trying to load datasource: " + id ); if (id.equals("DYNAMIC_DS")) { //load the clientId from the session //then load the correct XML from the disk, //depending on the clientId, using the clientId as a path } return null; }
1) I cannot get the session, since the dsRequest is null. How can I then get the clientId?
2) The original, requested DS ID is: DYNAMIC_DS. After loading the XML from the disk in the getDataSourceMethod, the ID will be: 1_DYNAMIC_DS, or 2_DYNAMIC_DS, as you suggested. So I think this will also not work, since the original id is different than the id returned. How to solve this?
Comment
-
Ok, reading http://forums.smartclient.com/showthread.php?t=15937&highlight=DataSource.addDynamicDSGenerator I think I got it.
So the calling part (server or client) is in charge of creating the compound-name, e.g. DYNAMIC_1_MyDs. It calls DataSource.get("DYNAMIC_1_MyDS"), and the getDataSource() parses this ID, gets the clientId, and reads the correct definition from disk. It returns the DataSource read.
I think this would work.
BUT: What is the advantage of doing this, and not just creating .ds.xmls called: 1_myDS.ds.xml, 2_myDS.xml, 3_myDS.xml, loading them ALL in the main .jsp page, and then calling the correct one?
Wouldn't this be exactly the same?
If I understand this correctly, in both cases all datasources will be loaded, that's why we need different IDs, so why to use one method instead of the other one ?
Comment
-
You are right, after some time I am taking this approach again.
It works, but I have a question regarding how to load the datasource on the server-side.
On the client-side, I can call DataSource.get("id"), but on the server side?
It seems to work calling:
DataSource ds = new DSRequest(id, DataSource.OP_FETCH, rpcManager).getDataSource();
But since I am not going to use this request I was wondering if this is the correct way to get the DataSource on the server-side?
Comment
Comment