简体   繁体   English

JSF-在dataTable的一列中呈现2个值

[英]JSF- render 2 values in one column in dataTable

I have a dataTable in JSF and in one column i must render a date. 我在JSF中有一个dataTable,并且我必须在一列中显示一个日期。 To view in page for a specific format I use a convertDateTime. 要在页面中查看特定格式,请使用convertDateTime。 The problem is when validationDate is loaded this value it is not converted for my pattern. 问题是,当validationDate加载此值时,不会为我的模式转换该值。 Only the first value (stampoperation), if it is loaded, is converted for my pattern. 如果加载了第一个值(stampoperation),则将其转换为我的模式。

<t:dataTable value="#{ProductBean.viewByid}"
             var="item" border="0" cellspacing="2" cellpadding="2"
             width="100%" id="dtbl" headerClass="tableSotableHeader"
             preserveDataModel="false" 
             rowClasses="rowOdd,rowEven">
   <h:column>
      <f:facet name="header">
         <h:outputText value="State" />
      </f:facet>
   </h:column>
   <h:column>
      <f:facet name="header">
         <h:outputText value="Data start" />
      </f:facet>
      **<h:outputText value="#{item.stampoperation}" rendered="#{item.status!=15}" >
         <f:convertDateTime timeZone="#{UIBean.tz}" type="date" pattern="dd.MM.yyyy, HH:mm"/>
      </h:outputText>
      <h:outputText  value="#{item.validDate}" rendered="#{item.status==15}">
         <f:convertDateTime timeZone="#{UIBean.tz}" type="date" pattern="dd.MM.yyyy, HH:mm"/>
      </h:outputText>**
   </h:column>
</t:dataTable>

There's a similar issue like in this question 这个问题也有类似的问题

When you dynamically display some component, it should be wrapped in a panelGroup and that panelGroup should have rendered attribute set. 当动态显示某些组件时,应将其包装在panelGroup中,并且该panelGroup应该已设置了render属性。

Solved: I put values in a panel Group 解决:我将值放在面板组中

<t:panelGroup id="x1">                                                                <h:outputText value="#{item.stampoperation}" rendered="#{item.status!=15}" >
         <f:convertDateTime timeZone="#{UIBean.tz}" type="date" pattern="dd.MM.yyyy, HH:mm"/>
      </h:outputText>
      <h:outputText  value="#{item.validDate}" rendered="#{item.status==15}">
         <f:convertDateTime timeZone="#{UIBean.tz}" type="date"  pattern="dd.MM.yyyy, HH:mm"/>
       </h:outputText>                                                            </t:panelGroup>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM