PrimeFaces主题未在标准JSF控件上正确应用

时间:2014-03-06 21:02:59

标签: jsf jsf-2 primefaces

我在使用primefaces时遇到了一个奇怪的问题。在某一点上,主题停止被正确应用于标准JSF控件,如commandButton等。不幸的是我无法追溯问题的原因

我的xhtml:

<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:head>  
</h:head>  

<h:body>  
    <p:spinner /> <!-- this one is skinned properly -->
     <p:outputPanel>
        Bla <p:commandButton /> <-- this one is not -->
     </p:outputPanel>
</h:body>  

我的web.xml

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
  <display-name>MyWebApp</display-name>
  <welcome-file-list>
    <welcome-file>index.jsf</welcome-file>
  </welcome-file-list> 
 <context-param>
    <param-name>primefaces.THEME</param-name>
    <param-value>bootstrap</param-value>
 </context-param>

 <context-param>
   <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
   <param-value>.xhtml</param-value>
 </context-param>
</web-app>

在生成的HTML源代码中,我注意到按钮类设置不正确:

查看源代码我真的不明白为什么添加了两个到样式表的链接。主题中的样式表不应该涵盖所有内容吗?

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <link type="text/css" rel="stylesheet" href="/MyWebApp/javax.faces.resource/theme.css.jsf?ln=primefaces-bootstrap" />
  <link type="text/css" rel="stylesheet" href="/MyWebApp/javax.faces.resource/primefaces.css.jsf?ln=primefaces&amp;v=4.0" />
  <script type="text/javascript" src="/MyWebApp/javax.faces.resource/jquery/jquery.js.jsf?ln=primefaces&amp;v=4.0"></script><script type="text/javascript" src="/MyWebApp/javax.faces.resource/jquery/jquery-plugins.js.jsf?ln=primefaces&amp;v=4.0">
  </script>
  <script type="text/javascript" src="/MyWebApp/javax.faces.resource/primefaces.js.jsf?ln=primefaces&amp;v=4.0">
  </script>
</head>
<body>
  <span id="j_idt6" class="ui-spinner ui-widget ui-corner-all">
  <input id="j_idt6_input" name="j_idt6_input" type="text" class="ui-spinner-input ui-inputfield ui-state-default ui-corner-all" autocomplete="off" />
  <a class="ui-spinner-button ui-spinner-up ui-corner-tr ui-button ui-widget ui-state-default ui-button-text-only">
    <span class="ui-button-text">
    <span class="ui-icon ui-icon-triangle-1-n">
    </span>
    </span>
  </a>
  <a class="ui-spinner-button ui-spinner-down ui-corner-br ui-button ui-widget ui-state-default ui-button-text-only">
    <span class="ui-button-text">
    <span class="ui-icon ui-icon-triangle-1-s">
    </span>
    </span>
  </a>
 </span>
 <script id="j_idt6_s" type="text/javascript">PrimeFaces.cw('Spinner','widget_j_idt6',{id:'j_idt6'});
 </script> <!-- this one is skinned properly -->
 <div id="j_idt7" class="ui-outputpanel ui-widget">
    Bla 
    <button id="j_idt9" name="j_idt9" class="" onclick="PrimeFaces.ab({source:'j_idt9'});return false;" type="submit">
      <span class="ui-button-text ui-c">ui-button</span>
    </button>
    <script id="j_idt9_s" type="text/javascript">PrimeFaces.cw('CommandButton','widget_j_idt9',{id:'j_idt9'});
    </script> <!-- this one is not -->
 </div>
</body>
</html>

这就是我在浏览器中看到的内容:

not what I want to see

运行时JBOSS AS 7.1.1

1 个答案:

答案 0 :(得分:2)

问题本身消失了:S