【问题标题】:primefaces component (P:layout) not working at allprimefaces 组件(P:布局)根本不工作
【发布时间】:2013-06-21 15:08:23
【问题描述】:

我正在尝试使用 PrimeFaces 展示的示例 ElementLayout 但布局根本没有显示!

我已经看到了与我的问题相关的一种问题,例如(正确的命名空间、文档类型...),但对我没有任何作用。

在我的 pom 文件中,我声明了 jsf-api:2.0(provided) 和 primefaces:3.5

我的 layout.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:f="http://java.sun.com/jsf/core"
 xmlns:h="http://java.sun.com/jsf/html"
 xmlns:ui="http://java.sun.com/jsf/facelets"
 xmlns:p="http://primefaces.org/ui">

 <h:head>
    <title>Title</title>
  </h:head>
  <h:body>
          <p:layout fullPage="true">
        <p:layoutUnit position="north" size="100" header="Top" resizable="true" closable="true" collapsible="true">
            <h:outputText value="Top unit content." />
          </p:layoutUnit>

          <p:layoutUnit position="south" size="100" header="Bottom" resizable="true" closable="true" collapsible="true">
              <h:outputText value="South unit content." />
          </p:layoutUnit>

         <p:layoutUnit position="west" size="200" header="Left" resizable="true" closable="true" collapsible="true">
            <h:form>
                <!-- ..... -->
            </h:form>
         </p:layoutUnit>

        <p:layoutUnit position="east" size="200" header="Right" resizable="true"    closable="true" collapsible="true" effect="drop">
            <h:outputText value="Right unit content." />
        </p:layoutUnit>

        <p:layoutUnit position="center">
            <ui:insert name="content">Put default content here, if any.</ui:insert>
        </p:layoutUnit>
    </p:layout>
</h:body>        

我显示的 page.xhtml 如下所示:

  <ui:composition template="/templates/layout.xhtml"
   xmlns="http://www.w3.org/1999/xhtml"
   xmlns:f="http://java.sun.com/jsf/core"
   xmlns:h="http://java.sun.com/jsf/html"
   xmlns:ui="http://java.sun.com/jsf/facelets"
   xmlns:p="http://primefaces.org/ui">      
   <ui:define name="content">
     <h:form>
        <p:commandButton value="View" icon="ui-icon-extlink"
            actionListener="#{dialogBean.viewCars()}" />

        <p:commandButton value="Options" icon="ui-icon-extlink"
            actionListener="#{dialogBean.viewCarsCustomized()}" />
    </h:form>
  </ui:define>
    </ui:composition>

我在 primefaces 中尝试了各种布局,没有人适合我

enter link description here

感谢您的帮助

【问题讨论】:

  • 你想做什么?在第一页中显示第二页?

标签: jsf layout jsf-2 primefaces


【解决方案1】:

这是一个样式问题。 从Primefaces Aristo下载这个jar

并确保它在应用程序类路径中可用 并对 web.xml 文件进行更改不要为“primefaces.THEME”指定任何上下文参数。

希望对你有帮助

【讨论】:

    【解决方案2】:

    在 JSF 中呈现布局时遇到类似问题。解决方案在 web.xml 中。

    web.xml中的&lt;welcome-file-list&gt;应该如下

    <welcome-file-list>
        <welcome-file>faces/index.xhtml</welcome-file>
    </welcome-file-list>
    

    如果你只有 index.xhtml,布局将不会被渲染

    【讨论】:

    • 这不是真的。这取决于您如何将 facelet 页面映射到 url...您的答案仅在 web.xml 的上下文中有效。不是一个通用的答案
    • 此配置与 URL 映射无关。我仍然使用localhost:8080/MyWebApp 访问我的应用程序。我的 index.xhtml 直接放在 WEB-INF/ 里面
    • 这取决于faces servlet的url映射是如何完成的……相信我
    猜你喜欢
    • 1970-01-01
    • 2018-07-16
    • 2014-12-13
    • 2018-09-15
    • 2013-05-30
    • 1970-01-01
    • 2014-05-22
    • 2012-09-19
    • 1970-01-01
    相关资源
    最近更新 更多