【问题标题】:JSF Primefaces and BootsfacesJSF Primefaces 和 Bootsfaces
【发布时间】:2015-09-16 04:26:57
【问题描述】:

我有问题。

我正在制作一个采用 PrimeFaces 布局的网站,当我单击左侧的任何菜单项时,它会在中心加载一个页面,但是当我使用 BootsFaces 主题时(<bnu: panel ....> </bnu: panel>,页面加载在center 但它不是另一个负载,当我不使用主题时,一切正常,但面板以纯文本显示,没有样式外观 =“成功”例如。

<?xml version='1.0' encoding='UTF-8' ?>
<!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:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:bnu="http://bootsfaces.net/ui">
    <h:head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>My Page</title>
    </h:head>
    <h:body>
        <p:layout fullPage="true">

            <p:layoutUnit position="north" size="100" resizable="false" closable="false" collapsible="false" >
                <h1>PAGE</h1>

            </p:layoutUnit>


            <p:layoutUnit position="west" size="195" header="Panel" resizable="true" closable="false" collapsible="true" >
                <h:form id="form" >

                    <p:menu>
                        <p:menuitem id="abc" value="Inicio" action="#{bean.page0()}" update=":content:pcenter" />
                        <p:submenu label="ABC" >
                            <p:menuitem id="X1" value="CC1" action="#{bean.page1()}" update=":content:pcenter"/>
                            <p:menuitem id="X2" value="CC2" action="#{bean.page2()}" update=":content:pcenter"/>
                            <p:menuitem id="X3" value="CC3" action="#{bean.page3()}" update=":content:pcenter"/>
                        </p:submenu>
                    </p:menu>

                </h:form>
            </p:layoutUnit>

            <p:layoutUnit position="center" header="Welcome user" >
                <h:form id="content">
                    <p:panel id="pcenter">
                        <ui:include src="#{bean.page}.xhtml" />
                    </p:panel>
                 </h:form>
            </p:layoutUnit>

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

        </p:layout>         
    </h:body>
</html>

我试试这个,不显示样式look="success",但显示标题

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:bnu="http://bootsfaces.net/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core">

    <bnu:panel id="pdata" title="User data" collapsible="true" look="success">
           <p:outputLabel value="Name" for="txt_name"/>
                <p:inputText id="txt_name" label="Name" required="true">
                </p:inputText>
    </bnu:panel>
</html>

我试试这个,也一样

<ui:composition 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"
    xmlns:ui="http://java.sun.com/jsf/facelets">

    <bnu:panel id="pdata" title="User data" collapsible="true" look="success">
           <p:outputLabel value="Name" for="txt_name"/>
                <p:inputText id="txt_name" label="Name" required="true">
                </p:inputText>
    </bnu:panel>
</ui:composition>

试试这个,工作但在单击左侧菜单的元素时不加载中心的页面

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:bnu="http://bootsfaces.net/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core">

   <head>
   </head>
    <bnu:panel id="pdata" title="User data" collapsible="true" look="success">
           <p:outputLabel value="Name" for="txt_name"/>
                <p:inputText id="txt_name" label="Name" required="true">
                </p:inputText>
    </bnu:panel>
</html>

【问题讨论】:

  • “页面加载在中心,但不是另一个加载” 是吗?你想在那里表达什么?
  • 我猜它应该是“默认页面片段显示在中心,但是当我单击其中一个菜单项时,中心面板没有更新为新的页面片段”。跨度>
  • 顺便说一句,我在对 bean 进行逆向工程时遇到了一些麻烦。你介意下次添加吗?加上 web.xml、faces-config.xml 和 pom.xml?这使得重现您的问题变得更加容易。正如我在回答中所写,我怀疑错误隐藏在后三个文件之一中。
  • 问题标题很尴尬,它可以适合任何其他关于 JSF、PrimeFaces 和 BootsFaces 的问题,所以我想更新它,只说具体问题,就像其他所有好的问题标题一样,但我到目前为止,我仍然不了解具体问题。

标签: jsf primefaces bootsfaces


【解决方案1】:

实际上,这三个版本中的每一个都有效。我已经基于您的 XHTML 页面创建了一个项目,它运行完美。无论有无 PrimeFaces Bootstrap 主题。所以我最好的猜测是你的项目设置有问题。

我建议您查看https://github.com/stephanrauh/BootsFaces-Examples/tree/master/PrimeFacesLayout 中的示例,并尝试找出与您的项目不同的地方。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-01-29
    • 2019-07-28
    • 1970-01-01
    • 2018-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-27
    相关资源
    最近更新 更多