7

I am using primefaces with JSF2.3

here is the way my dependencies are

    dependencies {

    providedCompile 'javax.servlet:javax.servlet-api:4.0.0'
    compile group: 'javax.faces', name: 'javax.faces-api', version: '2.3'
    compile group: 'org.glassfish', name: 'javax.faces', version: '2.3.3'
    compile 'javax.servlet:jstl:1.2'
    compile 'org.jboss.weld.servlet:weld-servlet:2.4.5.Final'
    compile group: 'org.primefaces', name: 'primefaces', version: '6.2'
}

my jsf file is very basic

   <html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
</h:head>
<f:view>
    <h:outputLabel value="Hello, world"/>
    <h:form>
        <p:selectOneMenu value="#{testView.chosen}"
                         style="width:200px">
            <f:selectItem itemLabel="Select listing template"/>
            <f:selectItems value="#{testView.list}"/>
            <p:ajax event="change" process="@this" update="@all"/>
        </p:selectOneMenu>
    </h:form>
</f:view>
</html>

and my viewScoped bean also

    @Named
@ViewScoped
public class TestView implements Serializable {
String chosen;
List<String> list;

@PostConstruct
public void setup(){
    list = new ArrayList<>();
    list.add("alpha");
    list.add("gamma");
    list.add("bravo");
}

getter and setter are ommited for simplicity.

the thing is that I used to work with (jsf 2.2, primefaces 6.1) and everything is working fine.

after the upgrade (jsf 2.3, primefaces6.2), I have a problem whenever the event change (when i change selection is triggered)

the error is

Uncaught TypeError: Cannot read property 'error' of null
    at Object.<anonymous> (core.js.xhtml?ln=primefaces&v=6.2:3)
    at i (jquery.js.xhtml?ln=primefaces&v=6.2:2)
    at Object.fireWith [as resolveWith] (jquery.js.xhtml?ln=primefaces&v=6.2:2)
    at A (jquery.js.xhtml?ln=primefaces&v=6.2:4)
    at XMLHttpRequest.<anonymous> (jquery.js.xhtml?ln=primefaces&v=6.2:4)

Is there any conflict javascript between jsf2.3 and primefaces ?

2
  • So you actually used PrimeFaces 6.2 with JSF 2.2 and did not get this error? Sure you did not upgrade PrimeFaces? And by accident have 2 PrimeFaces versions in your deployed project? Commented Mar 2, 2018 at 14:53
  • And update="@all" should rarely be used... Does it work if you do not use that? Assuming your example is an minimal reproducible example it should work if you remove that Commented Mar 2, 2018 at 14:57

4 Answers 4

7

AFAICS this is a bug in Mojarra, i would create a issue there. Seems like the component resources are available (see PrimeFaces HeadRenderer) in the postback but somehow they are not rendered in the response inside the head tag.

NOTE: this will only happen with update=@all as otherwise the head-tag won't be replaced. Actually update=@all shoudln't be used, only if really really really necessary.

Sign up to request clarification or add additional context in comments.

1 Comment

Actually update=@all shoudln't be used, only if really really really necessary hear, hear...
2

There's a problem with mojarra, because it should send all the files when you want to render "all".

Meanwhile, there is an alternative solution mentioned here: https://github.com/javaserverfaces/mojarra/issues/4354

You can execute the following script after primeface has loaded, so it can change the way PF renders the HEAD:

https://github.com/javaserverfaces/mojarra/files/2626517/primefaces_replacehead_hack.js.txt

With it, PF wont replace the head and the code will probably continue to work.

It worked for me.

1 Comment

Unfortunately both links are broken now :( However, there is github.com/eclipse-ee4j/mojarra/issues/4354 and github.com/eclipse-ee4j/mojarra/issues/4553 with at least some information.
0

Regarding your factual question (which is imo wrongly formulated),

Is there any conflict javascript between jsf2.3 and primefaces ?

The answer is:

No there is not. Since the PrimeFaces showcase is "Running PrimeFaces-6.2 on Mojarra-2.3.2" according to the bottom of the actual operational showcase: https://www.primefaces.org/showcase/

But your edit to me suggests (like I posted in my comments) you have multiple PF versions in your actual running project.

Comments

0

I can create this issue on PrimeFaces 6.2 and 6.3-SNAPSHOT ShowCase with simplified markup. The primefaces core javascript files are missing in the delivered content. After update body the global primefaces variable is undefined / null. Using @form instead of @all is still working.

(minified) index.xhtml

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui" template="/WEB-INF/template.xhtml">

<ui:define name="body">
    <h:form>
        <p:commandButton value="BUTTON_TEXT" update="@all"
            process="@none" />
    </h:form>
</ui:define>

(minified) template.xhtml

<!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:p="http://primefaces.org/ui">
    <h:head />
    <h:body>
        <ui:insert name="body"></ui:insert>
    </h:body>
    </html>

Stacktrace:

VM47:1 Uncaught TypeError: Cannot read property 'cw' of null
    at <anonymous>:1:12
    at p (jquery.js.xhtml?ln=primefaces&v=6.2:2)
    at Ja (jquery.js.xhtml?ln=primefaces&v=6.2:3)
    at r.fn.init.append (jquery.js.xhtml?ln=primefaces&v=6.2:3)
    at r.fn.init.<anonymous> (jquery.js.xhtml?ln=primefaces&v=6.2:3)
    at T (jquery.js.xhtml?ln=primefaces&v=6.2:3)
    at r.fn.init.html (jquery.js.xhtml?ln=primefaces&v=6.2:3)
    at Object.updateBody (core.js.xhtml?ln=primefaces&v=6.2:3)
    at Object.updateElement (core.js.xhtml?ln=primefaces&v=6.2:3)
    at Object.doUpdate (core.js.xhtml?ln=primefaces&v=6.2:3)

Open: https://github.com/javaserverfaces/mojarra/issues/4354

1 Comment

Is this an answer or a new question?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.