Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your question seems to be too broad, however I try to give some answers.</p> <blockquote> <p>How to pass results from RESTful service to JSF components?</p> </blockquote> <p>You can use the pattern implemented by NetBeans' guys. If you use this IDE, there is an option to automatically Build RESTful web services from database. Essentially, this pattern create all DAO basic functionalities in an abstract generic class called <code>AbstractFacade</code>. Then, for each concrete Entity class present in your JPA representation, it creates a Stateless class extending <code>AbstractFacade</code>, and adds jax-rs annotations to it in order to let it expose the Entity class through RESTful web service.</p> <p><strong>You can then access the service directly by EJB injection</strong>. Just use @EJB annotation to inject your service in any container-managed class (in the same application, but also in other applications provided that you use portable JNDI naming rules). In particular, you'll be interested in injecting the facade classes in the managed beans backing your facelets components.</p> <blockquote> <p>What's the best way to load the data? Is there a performance concern if every time I have to call the API from the server side (as opposed to client side using jquery and plain html)?</p> </blockquote> <p>Since you need to display thousands of records, your best bet is using Primefaces' <strong>lazy loading</strong> in your datatable. Your application will then call the db only for retrieving the few tens of records displayed in the current page. Absolutely avoid displaying more than those records, otherwise the client browser will likely be negatively impacted.</p> <blockquote> <p>How can I insert this new record into my datamodel #{testBean.sampleDataModel} so that I don't have to load the entire table again?</p> </blockquote> <p>Please distinguish between <em>loading from db</em> and <em>loading in jsf</em>. You can program your backing bean in order to call the db (which is usually the most expensive operation) only when you think it's necessary. As far as I know, both JSF's and PrimeFaces' dataTable implementations don't give you the possibility to manage the table contents at a row level: at every ajax update, the entire table will be reloaded. However, as already said, this won't impact your application's performances as long as you have correctly programmed your backing bean (i.e. <strong>choosing the right bean scope</strong> and <strong>avoid calling the db service in getters</strong>).</p> <p>Useful Links:</p> <ul> <li><a href="https://netbeans.org/kb/docs/websvc/rest.html" rel="nofollow noreferrer">NetBeans' tutorial</a> about RESTful web services</li> <li><a href="http://netbeans.dzone.com/nb-generate-simpler-rest" rel="nofollow noreferrer">Rubinoff's article</a> about the pattern used by Netbeans' RESTful web services</li> <li><a href="http://www.primefaces.org/showcase/ui/data/datatable/lazy.xhtml" rel="nofollow noreferrer">PrimeFaces showCase</a> about lazy loading</li> <li><a href="https://stackoverflow.com/questions/7031885/how-to-choose-the-right-bean-scope">How to choose the right bean scope</a></li> <li><a href="https://stackoverflow.com/questions/2090033/why-jsf-calls-getters-multiple-times">Why JSF calls getters multiple times</a></li> </ul>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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