I have test.xhtml with:
<h:form id="formProduct" >
<h:panelGroup id="filterProductTotal" layout="block">
<h:outputText value="#{filtersControllerRequestScoped.filteredProductsCount}"/>
</h:panelGroup>
<div id="product_container">
<ui:repeat value="#{filtersControllerRequestScoped.getFilteredProducts(1)}" var="product">
<div class="item">
<util:product-item-preview_2 productItem="#{product}"/>
</div>
</ui:repeat>
</div>
</h:form>
I read about the problem of repeated call methods, and fought to keep the business logic of the GET methods and tried to realize LAZY load.
Method getFilteredProducts() in request scoped bean called in various requests, even when I don't update form id="formProduct". Requests called by "p:ajax" or "p:remoteCommand" with and without "update" anithig.
Problem for me - I don't understand why the method "getFilteredProducts" is called each time (every ajax call), but "filteredProductsCount" only once when the page is loaded.
Update: some idea.
May be when i use "#{product}" in other requests in fact i use "#{filtersControllerRequestScoped.getFilteredProducts(1).get(INDEX)}", not an simple object "#{product}"?
Update: Part of <util:product-item-preview_2/>
:
<composite:interface name="productItemPreview" displayName="hello">
<composite:attribute name="productItem"/>
</composite:interface>
<composite:implementation>
...
<h:commandLink value="quick order" onclick="quickOrderPrepare(#{cc.attrs.productItem.productId})">
<p:ajax process="@this" oncomplete="quickOrderShow()" partialSubmit="true"/>
</h:commandLink>
...
<span class="b-prices">
<h:outputText value="Price: "/>
<h:outputText value="#{discountControllerRequestScoped.getProductPrice(cc.attrs.productItem)}">
<f:convertNumber minFractionDigits="2" maxFractionDigits="2"/>
</h:outputText>
</span>
...
<script>
function quickOrderPrepare(productId) {
setProductQuickOrderPanelRemoteCommand([{name: 'productId', value: productId}]);
}
function quickOrderShow(){
updateQuickOrderPanelRemoteCommand();
$('.popup.productQuickOrder').bPopup({
onClose: function() { updateBasket(); }
});
}
</script>
setProductQuickOrderPanelRemoteCommand
and updateQuickOrderPanelRemoteCommand
are primefaces remotecommand.