0

我是 JSF 和 Richfaces 的新手。我创建了一个 AddEmployee.xhtml,其中包括rich:panels、rich:dropDownMenu 和rich:toolbar。这个 xhtml 是我的应用程序的一部分。在运行时,当我从其他页面访问它时,我可以看到它的内容,但看不到 rich:panel(面板边框)。但是当我直接将这个 AddEmployee.xhtml 作为“在服务器中运行”运行时,我可以查看这个面板。我的问题是为什么当我从其他页面到达页面时我看不到这个面板布局??

我正在使用 Eclipse IDE (juno)。我正在使用的罐子是..

commons-beanutils-1.8.3.jar, commons-codec-1.3.jar, commons-collections-3.2.jar, commons-configuration-1.0.jar, commons-diagester-1.8.jar, commons-discovery-0.4.jar, 
commons-logging-1.1.1.jar, jsf-api-2.1.7.jar, jsf-impl-2.1.7.jar, jstl.jar, 

cssparser-0.9.5.jar、guava-11.0.rc1.jar、richfaces-components-api.4.3.2.Final.jar richfaces-components-ui-4.3.2.Final.jar、richfaces-core-api-4.3 .2.Final.jar、richfaces-core-impl-4.3.2.Final.jar、sac-1.3.jar

Faces.config.xml

<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
version="2.0">
<managed-bean>
<managed-bean-name>MenuBean</managed-bean-name>
<managed-bean-class>org.com.bean.MenuBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<managed-bean>
    <managed-bean-name>UserLogin</managed-bean-name>
<managed-bean-class>org.com.bean.UserLogin</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<managed-bean>
        <managed-bean-name>EmployeeMaster</managed-bean-name>
        <managed-bean-class>org.com.bean.EmployeeMaster</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<navigation-case>
    <from-action>#{MenuBean.addEmployee}</from-action>
    <from-outcome>AddEmployee</from-outcome>
    <to-view-id>/employee/AddEmployee.xhtml</to-view-id>
</navigation-case>
</faces-config>

页眉.xhtml

<?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">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:ui="http://java.sun.com/jsf/facelets">


<rich:toolbar height="46px">
        <rich:dropDownMenu mode="ajax" verticalOffset="1">
            <f:facet name="label">
                <h:outputText value="Home"/>
            </f:facet>
    <rich:menuItem label="Home" action="#{MenuBean.showHome}"></rich:menuItem>
        </rich:dropDownMenu>
        <rich:dropDownMenu mode="ajax">
            <f:facet name="label" >
                <h:outputText value="Employee"/>
            </f:facet>
      <rich:menuItem label="AddEmployee" action="#{MenuBean.addEmployee}">
      </rich:menuItem>
<rich:menuItem label="EmployeeDetails" action="#MenuBean.showEmployeeDetails}"/>
<rich:menuItem label="TerminateEmployee" action="#{MenuBean.terminateEmployee}"/>
<rich:menuItem label="UpdateEmployee" action="#{MenuBean.updateEmployee}"/>
        </rich:dropDownMenu>
    </rich:toolbar>
 </ui:composition>

登录.xhtml

<?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">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
    <title> Login </title>
</h:head>

<body>
<h:form>
<center>
<rich:panel header="Login" style="text-align:left;font-style:normal;               text-decoration:none;width : 343px; height : 181px; color: Black;">
    <center>

        <h:outputText value="Username"/> &nbsp;  &nbsp;  &nbsp;
<h:inputText id="username" value="#{UserLogin.userName}" required="true"/>
            <h:outputText value="&lt;br/&gt;" escape="false" />
            <h:outputText value="&lt;br/&gt;" escape="false" />
        <h:outputText value="Password"/>  &nbsp;  &nbsp;  &nbsp;
<h:inputText id="password" value="#{UserLogin.userPwd}" required="true"/>
            <h:outputText value="&lt;br/&gt;" escape="false" />
            <h:outputText value="&lt;br/&gt;" escape="false" />

        <h:commandButton value="Login"
                    action="#{UserLogin.login}" />   &nbsp; &nbsp; &nbsp;
        <h:commandButton type="reset" value="reset"/> 

    </center>
</rich:panel>
</center>
</h:form>
</body>
</ui:composition>

AddEmployee.xhtml

<?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:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
    <title> Add new employee </title>
</h:head>

