jsf - PrimeFaces dialog lazy loading (dynamic="true") does not work? -
i have changed beans requestscoped viewscoped. suddenly, lazy loading of dialogs not work. using primefaces jsf library.
<html> <h:body> <f:view> <h:form> <p:commandbutton id="addid" value="add" title="add" type="button" onclick="dlgmultifileselect.show();"/> ... </h:form> <p:dialog header="dialog" widgetvar="dlgmultifileselect" modal="true" resizable="true" dynamic="true"> <ui:include src="/dialogs/media_browser.xhtml"/> </p:dialog> </f:view> </h:body> </html> seems dynamic="true" not work since backing bean in media_browser.xhtml gets initialized immediately, , not when button clicked.
am doing wrong?
using primefaces 3.5.0.
have found pretty easy workaround:
let's quote balusc's answer on other question: skip executing <ui:include> when parent ui component not rendered
the
<ui:include>runs being taghandler during view build time, while rendered attribute evaluated during view render time.
regarding first proposal:
- use view build time tag
<c:if>around<ui:include>part.
so first add new method bean. (may useful in application scoped bean reuse)
public boolean isajaxrequest() { boolean val = facescontext.getcurrentinstance().getpartialviewcontext().isajaxrequest(); return val; } then enclose <ui:include> inside following <c:if>:
<p:dialog id="yourdlg" header="dialog" widgetvar="dlgmultifileselect" modal="true" resizable="true" dynamic="true"> <c:if test="#{applicationbean.ajaxrequest}"> <ui:include src="/dialogs/media_browser.xhtml"/> </c:if> </p:dialog> so @ page load time, request isn't ajax... , on other ajax requests on base page, dialog won't updated... if trigger dialog
<p:commandbutton id="addid" value="add" title="add" type="button" oncomplete="dlgmultifileselect.show();" update=":yourdlg"/> and update it's content, rendered!
please note following changes: p:dialog id, p:commandbutton update , p:commandbutton oncomplete
Comments
Post a Comment