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

Community Driven Extensions Project
Post Reply
arnieAustin
Posts: 74
Joined: 14 Feb 2015, 22:35
Location: Austin, 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 6.1 | JSF 2.2.12 | CDI 1.2 | WildFly Full 11.0.0.Final

arnieAustin
Posts: 74
Joined: 14 Feb 2015, 22:35
Location: Austin, 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 6.1 | JSF 2.2.12 | CDI 1.2 | WildFly Full 11.0.0.Final

User avatar
Melloware
Posts: 720
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 Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 6.2 / PF Extensions 6.2.7

User avatar
Melloware
Posts: 720
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 Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 6.2 / PF Extensions 6.2.7

User avatar
Melloware
Posts: 720
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 Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 6.2 / PF Extensions 6.2.7

arnieAustin
Posts: 74
Joined: 14 Feb 2015, 22:35
Location: Austin, TX

31 Mar 2018, 19:28

The key was to add process="@this" to the menuItem.
--- --- ---
PF 6.1 | JSF 2.2.12 | CDI 1.2 | WildFly Full 11.0.0.Final

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 1 guest