<body>
<h:form>

    <ui:insert name="CommonHeader">
        <ui:include src="/Header.xhtml"></ui:include>
    </ui:insert>    

<!-- Header definition over -->
        <br></br>
        <table align="left" cellspacing="0" border="0" cellpadding="5">
          <tr><td> 
          <rich:panel header="Employee Primary Details" style="text-align:left;font-style:normal;text-decoration:none;width : 350px; height : 200px;" rendered="true">

            <h:outputText value="Enter User name : "  style="FONT-WEIGHT: bold;"/> &nbsp;&nbsp;     
            <h:inputText id="empIde" value="#{EmployeeMaster.empId}" />

            <br/><br/>

            <h:outputText value="Enter firstname : " style="FONT-WEIGHT: bold;"/> &nbsp;&nbsp;&nbsp;&nbsp;
            <h:inputText id="firstNamee" value="#{EmployeeMaster.firstName}" />
            <br/><br/>

            <h:outputText value="Enter lastName : " style="FONT-WEIGHT: bold;"/> &nbsp;&nbsp;&nbsp;&nbsp;
            <h:inputText id="lastNamee" value="#{EmployeeMaster.lastName}"  />
            <br/><br/>

            <h:outputText value="Person Type :"  style="FONT-WEIGHT: bold;"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <h:selectOneMenu id ="personType" value="#{EmployeeDetailBean.personType}">
                <f:selectItem itemValue="ASE-T" itemLabel="ASE-T" />
                <f:selectItem itemValue="BA" itemLabel="BA" />
                <f:selectItem itemValue="Business Associate" itemLabel="Business Associate" />
                <f:selectItem itemValue="Employee" itemLabel="Employee" />
            </h:selectOneMenu>
            <br/><br/>

        </rich:panel>           
    </td></tr></table></h:form> </body> </html>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>roaster1</display-name>
  <welcome-file-list>
  <welcome-file>index.html</welcome-file>
  <welcome-file>index.htm</welcome-file>
  <welcome-file>index.jsp</welcome-file>
  <welcome-file>default.html</welcome-file>
  <welcome-file>default.htm</welcome-file>
  <welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
  <servlet-name>Faces Servlet</servlet-name>
  <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
 <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
  <servlet-name>Faces Servlet</servlet-name>
  <url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<context-param>
  <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
  <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
  <param-value>client</param-value>
</context-param>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
 <listener>
   <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
 </listener>
 <listener>
    <listener-class>org.com.init.Listener</listener-class>
  </listener>
</web-app>

当我编辑两个 XHTML 的源代码时,我发现一个中缺少以下内容...

<link href="/roaster2/faces/rfRes/panel.ecss?db=eAHjW!XqPQAE!QKS&ln=org.richfaces" rel="stylesheet" type="text/css"></link>
 <script src="/roaster2/faces/javax.faces.resource/json-dom.js?ln=org.richfaces" type="text/javascript"></script>
 <script src="/roaster2/faces/javax.faces.resource/jquery.effects.core.js?ln=org.richfaces" type="text/javascript"></script>
 <script src="/roaster2/faces/javax.faces.resource/jquery.effects.highlight.js?ln=org.richfaces" type="text/javascript"></script>
 <script src="/roaster2/faces/javax.faces.resource/JQuerySpinBtn.js?ln=org.richfaces" type="text/javascript"></script>
 <script src="/roaster2/faces/javax.faces.resource/calendar-utils.js?ln=org.richfaces" type="text/javascript"></script>
 <script src="/roaster2/faces/javax.faces.resource/calendar.js?ln=org.richfaces" type="text/javascript"></script>
 <link href="/roaster2/faces/rfRes/calendar.ecss?db=eAHjW!XqPQAE!QKS&ln=org.richfaces" rel="stylesheet" type="text/css"></link>
4

1 回答 1

0

在这些情况下,您最好的帮助是网络检查器之类的工具。在 Firefox 中,您可以使用 Firebug(插件)或“右键单击元素 -> 检查元素”。Chrome 也包含类似的工具。这些工具允许您检查所有 Web 元素(DOM 树、CSS、JavaScript 等),因此您可以随时检查任何元素中的 HTML 或 CSS 属性。

一个可能的解决方案是,当您将面板包含在其他页面中时,面板的边框被组件所在的容器的边框隐藏。

希望这个回答对你有帮助

问候,

于 2013-10-02T06:40:11.360 回答