Note that there are some explanatory texts on larger screens.

plurals
  1. POJSP backend for ExtJS
    primarykey
    data
    text
    <p>This question is about a proper architecture using JSP as a controller for ExtJS.</p> <p>I am fairly new to server side development but I am pretty familiar with ExtJS 4 and getting better with Java and SQL daily.</p> <p>I am trying to create a JSP controller to <em>write</em> the data from stores in ExtJS. I have MSSQL database and Tomcat running on the server. </p> <p>I successfully created a JSP (sqlData.jsp) that reads from the database and returns JSON data. I pass a query name to this JSP, it then looks up what the query is from a "query" table (columns: <code>[query_id],[query_name],[query]</code>). It then runs the query and returns the data in a JSON format - this is working fine to get data into ExtJS from a database. </p> <p>To use this backend set-up I usually configure the store like this:</p> <pre><code>var store = Ext.create('Ext.data.Store', { model: 'aModel', proxy: { type: 'ajax', url: 'sqlData.jsp?queryName=aQueryName', reader: 'json' }, autoLoad: true }); </code></pre> <p>Somehow, I need this sqlData.jsp to also handle a <code>store.save()</code> call from the ExtJS framework. Which means the JSP needs to receive a POST request and then do an update based on a pile of JSON data (ExtJS sends read request as GET and write methods like <code>store.save()</code> are POST).</p> <p>My plan was to add something in the Java to recognize whether it is a POST or GET request. Then, if it is a POST request, I would send it to a different Java method in the JSP to parse the JSON and write it to the database. </p> <p>Of course I would have to change my "query" table to have another column for update/insert statements linked to the same queryName (i.e.: <code>[query_id],[query_name],[select_query],[update_query]</code>).</p> <p>Does this backend implementation make any sense? </p> <p>Anyone else use JSP and ExtJS to achieve this smoother?</p> <p>I noticed that there is an <code>api</code> config option I can set in my proxy to specify different URLs for the different operations (READ, WRITE, DELETE, etc). Should I make a separate JSP and direct all write requests using this config instead?</p> <p>Would it be wiser to add a <code>writer: 'json'</code> config on the proxy so that it parses <em>before</em> POSTING? I figured I would have to parse it in the JSP either way so I didn't think I should.</p> <p>Any pointers will be much appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload