Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yours seems to me a good approach, so nothing to say about that. If you want to be able to create new instances of your JavaBean on the client side while keeping them in sync with their server side structure, then you could provide to the client a "proxy" object, that you can use to create new instances. This proxy, being generated on the fly by the server, will be always able to create correct instances of the client-side objects that are always in sync with your server-side counterpart.</p> <p>Example (very rough, it's just to give you an idea):</p> <p>1) include a server-side generated proxy for your javabeans</p> <pre><code> &lt;script src="/server/url/mapped/to/servlet/ssproxy.js"&gt;&lt;/script&gt; </code></pre> <p>The proxy, dynamically generated via a Servlet, will contain the javascript code necessary to create new client-side instances of your server-side objects (using Revealing Module Pattern here):</p> <p>2) Content of your ssproxy.js (generated by the server):</p> <pre><code>var server = {}; server.Proxy = (function(){ function _extend( obj, additional ) { //copy properties from additional into obj //... I'll leave that to you... } function _createObject( config ) { var default = { attribute1:'', attribute2:'' }; //you can implement something //like jQuery extend() function here //to override default values with passed in args _extend( default, config ); return default; } return { createObject: _createObject }; }()); </code></pre> <p>you can use it then to create objects when you need it:</p> <pre><code>var newobj = server.Proxy.createObject({attribute1:'custom value'}); </code></pre>
    singulars
    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.
    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