pe:clipboard breaks rendering if content is XML text

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

31 Mar 2018, 19:40

I have pe:clipboard working elsewhere in an application. I was adding it to a p:dialog which is used to display a web service message which is XML text.

The text is displayed in a p:inputTextarea. Rather than having to make the user click into the field, press CTRL+A and then CTRL+C, I put a p:commandButton on the dialog to provide the copy to the clipboard functionality instead.

However, when the page where the dialog is used is rendered, a bizarre error is produced:

Code: Select all

SEVERE: Servlet.service() for servlet [FacesServlet] in context with path [/DLSWeb] threw exception [Cannot find component for expression "<?xml" referenced from "modalXmlMessagePopupForm:copyXmlData".] with root cause
org.primefaces.expression.ComponentNotFoundException: Cannot find component for expression "<?xml" referenced from "modalXmlMessagePopupForm:copyXmlData".
	at org.primefaces.expression.SearchExpressionFacade.cannotFindComponent(SearchExpressionFacade.java:702)
	at org.primefaces.expression.SearchExpressionFacade.resolveClientIds(SearchExpressionFacade.java:249)
	at org.primefaces.expression.SearchExpressionFacade.resolveClientIds(SearchExpressionFacade.java:143)
	at org.primefaces.extensions.component.clipboard.ClipboardRenderer.encodeScript(ClipboardRenderer.java:53)
	at org.primefaces.extensions.component.clipboard.ClipboardRenderer.encodeEnd(ClipboardRenderer.java:44)
	at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:920)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
	at javax.faces.render.Renderer.encodeChildren(Renderer.java:176)
	at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:890)
	at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:85)
	at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:72)
	at org.primefaces.component.dialog.DialogRenderer.encodeContent(DialogRenderer.java:187)
	at org.primefaces.component.dialog.DialogRenderer.encodeMarkup(DialogRenderer.java:116)
	at org.primefaces.component.dialog.DialogRenderer.encodeEnd(DialogRenderer.java:48)
	at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:920)
	at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:89)
	at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:72)
	at org.primefaces.component.outputpanel.OutputPanelRenderer.encodeMarkup(OutputPanelRenderer.java:65)
	at org.primefaces.component.outputpanel.OutputPanelRenderer.encodeEnd(OutputPanelRenderer.java:41)
	at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:920)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
The markup is:

Code: Select all

<pe:clipboard id="copyXmlData" trigger="cmdCopyXmlContent" action="copy"
	target="#{xmlViewPopupController.xmlDisplay}">
	<p:ajax event="success"
		listener="#{xmlClipboardController.successListener}" 
		update="webServiceMessageListForm:webServiceMessageListFormGrowler" />
	<p:ajax event="error"
		listener="#{xmlClipboardController.errorListener}" 
		update="webServiceMessageListForm:webServiceMessageListFormGrowler" />
</pe:clipboard>

<p:commandButton id="cmdCopyXmlContent" icon="fa fa-copy" process="@this" 
	value="XML to Clipboard" action="copy" />
The xmlViewPopupController.xmlDisplay item is just a String field on the controller, containing the XML string was is read from the database where the messages are logged.

Using PF 6.1 and PFE 6.1.1.

Any ideas?
--- --- ---
PF 12 | JSF 4 | CDI 4 | WildFly 27

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

31 Mar 2018, 21:09

Let me try and reproduce and get back to you. This may have been something that was fixed between 6.1.1 and 6.2.3 versions of PFE but not sure.

I will let you know what I find out.
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

31 Mar 2018, 21:10

As a note have you tried putting the pe:clipboard AFTER the p:commandButton in the XHTML?
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, 21:36

I had not actually. However:

Code: Select all

[Fatal Error] :1:1: Content is not allowed in prolog.
Mar 31, 2018 2:35:13 PM com.sun.faces.application.view.FaceletViewHandlingStrategy handleRenderException
SEVERE: Error Rendering View[/jsf/pages/itd/console/webservicemessage/webServiceMessageList.xhtml]
org.primefaces.expression.ComponentNotFoundException: Cannot find component for expression "<?xml" referenced from "modalXmlMessagePopupForm:copyXmlData".
	at org.primefaces.expression.SearchExpressionFacade.cannotFindComponent(SearchExpressionFacade.java:702)
	at org.primefaces.expression.SearchExpressionFacade.resolveClientIds(SearchExpressionFacade.java:249)
	at org.primefaces.expression.SearchExpressionFacade.resolveClientIds(SearchExpressionFacade.java:143)
	at org.primefaces.extensions.component.clipboard.ClipboardRenderer.encodeScript(ClipboardRenderer.java:53)
	at org.primefaces.extensions.component.clipboard.ClipboardRenderer.encodeEnd(ClipboardRenderer.java:44)
	at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:920)
The only change was that the page rendered. When I invoked the command to read the XML and bring up the dialog, the above exception occurred.
--- --- ---
PF 12 | JSF 4 | CDI 4 | WildFly 27

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

31 Mar 2018, 22:43

Ok so the target you are copying is XML. I should be able to reproduce it. Feels like a bug in my code or possibly the clipboard code.
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, 23:15

Yep. Looks like the presence of the XML within an XHTML stream is not being protected or encoded correctly.

Interestingly enough, the page works fine when pe:clipboard isn't on the page.
--- --- ---
PF 12 | JSF 4 | CDI 4 | WildFly 27

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

01 Apr 2018, 16:44

Its most likely when I am writing the content to the Clipboard widget i just need to escape it to prevent this issue.
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

02 Apr 2018, 14:12

OK I have tried everything to reproduce this and I cannot.

XML Content:

Code: Select all

private String copyInput = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><note>Test Copy!</note>";

Code: Select all

<p:inputTextarea id="txtCopy" value="#{clipboardController.copyInput}" />
		<p:commandButton id="btnCopy" value="Copy" icon="fa fa-copy" />
		<pe:clipboard id="clipCopy" trigger="btnCopy" action="copy" target="txtCopy">
			<p:ajax event="success" listener="#{clipboardController.successListener}" />
			<p:ajax event="error" listener="#{clipboardController.errorListener}" />
</pe:clipboard>
It copies fine. Is there anyway you could try PrimeFaces 6.2 with PrimeFaces Extensions 6.2.3? I wonder if this issue has already been fixed.
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 “Extensions”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 3 guests