【问题标题】:JSF do not interpret placeholder in <h:outputText value="#{tableRow.x}" />JSF 不解释 <h:outputText value="#{tableRow.x}" /> 中的占位符
【发布时间】:2011-04-04 09:21:28
【问题描述】:

我将 jsf、richfaces 和 spring 混合在一起(faces backing beans = spring beans),我有一个带有表格的 jsp 页面。出于某种奇怪的原因标记

<rich:dataTable value="#{inputBean.table}" var="tableRow">

调用 inputBean.getTable() 方法并使用与 table(List) 相同数量的表行构造输出表 -> #{inputBean.table} 被替换为来自 inputBean 的对象表。

但是当我想显示一行X值时

<h:outputText value="#{tableRow.x}" />

只有#{tableRow.x} 显示在页面上,而不是值。我认为可能是richfaces配置正确但jsf没有配置问题(h:outputText是jsf标签)

有什么想法吗?我将衷心感谢您的帮助。提前致谢。 页面:

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
<html>
 <body>
 <f:view>
 <h:form>
    <rich:dataTable value="#{inputBean.table}" var="tableRow">
  <f:facet name="caption">
   <h:outputText value="United States Capitals" />
   </f:facet>
   <f:facet name="header">
    <h:outputText value="Capitals and States Table" />
   </f:facet>
   <rich:column>
    <f:facet name="header">x</f:facet>
    <h:outputText value="#{tableRow.x}" />
    <f:facet name="footer">State Name</f:facet>
   </rich:column>
   <rich:column>
    <f:facet name="header">lx</f:facet>
    <h:outputText value="#{tableRow.lx}" />
   <f:facet name="footer">State Capital</f:facet>
   </rich:column>
           <f:facet name="footer">
    <h:outputText value="Capitals and States Table" />
          </f:facet>
  </rich:dataTable>
 </h:form>
</f:view>
</body>
</html>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
         http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
 <!--  *********** Faces config *********** -->
 <context-param>
  <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
  <param-value>server</param-value>
 </context-param>
 <context-param>
  <param-name>javax.faces.CONFIG_FILES</param-name>
  <param-value>/WEB-INF/faces-config.xml</param-value>
 </context-param>
 <!-- Faces Servlet -->
 <servlet>
  <servlet-name>Faces Servlet</servlet-name>
  <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
  <load-on-startup>1</load-on-startup>
 </servlet>
 <!-- Faces Servlet Mapping -->
 <servlet-mapping>
  <servlet-name>Faces Servlet</servlet-name>
  <url-pattern>*.jsf</url-pattern>
 </servlet-mapping>
 <!--  *********** Faces config *********** -->
 <!--  *********** rich faces config *********** -->
 <!-- Plugging the "Blue Sky" skin into the project -->
 <context-param>
  <param-name>org.richfaces.SKIN</param-name>
  <param-value>blueSky</param-value>
 </context-param>
 <!-- Making the RichFaces skin spread to standard HTML controls -->
 <context-param>
  <param-name>org.richfaces.CONTROL_SKINNING</param-name>
  <param-value>enable</param-value>
 </context-param>
 <!-- Defining and mapping the RichFaces filter -->
 <filter>
  <display-name>RichFaces Filter</display-name>
  <filter-name>richfaces</filter-name>
  <filter-class>org.ajax4jsf.Filter</filter-class>
 </filter>
 <filter-mapping>
  <filter-name>richfaces</filter-name>
  <servlet-name>Faces Servlet</servlet-name>
  <dispatcher>REQUEST</dispatcher>
  <dispatcher>FORWARD</dispatcher>
  <dispatcher>INCLUDE</dispatcher>
 </filter-mapping>
 <!--  *********** rich faces config *********** -->
 <!--  *********** Spring config *********** -->
 <listener>
  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
 </listener>
 <listener>
  <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
 </listener>
 <context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>/WEB-INF/applicationContext.xml</param-value>
 </context-param>
 <!--  *********** Spring config *********** -->
 <welcome-file-list>
  <welcome-file>
      index.jsp
    </welcome-file>
 </welcome-file-list>
</web-app>

应用程序配置:

 <?xml version="1.0"?>
 <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-2.5.xsd">
  <!-- the parent application context definition for the springapp application -->
    <bean id="inputBean" class="backingbeans.InputBean"  scope="request">
         <property name="tableService" ref="tableService"/>
    </bean>    
    <bean id="tableService" class="TableServiceImpl"  scope="session">        
    </bean>
  </beans>

【问题讨论】:

  • 要排除一个和另一个,添加&lt;h:outputText value="#{inputBean.table}" /&gt; &lt;rich:dataTable&gt; 之前,让我们知道它显示的内容。
  • tableRow 中的对象类是什么?它有getX()方法吗?
  • 您好,感谢您的帮助。我已经尝试了仅使用 h:outputText 的简单代码,没有丰富的标签 - 结果相同。 TableRow 有 getX() 方法。它也不适用于其他 bean。日志说没有错:-(我的观点是h-tag没有用jsf完全解释->似乎是配置或库问题。我认为jsf生成代码时一定是在某个地方,它替换了标签而不是价值。有什么想法吗?提前致谢。

标签: java spring jsf richfaces


【解决方案1】:

好的,经过一天的配置,我发现了错误-我使用的是richfaces 3.1.0,但是jsf 1.2 !!!在我迁移到 jsf 2.x 后问题突然消失了。我认为主要问题是新的richfaces不能与旧的jsf混合。

【讨论】:

    猜你喜欢
    • 2022-11-01
    • 2013-04-10
    • 1970-01-01
    • 2016-01-20
    • 2012-08-09
    • 2014-07-14
    • 2013-03-18
    • 1970-01-01
    • 2019-06-04
    相关资源
    最近更新 更多