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

Community Driven Extensions Project
Post Reply
arnieAustin
Posts: 120
Joined: 14 Feb 2015, 22:35
Location: Houston, TX

06 Mar 2018, 02:57

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.
--- --- ---
PF 12 | JSF 4 | CDI 4 | WildFly 27

arnieAustin
Posts: 120
Joined: 14 Feb 2015, 22:35
Location: Houston, TX

06 Mar 2018, 03:33

I've also tried:

Code: Select all

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

Code: Select all

onclick="return false;"
No change.
--- --- ---
PF 12 | JSF 4 | CDI 4 | WildFly 27

Melloware
Posts: 3716
Joined: 22 Apr 2013, 15:48

06 Mar 2018, 14:27

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>
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

Melloware
Posts: 3716
Joined: 22 Apr 2013, 15:48

06 Mar 2018, 14:48

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?
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

Melloware
Posts: 3716
Joined: 22 Apr 2013, 15:48

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.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

arnieAustin
Posts: 120
Joined: 14 Feb 2015, 22:35
Location: Houston, TX

31 Mar 2018, 19:28

The key was to add process="@this" to the menuItem.
--- --- ---
PF 12 | JSF 4 | CDI 4 | WildFly 27

Mechanic
Posts: 2
Joined: 25 Apr 2018, 10:38

26 Apr 2018, 20:31

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

Post Reply

Return to “Extensions”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 4 guests