question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PrimeFacesScriptProcessor: Uncaught Synatx Error, Primefaces.settings rendered in SPAN

See original GitHub issue

When using the PrimeFacesScriptProcessor according to the Showcase you can see in the WebDev-Console “Uncaught SyntaxError: Unexpected token ‘<’” and when inspecting the webpage you see that the “Primefaces.settings”-Part is inside of a SPAN-tag, which seems to be the cause of the error. In the Showcase itself it is not visible, but there can also not see any Primefaces.settings in the head.

When using BalusC approach, the tag gets rendered as expected but after a click or ajax request, Mojarra throws excpetion caused by duplicated id in component.

Primefaces Extension Code

private void addJS(FacesContext context, String script) { String id = UUID.randomUUID().toString(); final UIOutput js = new UIOutput(); js.setId(“js-” + id + “1”); js.setRendererType(“javax.faces.resource.Script”); final UIOutput content = new UIOutput(); content.setId(“js-” + id + “2”); content.setValue(script); js.getChildren().add(content); context.getViewRoot().addComponentResource(context, js); }

Rendered HTML: <script type="text/javascript"><span id="js-a07c21e3-04b7-4063-b3eb-b570c6b974ee2">if(window.PrimeFaces)...</span></script>

BalusC

private void addJS(FacesContext context, String script) { UIOutput js = new UIOutput(); js.setRendererType(“javax.faces.resource.Script”); UIOutput content = new UIOutput(); content.setValue(script); js.getChildren().add(content); context.getViewRoot().addComponentResource(context, js); }

Rendered HTML: <script type="text/javascript">if(window.PrimeFaces)...</script>

Environment:

  • PF Version: 10.0.0
  • JSF version: Mojarra 2.3
  • Affected browsers: reproduced in Chrome and Firefox

To Reproduce Steps to reproduce the behavior:

  1. Include the PrimeFacesScriptProcessor according to the showcase
  2. Open Browser

Expected behavior No Error (and JS not encapsulated by SPAN-tag?)

Sample XHTML Trivial xhtml-page

Sample Bean No Bean necessary

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mellowarecommented, Aug 9, 2021

10.0.3 is in Maven Central now…

1reaction
mellowarecommented, Jul 28, 2021

I have verified your fix and implemented it! Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Primefaces - Uncaught SyntaxError: Unexpected token ILLEGAL
I'm trying to implement something in JSF 2.0 and Primefaces 4.0 but I having some issues. A little time ago my <p:editor> was...
Read more >
(Solved) Primefaces tags not rendering - Prime Community ...
I tried to set up a JakartaEE 9.1 project in IntelliJ 2022.1 (Ultimate) using JSF 3.0.0 and primefaces 11.0.0. The application is running ......
Read more >
Calendar: An error appears in the JS console when an invalid ...
An error appears in the JS console when an invalid date is entered into a p:calendar textbox. This is a regression in PrimeFaces...
Read more >
[Solved] Uncaught syntaxerror: invalid or unexpected token
What I have tried: If we change the parameters order and use double quotes. Then the error is gone.
Read more >
Uncaught SyntaxError: Unexpected token - DataTables
I was doing the code below, howerever, it's not shown as expected and returns: Uncaught SyntaxError: Unexpected token {
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found