我在 Tomcat 7 jsf 2.1 中有这张表
我的目的是自定义单元格中显示的文本。它是一个整数,我显示从列表中获取的对象的 toString 中的字符串
1,2,3,4,5
1,2,4,8,2
我用它变换它
1,f(2)->"TWO",g(3)->"XXX",4,5
1,f(2)->"TWO",g(4)->"yyyy",4,5
这是桌子
<p:dataTable id="dataTable"
lazy="true"
value="#{cfgCentraleController.lazyModel}"
paginator="true" rows="10"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
var="centrale"
selection="#{cfgCentraleController.selectedCentrali}"
emptyMessage="Nessun dato per la ricerca"
rowsPerPageTemplate="10,15,20,25,30,35,40,45,50">
<f:facet name="header">
Lista Centrali
</f:facet>
<p:column selectionMode="multiple" style="width:18px" />
<p:column sortBy="#{centrale.idDevices}" >
<f:facet name="header">
<h:outputText value="idDevices" />
</f:facet>
<p:commandLink value="#{centrale.idDevices}" update=":centraleDetailForm:display" oncomplete="centraleDialogJS.show()" title="View">
<f:setPropertyActionListener value="#{centrale}" target="#{cfgCentraleController.selectedCentrale}" />
</p:commandLink>
</p:column>
<p:column sortBy="#{centrale.ridonda}">
<f:facet name="header">
<h:outputText value="Ridonda" />
</f:facet>
<h:outputText value="#{centrale.ridonda}" />
</p:column>
<p:column sortBy="#{centrale.idMarca}">
<f:facet name="header">
<h:outputText value="Marca" />
</f:facet>
<c:set var="MM" value="#{cfgCentraleController.resolveRete(centrale.idRete)}" />
<h:outputText value="#{MM}" />
</p:column>
<p:column sortBy="#{centrale.idRete}">
<f:facet name="header">
<h:outputText value="Rete" />
</f:facet>
<c:set var="RR" value="#{cfgCentraleController.resolveRete(centrale.idRete)}" />
<h:outputText value="#{RR}" />
</p:column>
<p:column sortBy="#{centrale.descrizione}">
<f:facet name="header">
<h:outputText value="Descrizione" />
</f:facet>
<h:outputText value="#{centrale.descrizione}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Note" />
</f:facet>
<h:outputText value="#{centrale.note}" />
</p:column>
<f:facet name="footer" >
<p:row>
<p:column>
<h:commandLink>
<p:graphicImage library="img" width="20" name="XLS.png" value="XLS.png" />
<p:dataExporter type="xls" target="dataTable" fileName="cars" />
</h:commandLink>
<h:commandLink>
<p:graphicImage library="img" width="20" name="PDF.png" value="PDF.png" />
<p:dataExporter type="pdf" target="dataTable" fileName="cars"/>
</h:commandLink>
<h:commandLink>
<p:graphicImage library="img" width="20" name="CSV.png" value="CSV.png"/>
<p:dataExporter type="csv" target="dataTable" fileName="cars" />
</h:commandLink>
</p:column>
<p:column colspan="1" style="text-align: left" >
<p:commandLink id="pdf" ajax="false">
<p:graphicImage value="/resources/images/pdf.png"/>
<pe:exporter type="pdf" target="dynamicColumnsTable" fileName="dynamicColumnsTable"/>
</p:commandLink>
<p:spacer height="20"/>
<p:commandLink id="xls" ajax="false">
<p:graphicImage value="/resources/images/excel.png"/>
<pe:exporter type="xlsx" target="dynamicColumnsTable" fileName="dynamicColumnsTable"/>
</p:commandLink>
<p:commandButton value="Nuova Centrale" oncomplete="newCentraleDialogJS.show()" icon="ui-icon-star" title="Crea una nuova centrale"/>
<p:commandButton value="Elimina Centrale" onclick="confirmationJS.show();" update="dataTable" icon="ui-icon-trash"/>
</p:column>
</p:row>
</f:facet>
</p:dataTable>
豆是
package com.telenia.tsam.beans.config.centrali;
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
/**
*
* @author Riccardo
*/
@ManagedBean
public class Centrale implements Serializable {
private static final long serialVersionUID = 481317100879125703L;
private int idDevices;
private String note;
private String descrizione;
private int idMarca;
private int idRete;
private int ridonda;
/**
* @return the idDevices
*/
public int getIdDevices() {
return idDevices;
}
/**
* @param idDevices the idDevices to set
*/
public void setIdDevices( int idDevices ) {
this.idDevices = idDevices;
}
/**
* @return the note
*/
public String getNote() {
return note;
}
/**
* @param note the note to set
*/
public void setNote( String note ) {
this.note = note;
}
/**
* @return the descrizione
*/
public String getDescrizione() {
return descrizione;
}
/**
* @param descrizione the descrizione to set
*/
public void setDescrizione( String descrizione ) {
this.descrizione = descrizione;
}
/**
* @return the idMarca
*/
public int getIdMarca() {
return idMarca;
}
/**
* @param idMarca the idMarca to set
*/
public void setIdMarca( int idMarca ) {
this.idMarca = idMarca;
}
/**
* @return the idRete
*/
public int getIdRete() {
return idRete;
}
/**
* @param idRete the idRete to set
*/
public void setIdRete( int idRete ) {
this.idRete = idRete;
}
/**
* @return the ridonda
*/
public int getRidonda() {
return ridonda;
}
/**
* @param ridonda the ridonda to set
*/
public void setRidonda( int ridonda ) {
this.ridonda = ridonda;
}
}
这是 cfgCentraleController 中的解析器
public Marca resolveMarca( int idMarca ) {
if (this.marche != null) {
for (Marca marca : marche) {
if (marca.getIdMarca() == idMarca) {
return marca;
}
}
}
return null;
}
public Rete resolveRete( int idRete ) {
if (this.reti != null) {
for (Rete rete : reti) {
if (rete.getIdRete() == idRete) {
return rete;
}
}
}
return null;
}
我使用 BalusC 的指示动态更改 <h:dataTable> 列中单元格的 CSS 样式并且数据显示正确
但是出口抱怨这个问题
giu 25, 2013 5:16:07 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [Faces Servlet] in context with path [] threw exception [/stdPortal/stdPages/config/centrale/List.xhtml @148,51 value="#{MM}": /stdPortal/stdPages/config/centrale/List.xhtml @147,102 value="#{cfgCentraleController.resolveRete(centrale.idRete)}": Property 'resolveRete' not found on type com.telenia.tsam.beans.config.centrali.cfgCentraleController] with root cause
javax.el.PropertyNotFoundException: Property 'resolveRete' not found on type com.telenia.tsam.beans.config.centrali.cfgCentraleController
at javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:237)
at javax.el.BeanELResolver$BeanProperties.access$400(BeanELResolver.java:214)
at javax.el.BeanELResolver.property(BeanELResolver.java:325)
at javax.el.BeanELResolver.getType(BeanELResolver.java:117)
at com.sun.faces.el.DemuxCompositeELResolver._getType(DemuxCompositeELResolver.java:215)
at com.sun.faces.el.DemuxCompositeELResolver.getType(DemuxCompositeELResolver.java:242)
at org.apache.el.parser.AstValue.getType(AstValue.java:84)
at org.apache.el.ValueExpressionImpl.getType(ValueExpressionImpl.java:172)
at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:98)
at org.apache.el.parser.AstIdentifier.getType(AstIdentifier.java:50)
at org.apache.el.ValueExpressionImpl.getType(ValueExpressionImpl.java:172)
at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:98)
at org.primefaces.component.export.Exporter.exportValue(Exporter.java:131)
at org.primefaces.component.export.ExcelExporter.addColumnValue(ExcelExporter.java:204)
at org.primefaces.component.export.ExcelExporter.exportCells(ExcelExporter.java:164)
at org.primefaces.component.export.ExcelExporter.exportRow(ExcelExporter.java:147)
at org.primefaces.component.export.ExcelExporter.exportAll(ExcelExporter.java:123)
at org.primefaces.component.export.ExcelExporter.export(ExcelExporter.java:61)
at org.primefaces.component.export.DataExporter.processAction(DataExporter.java:99)
at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:818)
at javax.faces.component.UICommand.broadcast(UICommand.java:300)
at javax.faces.component.UIData.broadcast(UIData.java:1108)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.telenia.tsam.Filters.NoCacheFilter.doFilter(NoCacheFilter.java:47)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:581)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1008)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1852)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
我认为它使用不同的方法来解决 EL。或者我做错了什么?