Note that there are some explanatory texts on larger screens.

plurals
  1. POReducing the JSF component tree/state by an alternate approach. Is it Okay?
    primarykey
    data
    text
    <p>Unfortunately, I made a mistake of choosing JSF for an internet facing, high traffic application, now I am wondering as to how to improve the scalability of this JSF webapp.</p> <p>I have a JSF page that displays a large no of items each of which may be commented upon. Inorder to reduce the state &amp; improve performance I am trying to reduce the no of <code>forms</code>/<code>commandButtons</code> on the page.</p> <p><strong><code>1.</code></strong> Through what ways can I reduce the component tree/ statefulness of JSF ? Do the plain html elements(that are mixed in between the jsf tags) also form part of component tree ? I dont know how component state saving has been helpful to my app since I have been following plain request/response model while designing my app, (may be it is helpful for just JSF's internal requirements)!?</p> <p><strong><code>2.</code></strong> I was thinking of an approach where instead of creating a separate <code>&lt;h:form&gt;</code> (each with a separate <code>commandButton</code>) for every item like below,</p> <h2>(Usual Approach)</h2> <blockquote> <pre><code>&lt;h:form&gt; &lt;!-- for each item a separately --&gt; &lt;h:outputText value="Add comment"/&gt; &lt;h:inputTextarea value="#{itemController.comment}" required="true"/&gt; &lt;p:commandButton actionListener="#{itemController.addUserComment(123)}" value="Add" /&gt; &lt;/h:form&gt; </code></pre> </blockquote> <h2>(Alternate Approach)</h2> <p>I am trying to make the above better by just putting a single remoteCommand for all the items &amp; pass the required parameters to this remoteCommand.</p> <blockquote> <pre><code>&lt;form&gt; &lt;input id="item1_comment"/&gt; &lt;button onclick="addComment(123, 'item1_comment');"/&gt; &lt;/form&gt; &lt;script type="text/javascript"&gt; function addComment(itemId, id) { $('#comment_in').attr('value', $('#'+id).attr('value')); $('#forItem_in').attr('value', itemId); addComment_RC(); // call remoteCommand to show the content in dialog } &lt;/script&gt; &lt;h:form prependId="false" &gt; &lt;!-- for all items, just single remoteCOmmand --&gt; &lt;h:inputHidden id="comment_in" value="#{itemController.comment}"/&gt; &lt;h:inputHidden id="forItem_in" value="#{itemController.forItem}"/&gt; &lt;p:remoteCommand name="addComment_RC" process="@form" actionListener="#{itemController.addComment()}" /&gt; &lt;/h:form&gt; </code></pre> </blockquote> <p>Is it better to do it this way (or are there any issues with this approach)?</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.
 

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