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

UI Components for JSF
arnieAustin
Posts: 120
Joined: 14 Feb 2015, 22:35
Location: Houston, TX

23 Feb 2018, 00:34

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

tandraschko
PrimeFaces Core Developer
Posts: 3979
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

23 Feb 2018, 11:16

Use the PrimeFaces Extensions subforum.
Thomas Andraschko

PrimeFaces | PrimeFaces Extensions

Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE

Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko

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

23 Feb 2018, 14:19

Yes please re-post in the Extensions forum and I will try to help: viewforum.php?f=14
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: 3717
Joined: 22 Apr 2013, 15:48

23 Feb 2018, 17:27

Found the solution for you... use url="javascript:void(0)"

Code: Select all

<p:menuitem id="mnuCopy" value="Copy" url="javascript:void(0)" icon="fa fa-copy" />
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

06 Mar 2018, 02:54

That effected no change. Neither did url="#".
--- --- ---
PF 12 | JSF 4 | CDI 4 | WildFly 27

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

06 Mar 2018, 14:44

Add process="@this" or immediate="true" to prevent the form values from sticking.

Code: Select all

<p:menuitem id="mnuCopy" value="Copy" url="javascript:void(0)" icon="fa fa-copy" process="@this" immediate="true" />
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

06 Mar 2018, 15:41

This is bizarre! That had no effect either! The entire page is re-rendered. What am I missing here?

Code: Select all

	<h:form id="applicantMenuForm" styleClass="applicantMenuBar" >
		<p:growl id="applicantMenuFormGrowler" showDetail="true" sticky="false" for="applicantMenuFormGrowling" />  

		<div>
			<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" onclick="return false;" process="@this"
						value="&nbsp;DL/ID/UNL: #{sessionScope.SELECTED_APPLICANT.selectedApplicantDlIDUnlNumber}" />
					
					<p:menuitem id="appDob" icon="fa fa-copy" onclick="return false;" process="@this"  
						value="&nbsp;DOB: #{sessionScope.SELECTED_APPLICANT.selectedApplicantDobMdy}" />
					

--- --- ---
PF 12 | JSF 4 | CDI 4 | WildFly 27

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

06 Mar 2018, 15:49

I don't see url="javascript:void(0)" in your example above?
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

06 Mar 2018, 15:54

UGH! I just tried:

Code: Select all

	<p:menuitem id="appDlIdUnl" icon="fa fa-copy" 
		process="@this" actionListener="#{clipboardController.noOp}"
		value="&nbsp;DL/ID/UNL: #{sessionScope.SELECTED_APPLICANT.selectedApplicantDlIDUnlNumber}" />
and not only is the page redrawn (calling refreshData), but it happens TWICE!
--- --- ---
PF 12 | JSF 4 | CDI 4 | WildFly 27

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

06 Mar 2018, 16:04

OK you have something funky going on that I can't explain. it should NOT be called twice and it should NOT be refreshing the whole page as a navigation.

Can you make me a small reproducible sample by reproducting it with this simple test project. You can run "mvn clean jetty:run" to run this at localhost:8080.

Clone this repository https://github.com/primefaces/primefaces-test.git in order to reproduce your problem.
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

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 34 guests