PrimeFaces components are not rendered in browser in spite of dependency being present

前端 未结 4 2076
北海茫月
北海茫月 2021-01-14 16:45

I\'m developing a JSF web application with PrimeFaces 3.5 on Eclipse 4.3. There are no compiletime or runtime errors and the application deploys successfully. However, I can

相关标签:
4条回答
  • 2021-01-14 17:15

    if you build your proeject mit maven remember to include a dependency of primefaces lib into pom.xml

    best regards

    0 讨论(0)
  • 2021-01-14 17:18

    This is not directly answer on this question, but it's related to it. I want to share my experience with the problem "PrimeFaces tags not rendering". I am developing JSF 2.2 app on WildFly, and here is my index.xhtml:

    <html 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">
    
    <h:body>
        <h:form>
            <p:editor value="#{mDb.newMessage.content}"></p:editor>
        </h:form>
    </h:body>
    </html>
    

    When an app is running, the editor doesn't appear, and this was very strange to me, because PrimeFaces was configured correctly in project.

    I accidentally discovered cause of problem. There was not a h:head tag in index.xhtml. When I put head tag, PrimeFaces components rendered successfully!!

    I hope this could help someone.

    0 讨论(0)
  • 2021-01-14 17:22

    As to the cause of your concrete problem of PrimeFaces components not being rendered, as per the screenshot, you have a leading blank space in PrimeFaces taglib URI:

    xmlns:p=" http://primefaces.org/ui"
    

    This is significant and thus wrong. Get rid of it:

    xmlns:p="http://primefaces.org/ui"
    

    This way the PrimeFaces components must be parsed and appear in the HTML output.

    For the remainder I strongly recommend you to go through a sane JSF2 tutorial first. You're making several conceptual mistakes which are already covered by a decent Hello World example. Start at our JSF wiki page. Those mistakes do however not have this "blank page" as consequence. They will cause different problems (e.g. CSS/JS not functioning and form submit not working). If you still stucks on that, you should essentially be asking a new question.

    0 讨论(0)
  • 2021-01-14 17:37

    1.
    When ever you are referring to Managed Bean properties from JSF components, use correct syntax for JSF EL statements.

    #{bean_name.property}
    

    In your code you are forgetting to provide #{}.
    For example at line #15 in login.xhtml use :

    <h:inputText id="id" value="#{loginBean.id}" required="true" requiredMessage="ID required"/>
    

    2.
    You are keeping <h:head> inside <h:body>. Its not a good practice.
    Keep <h:head> out side <h:body>.
    Actual structure would be:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html 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">
    
         <h:head>
            <title></title>
         <h:head>   
    
         <h:body>
           <!-- Your Code -->
         </h:body>
    </html>
    

    3.
    You may be getting exception in ManagedBean LoginBean.java class.
    Please post the code instead of screenshots.

    0 讨论(0)
提交回复
热议问题