尽管存在依赖关系,PrimeFaces组件不会在浏览器中呈现 [英] PrimeFaces components are not rendered in browser in spite of dependency being present

查看:124
本文介绍了尽管存在依赖关系,PrimeFaces组件不会在浏览器中呈现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Eclipse 4.3上使用PrimeFaces 3.5开发一个JSF Web应用程序。没有compiletime或运行时错误,应用程序成功部署。但是,我无法在浏览器中获得所需的输出。 PrimeFaces组件不会出现,而标准的JSF组件。



我不知道我是否配置了一切正确。 PrimeFaces JAR至少在 / WEB-INF / lib 内:





PrimeFaces XML命名空间被声明为 xmlns:p =http:\\primefaces.org\ui





我映射了 FacesServlet *。xhtml





以下是 login.xhtml的完整源代码

 <!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:h =http://java.sun.com/jsf/html
xmlns:f =http://java.sun.com/jsf/core
xmlns:p =http://primefaces.org/ui>
< h:body>
< h:head>< title>登录页面< / title>< / h:head>
< h:form>
< p:panel id =panelheader =登录面板style =margin-bottom:10px;>

< h:panelGrid columns =3>
< h:outputLabel value =User Id:/>
< p:inputText id =idvalue =loginBean.idrequired =truerequiredMessage =需要ID/>
< p:message for =id/>

< p:outputLabel value =用户名:/>
< p:inputText id =namevalue =loginBean.namerequired =truerequiredMessage =需要名称/>
< p:message for =name/>
< / h:panelGrid>
< / p:panel>
< p:commandButton type =Submitvalue =Submitaction =#style =margin-right:20px; />




` / p>

输出如下所示:





如你所见,< h:outputText> 做了它的工作,但没有一个< p:xxx> 出现。原因如何,如何解决?

解决方案

关于您的具体问题的原因,PrimeFaces组件未被呈现根据屏幕截图,您在PrimeFaces taglib URI中有一个前导空格:

  xmlns:p =http:// $

这很重要,因此错了。摆脱它:

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

这样,PrimeFaces组件必须被解析并显示在HTML输出中。



对于其余的,我强烈建议您先阅读一个理智的JSF2教程。你制作了几个概念上的错误,这些错误已经被一个体面的Hello World示例所覆盖。从我们的JSF wiki页面开始。不过,这些错误不是有这个空白页。它们会导致不同的问题(例如,CSS / JS不起作用,表单提交不起作用)。如果你仍然坚持下去,你应该主要提出一个新的问题。


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 cannot get the desired output in browser. The PrimeFaces components do not show up, while the standard JSF components do.

I'm not sure if I configured everything right. The PrimeFaces JAR is at least inside /WEB-INF/lib:

And the PrimeFaces XML namespace is declared as xmlns:p="http:\\primefaces.org\ui"

And I mapped the FacesServlet on *.xhtml:

Here's the full source code of login.xhtml:

  <!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:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p=" http://primefaces.org/ui" >
        <h:body>  
<h:head ><title>Login Page !!</title></h:head>
 <h:form>  
<p:panel id="panel" header="Login Panel" style="margin-bottom:10px;">  

    <h:panelGrid columns="3">  
        <h:outputLabel  value="User Id:" />  
        <p:inputText id="id" value="loginBean.id" required="true" requiredMessage="ID required"/>  
        <p:message for="id" />

        <p:outputLabel value="User Name:" />  
        <p:inputText id="name" value="loginBean.name"  required="true" requiredMessage="Name required" />  
        <p:message for="name" />
    </h:panelGrid>  
</p:panel>  
<p:commandButton type="Submit" value="Submit" action="#" style="margin-right:20px;" />  

`

The output looks like this:

As you see, <h:outputText> did its job, but none of <p:xxx> show up. How is this caused and how can I solve it?

解决方案

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.

这篇关于尽管存在依赖关系,PrimeFaces组件不会在浏览器中呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