Issue with primefaces dynamic dialog - jsf

I have a dynamic Dialog with a CommandButton or an OutputLabel inside, using a value that takes time to generate. To avoid loosing time when loading the page, I used the dynamic param of the dialog. Unfortunately, my function is still called and the necessary time to display the page is very long.
<p:dialog dynamic="true">
<h:outputText value="#{myBean.myFunction()}"/>
</p:dialog>
Any idea what the issue could be?
Using PF Version 11.0.7

Add appendTo="#(body)" to p:dialog, that should help.
<p:dialog appendTo="#(body)" dynamic="true">
<h:outputText value="#{myBean.myFunction()}"/>
</p:dialog>
visit: https://primefaces.github.io/primefaces/12_0_0/#/core/dialogframework

Related

Primefaces Command button causes page reloading

I am working an primefaces application, I am using
Primefaces 5.x version, Jsf 2.x
which has tabview
in one of the tabs I have command button, by clicking on it pdf export should happen.
For the first time click on button page is getting reloaded, from the second time on words request is going to bean page and downloading is working correctly.
this is my code snippet for command button :
<h:form id="mainForm">
<p:tabView id="myId" activeIndex="#{bean.currentTabIndex}" dynamic="true" cache="false">
<p:tab title="vehicle" id="vehId" styleClass="panelBack">
<h:form id="exportForm">
// some code
<p:commandButton value="export" process="#this" actionListener="# {bean.export()}" ajax="false" id="exportButton" />
</h:form>
</h:form>
If I make dynamic = false, it's working. I mean after clicking export button request is going to bean class, export is working.
What would be the problem? Can somebody help me?
Thank you
Yes your problem is most likely nested that is not allowed in JSF.

primefaces p:inputSwitch not work in dialog while use update the dialog

I am doing a on-off with p:inputSwitch, it's in a dialog. When an ajax call inside a form happens in combination with an update on the inputSwitch, the inputSwitch behaves strange and always resets its state. Here is a simple reproducible example (without the need of a backing bean):
<h:form id="buttonForm">
<p:commandButton value="button" update="switch" oncomplete="PF('switchDialog').show();" />
<p:dialog widgetVar="switchDialog">
<p:inputSwitch id="switch" />
</p:dialog>
</h:form>
Interesting observations:
When you remove the h:form the problem is gone
When you remove the update parameter it works
When the p:inputSwitch is outside of the p:dialog it also works
Sorry for this zombie post but i've found a solution that can help.
Add in your
<p:dialog widgetVar="switchDialog" dynamic="true">
Regards

Variables not showing values in <p:dialog> window

I have a program that is felling some fields of an object and this object values need to appear in a modal dialog window.
When debugging the program I see the objects being filled correctly, all the values are there.
Right after feeling this values I am showing the dialog window from my bean but the values does not appear.
This is how I am defining my dialog window.
<p:dialog id="infoDialogReset"
class="dialogWindowGenericMessage"
showHeader="false"
widgetVar="infoDialogResetResolve" modal="true" showEffect="fade" hideEffect="fade" resizable="false" appendTo="#(body)" closable="false">
<p:panel id="infoDialogResetPanel" class="dialogText18Blue" header="RESET + RESOLVE CHANNEL" style="">
<p:outputLabel >reset status ->#{channelManagement.selectedChannel.resetStatus}</p:outputLabel>
</f:facet>
</p:panel>
</p:dialog>
This is the piece of code where I am passing the values to the variables values.
this.selectedChannel.setResetStatus(0);
RequestContext.getCurrentInstance().update(":j_idt3:mainForm:infoDialogReset");
context.execute("PF('infoDialogResetResolve').show();");
As the result the dialog windows is being shown as expected but the value for the channelManagement.selectedChannel.resetStatus object is not appearing.
Any ideas what am I doing wrong?
I have changed my approach.
Instead of calling my modal dialog screen from by back bean I have called directly from the .xhtml page.
Just for reference if someone is facing the same issue. This is the way that I am doing the call.
<p:commandButton ajax="true" class="buttonCommmandBlue" value="RESET" oncomplete="PF('dialogResetResolve').show()" update=":j_idt3:mainForm:panelResetResolve" action="#{channelManagement.resetChannel(channelManagement.selectedChannel.name)}">

primefaces panelgrid update from datatable

I am getting "Cannot find component with identifier "contentForm:tabView:form:addressDialogPanel" referenced from "contentForm:tabView:form:addressBookTable" " error. How can I update my panelGrid inside the widget?
<h:form id="form">
<p:dataTable id="addressBookTable">
<p:ajax event="rowSelect" listener="#{addressBookController.onRowSelect}"
update="contentForm:tabView:form:addressDialogPanel" oncomplete="addressDialog.show()" />
</p:dataTable>
<p:dialog id="addressDialogId" widgetVar="addressDialog">
<h:panelGrid id="addressDialogPanel" columns="2" cellpadding="4">
</h:panelGrid>
</p:dialog>
</h:form>
The main problem is that you are giving the wrong client ID of component's. Also p:tabView is a component it is not a form. When you define a h:form, it generates a standart HTML form element. And when you submit the page JSF uses POST to submit your data into backing bean. So nesting them is going to occur lot's of issues that you don't expect. You should seperate forms into sections like sideForm or searchForm or etc.
You should detect the correct client ID of your component when you try to update it. You can do this with your browser's developer settings(press f12 for chrome). Then select component with the magnifier button and give that ID into update property. Just like here:
You should read to learn basics of JSF for example from here

How to update a component inside of dataTable from outside of it

I am using Mojarra implementation of JSF 2.1 with Primefaces 3.2.
My problem approximately looks like this:
<p:dialog id="someDialog">
..
<h:form id="dialogForm">
<p:commandLink action=".."update=":someForm:someUIRepeat:someDataTable:someInputTextArea"/>
</h:form>
</p:dialog>
<h:form id="someForm">
<ui:repeat id="someUIRepeat" value=".." ..>
<p:dataTable id="someDataTable" value=.. >
<p:column>
<p:inputTextarea id="someInputTextarea" value=../>
<p:column>
.. here go other columns
<ui:repeat>
</h:form>
The issue is that when I click on the commandLink in the dialog the inputTextarea is not updated. However, if I write this in the update of the commandLink:
update=":someForm:someUIRepeat:someDataTable,:someForm:someUIRepeat:someDataTable:someInputTextArea"
then the whole dataTable gets updated and the inputTextarea updates as well, but the values in the fields located in other columns get erased after I click on the commandLink in the dialog.
The reason why I put dataTable inside of ui:repeat is that I need to bind a dataTable with each row of one collection and I think it's not related to my problem.
Any ideas how I can solve this problem?
Thanks in advance,
Nurzhan.
for start try this
added onclick="jQuery('#someForm:someButton').click();"(check the exact id of your hidden button) to your <p:commandLink inside the dialog
set the update to update=":someForm:someUIRepeat:someDataTable"
and add
<h:commandButton id="someButton" style="display:none">
<f:ajax execute="#form"></f:ajax>
</h:commandButton>
to <h:form id="someForm">
explanation: the purpose of the hidden button is to execute (send its values) the form to the server so that when you do call update the fields wont be erased...

Resources