2013-09-23 12:01:03 8 Comments
I have a p:dialog and there is a panel inside it. The problem is "Save" button's action method is not working. It doesn't even calls the method. I can reach the method def. with ctrl+lm so there is no problem with method name.
<h:body>
<h:form id="createAppUserForm" prependId="false">
....
<p:dialog id="newRoleDialogId"
header="Add New Role"
resizable="true"
draggable="true"
widgetVar="newRoleDetailsDialog"
appendToBody="true"
>
<p:panel id="newRoleDialogPanel">
<p:panelGrid id="newRoleDialogPanelGrid" columns="2" style="width: 100%" styleClass="panelGridWithoutBorder">
<h:outputText value="Role Name :"/>
<p:inputText value="#{createAppUserController.selectedRole.name}"/>
<h:outputText value="Role Desc :"/>
<p:inputText value="#{createAppUserController.selectedRole.description}"/>
</p:panelGrid>
<center>
<p:commandButton value="Save"
update="roleListDataTable newRoleDialogPanelGrid growlCreateAppUser"
oncomplete="if (!args.validationFailed) newRoleDetailsDialog.hide()"
action="#{createAppUserController.saveNewRole()}"/>
<p:commandButton value="Cancel"
immediate="true"
onclick="newRoleDetailsDialog.hide()" />
</center>
</p:panel>
</p:dialog>
</h:form>
</h:body>
Related Questions
Sponsored Content
12 Answered Questions
[SOLVED] commandButton/commandLink/ajax action/listener method not invoked or input value not set/updated
- 2010-01-22 16:18:46
- Muhammad Hewedy
- 199221 View
- 332 Score
- 12 Answer
- Tags: jsf jsf-2 action commandbutton commandlink
1 Answered Questions
[SOLVED] p:dialog inside p:dialog - p:commandButton and p:ajax not working
- 2019-02-05 12:29:29
- RJ_P
- 43 View
- -1 Score
- 1 Answer
- Tags: primefaces
2 Answered Questions
[SOLVED] p:commandButton action not working in p:confirmDialog
- 2014-07-25 13:48:50
- sTg
- 21094 View
- 4 Score
- 2 Answer
- Tags: jsf jsf-2 primefaces dialog
1 Answered Questions
[SOLVED] p:selectOneMenu in p:panel no load correct after save
- 2017-12-26 18:33:25
- vctlzac
- 376 View
- 0 Score
- 1 Answer
- Tags: jsf primefaces jsf-2
1 Answered Questions
[SOLVED] p:fileUpload doesn't work inside p:dialog
- 2017-09-13 00:19:41
- Alfonso
- 869 View
- 3 Score
- 1 Answer
- Tags: jsf file-upload primefaces dialog
2 Answered Questions
[SOLVED] Button in dialog inside p:dialog is not calling controller method
- 2015-03-14 19:52:20
- X. Stuff
- 4272 View
- 1 Score
- 2 Answer
- Tags: jsf jsf-2 primefaces controller dialog
0 Answered Questions
Refresh p:dialog contents on click of p:commandButton
- 2015-05-14 13:06:05
- 99maas
- 251 View
- 0 Score
- 0 Answer
- Tags: jsf primefaces dialog
2 Answered Questions
[SOLVED] p:commandButton inside p:dialog does not work
- 2015-01-08 11:51:45
- Eduardo Santos
- 213 View
- 0 Score
- 2 Answer
- Tags: jsf primefaces
0 Answered Questions
p:commandButton doesn't execute action function
- 2014-05-08 15:49:06
- Rodrigo Martinez
- 347 View
- 0 Score
- 0 Answer
- Tags: jsf primefaces javabeans commandbutton
1 Answered Questions
p:commandButton not working inside p:dialog
- 2013-07-01 16:37:21
- Sundeep Malik
- 1204 View
- 0 Score
- 1 Answer
- Tags: java jsf-2 primefaces tomcat7
4 comments
@Reza Abazari 2019-12-05 06:39:33
Adding (process="@this") to commandButton worked for me.
@Kukeltje 2019-12-05 06:52:19
That would have been the generic #9 in stackoverflow.com/questions/2118656/… and not related to a dialog at all (it might have been in a dialog but that would still have been a problem if you would have removed the surrounding dialog in the process of creating a minimal reproducible example
@BalusC 2013-09-23 12:09:43
The dialog, when used with an
appendToBody/appendTo="@Body"
must have its own form.Because, when the dialog is generated into HTML output, it's by JavaScript relocated to the end of HTML
<body>
which causes it to not be sitting in any form anymore. The generated HTML DOM tree ends up to look like this (use webbrowser's dev tools to see it):The
appendToBody="true"
plays a role in here. The end of body ensures easy and best cross browser compatibility of displaying a modal dialog by JavaScript.The same is true by the way for a
p:overlayPanel
with anappendTo...
But also make sure there is, before 'moving' the
p:dialog
, there is not a nestedh:form
. So preventSince although it ends up like
it is initially invalid html
See also:
@hellzone 2013-09-23 12:29:55
I removed outside form and added forms inside dialog boxes but now it gives says "UI Layout Initialization Error.The center-pane element does not exist.The center-pane is a required element". I removed <center> element but it still gives same error. Any idea?
@BalusC 2013-09-23 13:03:47
That's a different problem completely unrelated to the question being asked. Just press "Ask Question" on right top to ask a question about that. Hint: it isn't talking about
<center>
(which is by the way deprecated since HTML 4.01 in 1998, you should never use<center>
nowadays).@amphibient 2015-07-10 22:19:31
the saga continues: stackoverflow.com/questions/31350850/…
@Tim 2016-08-26 10:24:04
@BalusC is this still a problem with Primefaces 6 ? I have dialogs that don't have their own forms, but everything works as expected. I will update my code then
@AshutoshDeora 2015-07-14 06:56:02
The appendToBody="true" plays a role in here. This attribute have been removed from in latest version. Please look for other alternative
@Kukeltje 2019-12-05 08:19:20
Answer was enhanced
@DarwinFernandez 2014-01-14 15:34:31
try this p:remoteCommand
http://www.primefaces.org/showcase/ui/ajax/remoteCommand.xhtml
this is my example
@BalusC 2015-06-01 17:28:04
@don-kaotic: It's not a solution. It's a workaround. The underlying problem still exists.
@hamza-don 2015-06-01 17:30:59
@BalusC you're right, but there is no obligation to not use a workaround if there is no issues with that.