I am using primefaces 1.1 + JSF 1.2 running in JBoss 5.1
I have a problem with p:dialog
Below are the code snippets taken from the showcase(of PF 2.2, yet the p:dialog code remains the same. Right?? ) which can be seen # http://www.primefaces.org/showcase/ui/dialog.jsf
Code:
<h:panelGrid cellpadding="5">
<p:commandButton value="Basic Dialog" onclick="dlg1.show()" type="button"/>
<p:commandButton value="Modal" onclick="dlg2.show();" type="button"/>
<p:commandButton value="Effects" onclick="dlg3.show();" type="button"/>
</h:panelGrid>
<p:dialog header="Basic Dialog" widgetVar="dlg1">
<h:outputText value="Resistance to PrimeFaces is futile!" />
</p:dialog>
<p:dialog header="Modal Dialog" widgetVar="dlg2" modal="true" height="200">
<h:outputText value="This is a Modal Dialog." />
</p:dialog>
<p:dialog header="Effect Dialog" widgetVar="dlg3" showEffect="bounce" hideEffect="explode" height="200">
<h:outputText value="This dialog has cool effects." />
</p:dialog>
The thing is, the outputText values within the dialog boxes are displayed along with the commandbuttons like the ordinady html contents rather than displayed inside a dialog box only when the commandButtons are clicked. What might be the issue? :shock:
P.S : The above code runs fine in Primefaces 2.2 + Jsf 2.0 + JBoss 6
SCREENSHOT -
problem image url
Related
Primefaces Migration-Guide 5.3 to 6.0:
ContextMenu: p:contextMenu must be placed AFTER the target component (e.g. datatable) in the xhtml now.
I tried exactly that, but it' not working. No Menu at all.
Placing ContextMenu before dataTable: Menu is showing. Additional output on browser console:
ContextMenu targets a widget which is not available yet. Please place the contextMenu after the target component. targetWidgetVar: widget_base_cars
My Webshpere Liberty log:
...org.primefaces.webapp.PostConstructApplicationEventListener I Running on PrimeFaces 7.0
Java:
java.version = 1.8.0_102
Stripped down to primefaces showcase
<h:body>
<h1>Context Menu</h1>
<h2>ContextMenu: p:contextMenu must be placed AFTER the target component</h2>
<h:form id="base" >
<p:dataTable id="cars" var="car" value="#{dtContextMenuView.cars}" rowKey="#{car.id}" >
<f:facet name="header">
List with #{dtContextMenuView.numberOfCars} Items
</f:facet>
<p:column headerText="Id">
<h:outputText value="#{car.id}" />
</p:column>
<p:column headerText="Year">
<h:outputText value="#{car.year}" />
</p:column>
<p:column headerText="Brand">
<h:outputText value="#{car.brand}" />
</p:column>
<p:column headerText="Color">
<h:outputText value="#{car.color}" />
</p:column>
</p:dataTable>
<p:contextMenu for="cars" >
<p:menuitem value="Hello" />
<p:menuitem value="World" />
</p:contextMenu>
<h2>but it fails</h2>
</h:form>
</h:body>
I expect the menu to show on right click.
Is it a bug, or am i the bug?
I reproduced this testing around with PF 5.3/6.0/7.0. I'm with you as long as your p:dataTable is not selectable:
The p:contextMenu appears on rightclick when added above the p:dataTable element in xhtml. When added below, no context menu appears at all. But tbh.: is a context menu useful on a datatable which does not allow selection?
When making it selectable by adding the attributes
selection="#{myBean.selectedValue}" selectionMode="singel"
it behaves like this:
p:contextMenu below p:dataTable as suggested by migration guide: On rightclick, the clicked row is selected and context menu appears on it.
p:contextMenu above p:dataTable: on rightclick, context menu appears either, but the row is not selected.
So if p:contextMenu is added above the table, selection does not work as expected which must be the reason for the migration guide telling "add it below!".
Btw: I did not get that warning in my JavaScript console during my tests, don't know why.
I working with primefaces 6.2 on JavaEE 8 .
I have a basic dialog with a commandbutton created a modal over that .(Sory for bad english !)
I want to close modal without closing basic dialog .
How can fix this problem ?
<p:dialog header="Basic Dialog" id="user-management" widgetVar="user-management" width="700px" height="300px" resizable="false">
<p:toolbar>
<f:facet name="left">
<p:commandButton type="button" title="Add" icon="ui-icon-plus" onclick="PF('userDialog').show();"/>
</f:facet>
</p:toolbar>
<p:spacer/>
<p:dataTable value="#{userGroupBean.userSet}" var="user">
// Show user information
</p:dataTable>
</p:dialog>
<p:dialog header="User"
widgetVar="userDialog"
closeOnEscape="true"
resizable="true"
modal="true"
showEffect="fade"
hideEffect="fade"
height="auto"
width="auto">
<h:panelGrid columns="2">
// Some inputs ...
</h:panelGrid>
<p:spacer/>
<div class="dialog-footer">
<p:commandButton value="Save"
oncomplete="PF('userDialog').hide();"
process="#form"
update="user-management"
action="#{userGroupBean.save}"/>
</div>
</p:dialog>
The basic dialog is not 'closed' it is updated via update="user-management" and hence the html that is returned from the server is put in the html dom in with the dialog in the default state: closed. You have several options:
Don't update the dialog but update it's contents (my prefered solution) by adding e.g. a panel inside it and update that
Set a flag in a beanand use visible="#{mybean.dialogIsVisibleFlag}"
in the oncomplete of the ajax call do a PF('user-management').show()
I can't seem to make p:sticky work inside a p:dialog :
my dialog xhtml :
<p:dialog modal="true" height="490" width="700" resizable="false" >
<h:form id="form">
<p:toolbar id="tb">
<p:toolbarGroup align="right">
<p:commandButton value="save" />
</p:toolbarGroup>
</p:toolbar>
<p:sticky target="form:tb" />
</h:form>
</p:dialog>
It works fine from a simple page. any thoughts?
You are not doing anything wrong, it is just not supported. And due to a 'bad' issue report, it is closed as invalid http://code.google.com/p/primefaces/issues/detail?id=6341
Looking at the javascript source code of the sticky component, it checks scrolling of the window and not any other part inside it. So there is a big chance it will also fail in e.g. a p:layout.
Iam using primefaces 4.0 .I want to use dialog box . When i used it its printing the dialog content in the same page on load itself .Dialog box not opening
<h:panelGrid columns="1" cellpadding="5">
<p:commandButton id="basic" value="Basic" onclick="dlg.show()" type="button" />
</h:panelGrid>
<p:dialog id="basicDialog" header="Basic Dialog" widgetVar="dlg1">
<h:outputText value="Resistance to PrimeFaces is futile!" />
</p:dialog>
also tried
in facesconfig.xml
org.primefaces.application.DialogActionListener
org.primefaces.application.DialogNavigationHandler
org.primefaces.application.DialogViewHandler
Thanks in advance
I missed adding
h:head
Thanks all for your response
I want to show a dialog box on the click of a primefaces commandbutton. Before the dialog box , I need to check a condtional.
I am using Spring web-flow 2.3.0.
So I am doing it like this ,
And the Dialog Box is
I am not able to show this dialog box based on this condition.
Please help me ,any pointers?
SWF 2.3.0 Primefaces 2.2.1 JSF 2 Spring Security 3 Spring 3.1.0M1I EhCache Apache Tomcat 6.0 STS 2.5.1
So I have changed my code as per below
<p:commandLink id="addRequest" immediate="true" value="addreq"
oncomplete="dlg3.show()" update="dialogPanel">
<f:setPropertyActionListener
value="#{searchHandler.selectedAccIns}"
target="#{reqSearchHandler.checkAccStatus}" />
</p:commandLink>
And the dialog box is
<p:outputPanel id="dialogPanel"
rendered="#{not reqSearchHandler.accStatusFlag}">
<p:dialog header="Effect Dialog" widgetVar="dlg3"
showEffect="bounce" hideEffect="explode" height="200">
<h:outputText
value="Account is #{searchHandler.selectedAccIns.accStatusDesc}" />
<h:outputText value="Do you want to continue?" />
<div align="left">
<p:commandButton value="Yes" action="accept" />
<p:spacer width="960" height="5" />
<p:commandButton value="No" action="cancel" />
</div>
</p:dialog>
</p:outputPanel>
But when I am clicking on the command link , I am getting 3 dialog boxes. Can you please tell me why it is so?
Somebody else just posted the same problem! :)
You should use the oncomplete attribute instead of onclick of the commandButton. The click javascript event occurs before the page posts back, likely causing your dialog not to appear because of the page reloading.
oncomplete="dlg3.show()" will display the dialog AFTER the postback.