Page 1 of 1

pe:clipboard p:menuitem submits form and reloads entire page?

Posted: 06 Mar 2018, 02:57
by arnieAustin
I have the following menu set up to use the pe:clipboard on a few menu items.

It works as expected, with one exception:

The menu itself is in its own h:form. There is no desired navigation, action or actionListener to be invoked, just the copy to the clipboard.

Yet the entire page is re-rendered, resulting in the same DB IO that was invoked when the page is first accessed.

I do not understand why or how to prevent this. Is there a way? I have tried url="#", actionListener pointed at a noOp method; nothing works.

In this case, using PF 6.1, PFE 6.1.1.

Code: Select all


<pe:clipboard id="copyAppDlIdUnl" trigger="appDlIdUnl"
	action="copy"
	text="#{sessionScope.SELECTED_APPLICANT.selectedApplicantDlIDUnlNumber}">
	<p:ajax event="success" listener="#{clipboardController.successListener}"
		update="applicantMenuFormGrowler" />
	<p:ajax event="error" listener="#{clipboardController.errorListener}"
		update="applicantMenuFormGrowler" />
</pe:clipboard>

<pe:clipboard id="copyAppDob" trigger="appDob" action="copy"
	text="#{sessionScope.SELECTED_APPLICANT.selectedApplicantDobMdy}">
	<p:ajax event="success" listener="#{clipboardController.successListener}"
		update="applicantMenuFormGrowler" />
	<p:ajax event="error" listener="#{clipboardController.errorListener}"
		update="applicantMenuFormGrowler" />
</pe:clipboard>

<p:menubar id="applicantMenuBar" rendered="#{not empty sessionScope.SELECTED_APPLICANT}">

	<p:submenu
		label="Selected Applicant: #{sessionScope.SELECTED_APPLICANT.selectedApplicantLName}, #{sessionScope.SELECTED_APPLICANT.selectedApplicantFName}">

		<p:menuitem id="appDlIdUnl" icon="fa fa-copy"
			value="&nbsp;DL/ID/UNL: #{sessionScope.SELECTED_APPLICANT.selectedApplicantDlIDUnlNumber}" />

		<p:menuitem id="appDob" icon="fa fa-copy"
			value="&nbsp;DOB: #{sessionScope.SELECTED_APPLICANT.selectedApplicantDobMdy}" />

		<p:menuitem value="Go" icon="fa fa-arrow-circle-left" url="/viewBasicRecord.do" />

	</p:submenu>
Per suggestion, I have tried url="javascript:void(0)" as well ad url="#" to no effect. The page is reloaded.

Re: pe:clipboard p:menuitem submits form and reloads entire page?

Posted: 06 Mar 2018, 03:33
by arnieAustin
I've also tried:

Code: Select all

url="#" onclick="return false;"
as well as just

Code: Select all

onclick="return false;"
No change.

Re: pe:clipboard p:menuitem submits form and reloads entire page?

Posted: 06 Mar 2018, 14:27
by Melloware
try url="javascript:void(0)" like in this example...

Code: Select all

		<p:contextMenu>
			<p:menuitem id="mnuCopy" value="Copy" url="javascript:void(0)" icon="fa fa-copy" immediate="true" />
		</p:contextMenu>
		
		<pe:clipboard id="clipContextCopy" trigger="mnuCopy" action="copy" text="#{clipboardController.copyInput}">
                    <p:ajax event="success" listener="#{clipboardController.successListener}" />
                     <p:ajax event="error" listener="#{clipboardController.errorListener}" />
              </pe:clipboard>

Re: pe:clipboard p:menuitem submits form and reloads entire page?

Posted: 06 Mar 2018, 14:48
by Melloware
I am running my Showcase locally and I cannot reproduce your problem. Mine is doing a partial Ajax submit and not a full page submission.

Is there any way you can upgrade to PF 6.2 and PFE 6.2 and try it?

Re: pe:clipboard p:menuitem submits form and reloads entire page?

Posted: 20 Mar 2018, 14:08
by Melloware
Our example is online: https://www.primefaces.org/showcase-ext ... cUsage.jsf

Just right click the background and it brings up the menu item "Copy" which you can see and it does not do a full page submit.

Re: pe:clipboard p:menuitem submits form and reloads entire page?

Posted: 31 Mar 2018, 19:28
by arnieAustin
The key was to add process="@this" to the menuItem.

Re: pe:clipboard p:menuitem submits form and reloads entire page?

Posted: 26 Apr 2018, 20:31
by Mechanic
Melloware wrote:
20 Mar 2018, 14:08
Our example is online: https://www.primefaces.org/showcase-ext ... cUsage.jsf

Just right click the background and it brings up the menu item "Copy" which you can see and it does not do a full page submit.
Thank you very much for the example. And everything becomes clearer. without examples it is difficult.
thanks