primefaces codeMirror doesn't load his own css

2019-08-13 07:14发布

问题:

I want to use codeMirror from primeface-extension with an sql syntax.

I've got a 404 error when the page who contains this component load. The Css and javascript component not found.

My code is the same as the example from showcase-ext codeMirror.

Using primefaces 5.1 and primefaces-ext 2.1.0.

Does anyone have this problem?

Thank you in advance.

edit:

my jsf:

    <pe:codeMirror id="codeMirror"
    value="#{sandboxBean.content}" lineNumbers="true"/>  

    <p:commandButton actionListener="#{sandboxBean.changeMode}" update="codeMirror"  
             value="Change mode with AJAX" style="margin-top:10px;"/>

my bean:

private String content;  
private String mode = "javascript";  

public void changeMode() {  
    if (mode.equals("css")) {  
        mode = "javascript";  
    } else {  
        mode = "css";  
    }  
}  

public List<String> complete(final CompleteEvent event) {  
    final ArrayList<String> suggestions = new ArrayList<String>();  

    suggestions.add("context: " + event.getContext());  
    suggestions.add("token: " + event.getToken());  

    return suggestions;  
}  

public String getContent() {  
    return content;  
}  

public void setContent(final String content) {  
    this.content = content;  
}  

public String getMode() {  
    return mode;  
}  

public void setMode(final String mode) {  
    this.mode = mode;  
}

The error on my browser console: 404 (Introuvable) for css and js of primefaces component.

The other primefaces component load correctly so i doesn't understand why this one not work.

What's wrong in my code ?

回答1:

I have got the same error and managed to make it work adding resources-codemirror dependency to my pom.xml

    <dependency> 
        <groupId>org.primefaces.extensions</groupId> 
        <artifactId>primefaces-extensions</artifactId> 
        <version>3.2.0</version> 
    </dependency>       
    <dependency>
        <groupId>org.primefaces.extensions</groupId>
        <artifactId>resources-codemirror</artifactId>
        <version>1.2.1</version>
    </dependency>