commandButton action is not working inside confirmDialog

UI Components for JSF
Post Reply
satish.mutyam
Posts: 14
Joined: 03 Nov 2011, 17:38

09 Nov 2011, 07:53

Hi,
I am using primefaces 3.0 M4 components. When i try to invoke the commandButton action, it is not performing any action. Below is my sample code.

<p:confirmDialog message="Are you sure you want delete an item"

header="Delete" severity="alert" widgetVar="confirmation" appendToBody="true">

<p:commandButton value="Yes" update="messages" oncomplete="confirmation.hide()"
action="delete" ajax="false" />
<p:commandButton value="No" onclick="confirmation.hide()" type="button" />

</p:confirmDialog>
When click on 'No', it is able to close the confirm wizard, for 'Yes' it should invoke respectyive action, but in my case it was not triggering any action.
Please suggest what could be the problem and its alternate solution.
PrimeFaces version 3.3.1, Mojarra version 2.0.9 and the Tomcat 7.0.23/Weblogic 11g

spauny
Posts: 75
Joined: 10 Oct 2011, 16:42

09 Nov 2011, 08:12

What exactly are you expecting to happen? Do you want to call delete.jsf(xhtml)? For that to happen, you have to configure correctly the web.xml...
For testing that button you could call a bean's method, and see if it does.

satish.mutyam
Posts: 14
Joined: 03 Nov 2011, 17:38

09 Nov 2011, 08:46

No.. even i tried to call the bean method from action attribute of commandButton it didn't work.

my intension is to call the action event flow configured in respective spring webflow xml.

For testing purpose, i used the commandLink instead commandButton it worked fine and solved my problem.

But my question is how it make it work the commandButton?
PrimeFaces version 3.3.1, Mojarra version 2.0.9 and the Tomcat 7.0.23/Weblogic 11g

spauny
Posts: 75
Joined: 10 Oct 2011, 16:42

09 Nov 2011, 08:56

I've just noticed that your button has ajax set to false and I've remembered that inside a confirmDialog, a commandButton that has ajax set to false (does a forward/redirect) doesn't work...
I've had a fileDownload commandButton and that doesn't worked, so, firstly you should create an issue and secondly you should use a commandButton inside a confirmDialog only if has ajax set to true (because that works), if not, you should let it go and implement another functionality.

satish.mutyam
Posts: 14
Joined: 03 Nov 2011, 17:38

09 Nov 2011, 09:19

Thanks. I will check for alternate solutions.
PrimeFaces version 3.3.1, Mojarra version 2.0.9 and the Tomcat 7.0.23/Weblogic 11g

Joseph
Posts: 1
Joined: 31 Aug 2012, 17:17

31 Aug 2012, 17:25

Hi, Did anybody resolve this issue? I am using primefaces 3.4.RC1. I am unable to get the "Yes" button on the commandDialogue to call my method "deleteTestMethod" in managedBean.

Code: Select all

<h:form prependId="false">
		<p:dataTable var="profile"
			value="#{userProfileListBean.profileDTOList}" id="userProfilesTable"
			styleClass="entityTable">
			<p:column headerText="Profile Name" id="name">
            #{profile.name}
        </p:column>
			<p:column headerText="Options">
				<p:commandLink title="Edit" style="margin-right:20px;"
					actionListener="#{userProfileBean.viewProfile(profile,dashboardBean)}"
					update=":include" ajax="true" target=":include">
					<p:graphicImage value="/resources/images/edit.png" />
				</p:commandLink>

				<p:commandButton id="showDialogButton" value="Destroy the World"
					onclick="confirmation.show(); return false;" type="button" />
			</p:column>

		</p:dataTable>
	</h:form>
	<p:confirmDialog id="confirmDialog"
		message="Are you sure about destroying the world?"
		header="Initiating destroy process" severity="alert"
		widgetVar="confirmation" appendToBody="true">
		<h:form>
			<p:commandButton id="confirm2" value="Yes Sure"
				oncomplete="confirmation.hide()"
				actionListener="#{userProfileBean.deleteTestMethod}" ajax="true"  />
			<p:commandButton id="decline" value="Not Yet"
				onclick="confirmation.hide()" type="button" />
		</h:form>
	</p:confirmDialog>

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Google [Bot] and 36 guests