p:confirm is not working with p:menuItem in 5.2.0

Locked
vocegerente
Posts: 6
Joined: 30 Jun 2015, 03:05

10 Jul 2015, 04:39

Primefaces version 5.2.0 says that p:confirm may work with p:menuItem. I've tried make it work but with no success.

Here is the example code to demonstrate de problem. The button "Save" pop's up the dialog, but the buttons "Bt1" and "Bt2" doesn't.

It was supposed by documentation in page 121 to work with buttons "Save" and "Bt2":

Code: Select all

		<h:form id="formEdit">

			<p:growl id="messages" />
			
			<p:splitButton value="Bt1">
			
				<p:confirm header="Confirmation" message="Sure?"
					icon="ui-icon-alert" />
					
				<p:menuitem value="Bt2">
					<p:confirm header="Confirmation" message="Sure?"
					icon="ui-icon-alert" />
				</p:menuitem>
			
			</p:splitButton>
			
			<p:commandButton value="Save" actionListener="#{bean.save}"
				update="messages">
				<p:confirm header="Confirmation" message="Sure?"
					icon="ui-icon-alert" />
			</p:commandButton>
			
			<p:confirmDialog global="true">
				<p:commandButton value="Yes" type="button"
					styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
				<p:commandButton value="No" type="button"
					styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
			</p:confirmDialog>


		</h:form>
Does anyone has any idea to solve it?
Last edited by vocegerente on 10 Jul 2015, 16:00, edited 1 time in total.

mert.sincan
Posts: 5281
Joined: 29 Jun 2013, 12:38

10 Jul 2015, 08:58

It is not supported on p:splitButton. You can create a github issue for this feature. https://github.com/primefaces/primefaces/issues


mert.sincan
Posts: 5281
Joined: 29 Jun 2013, 12:38

10 Jul 2015, 15:34

Thank you for the update.

vocegerente
Posts: 6
Joined: 30 Jun 2015, 03:05

10 Jul 2015, 15:59

You're welcome.

Bellow is a workaround to make p:confirmDialog to work with splitButton and menuItem, using javascript api to show and hide the dialog component. The problem is that you have to write one confirmDialog per button, once you have to especialize messages and action behavior.

Code: Select all


		<h:form id="formEdit2">

			<p:growl id="messages" />

			<p:splitButton value="Bt1">

				<p:confirm header="Confirmation" message="Sure?"
					icon="ui-icon-alert" />

				<!-- Bt2 now uses javascript api -->
				<p:menuitem value="Bt2" onclick="PF('dialogBt2').show();"/>

			</p:splitButton>

			<p:commandButton value="Save" actionListener="#{bean.save}"
				update="messages">
				<p:confirm header="Confirmation" message="Sure?"
					icon="ui-icon-alert" />
			</p:commandButton>

			<p:confirmDialog global="true">
				<p:commandButton value="Yes" type="button"
					styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
				<p:commandButton value="No" type="button"
					styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
			</p:confirmDialog>
			
			<p:confirmDialog widgetVar="dialogBt2" message="Sure?">
			
				<!-- must config with action and/or actionListener from Bt2 -->
				<p:commandButton value="Yes" type="button" onclick="PF('dialogBt2').hide();"
					styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
					
				<p:commandButton value="No" type="button" onclick="PF('dialogBt2').hide();"
					styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
					
			</p:confirmDialog>			

		</h:form>


mert.sincan
Posts: 5281
Joined: 29 Jun 2013, 12:38

31 Jul 2015, 15:50

Issue is resolved for 5.2.9 and 5.3. (https://github.com/primefaces/primefaces/issues/507)

Locked

Return to “Spark”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 11 guests