Sorry, you're correct that handleDSRequest() is too late, however there is still no need to worry about doGet or doPost or know anything about the encoding of the request, as APIs such as processRequest() or processRPCTransaction() are both early enough.
Announcement
Collapse
No announcement yet.
X
-
For other finding this thread:
You need to inject the class with:- httpServletRequest.setAttribute() in a IDACall-subclass.handleDSRequest() for SQLs
- httpServletRequest.setAttribute() in a DataSourceLoader-subclass.doGet() for automatic GUI changes because of canView:false.
The only thing not working as of today is that joins for not needed includeFrom fields are still being generated. This is not a security issue, but results in SQLs more complicated than necessary.
Isomorphic: If I understand correctly, the IDACall-subclass only affects incoming GUI requests. Therefore I also need this in my RESTHandler-subclass, correct? What about server initiated requests? Wouldn't it be better this this were in my SQLDataSource-subclass instead of IDACall and RESTHandler?
Best regards
Blama
Comment
-
Hi Isomorphic,
I do have a question w.r.t. to this:
Originally posted by Blama View PosthttpServletRequest.setAttribute() in a DataSourceLoader-subclass.doGet() for automatic GUI changes because of canView:false.
Code:import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.isomorphic.servlet.DataSourceLoader; import com.lmscompany.lms.server.worker.T_SETTINGS; public class MyDataSourceLoader extends DataSourceLoader { private static final long serialVersionUID = 616663945156810788L; @Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setAttribute("[I]t_config[/I]", T_CONFIG.getInstance()); super.doGet(request, response); } }
Code:<servlet> <servlet-name>DataSourceLoader</servlet-name> <servlet-class>com.lmscompany.lms.server.LMSDataSourceLoader</servlet-class> </servlet>
Does this internal "get DataSource" also use the class (=the servlet) from web.xml?
Somehow I can't imagine it is that way, as there is not always a HTTP request and therefore I think you'll do this somehow differently.
Can I (and must I) also inject my Velocity variables there?
Thank you & Best regards
Blama
Comment
-
Can't quite figure out the question here, but if we have it right, no, code in a DataSourceLoader servlet will not be invoked if processing starts from IDACall (or a subclass).
If you've written your DataSource so that it requires certain variables to be present when created, then you will need to make sure those variables are defined in all the ways you might invoke it, including in standalone (non-servlet-triggered) usage if you are using the DataSource that way too.
Comment
-
Hi Isomorphic,
OK, understood.
So for me, DataSourceLoader is just the way to transport the .ds.xml config relevant on the client side for the logged in user to the browser.
DataSourceLoader and IDACall and RESTHandler requests:- httpServletRequest.setAttribute() in a DataSourceLoader-subclass.doGet() for automatic GUI changes because of canView:false.
- httpServletRequest.setAttribute() in a IDACall-subclass.handleDSRequest() for SQLs created for an incoming IDACall-request
- httpServletRequest.setAttribute() in a RESTHandler-subclass.handleDSRequest() for SQLs created for an incoming RESTHandler-request
You write "then you will need to make sure those variables are defined in all the ways you might invoke it". How to do that? I have the strong feeling this is somehow to be done in SQLDataSource-subclass, but in #19 you write this is too late. Do I need it additionally there?
Additional question for better debugging: Is there some way for me to get the DataSource, it's fields etc you are using to generate an SQL?
So this means the "XML" (most likely not possible) or at least the DataSource instance after Dynamic DataSource modification and after Velocity declarative security evaluation, so that I can use getters on it? Can/Should I put a breakpoint in SQLDataSouce.execute() for this?
Or just DataSourceManager.get()? But how to inject then velocity-variables then?
Thank you & Best regards
Blama
Comment
-
If those are the ways you invoke DataSource operations, then you are covered.
As we explained, there is also Standalone Usage. In that case, there isn't even a servlet, so your DataSource cannot work in that mode. If you are not using that mode, there's no reason to care.
Second question: the XML is on disk and/or returned from your own DataSourceGenerator code, so you already have that. Then, as far as the created DataSource instance, there are server-side APIs such as DataSource.getFieldNames() / getField().
Comment
Comment