Javascript 我需要转换h:outputtext

Javascript 我需要转换h:outputtext,javascript,jsf,richfaces,Javascript,Jsf,Richfaces,我有一个rich:datatable来显示数据库中的记录,其中有一些列。以下是一个例子: <rich:dataTable id="myTable" var="myItem" value="#{myList}"> <rich:column width="25%"> <h:outputText value="#{myItem.myValue}" /> </rich:column> ... ... 表中显示的记录很

我有一个rich:datatable来显示数据库中的记录,其中有一些列。以下是一个例子:

<rich:dataTable id="myTable" var="myItem" value="#{myList}">
    <rich:column width="25%">
         <h:outputText value="#{myItem.myValue}" />
    </rich:column>
...

...

表中显示的记录很好。我想将
h:outputText
值显示为不同的值(我的意思是转换它)。例如,反转字符串或“查找并替换”其结果。有NumberConverter和DateConverter,但找不到字符串的。客户端解决方案(如javascript、jquery)也可能是合理的。有什么建议吗?

没有字符串值的默认转换器

这里可以做的最简单的事情是编写一个替代的getMyValue()-methode

有NumberConverter和DateConverter,但找不到字符串的

你自己做一个就行了

@FacesConverter("myStringConverter")
public class MyStringConverter implements Converter {

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value) {
        // Write code here which converts the model value before displaying.
    }

    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) {
        // Write code here which converts the submitted value before updating model.
        // Note that this method isn't ever used in output text.
    }

}
按如下方式使用:

<h:outputText value="#{myItem.myValue}" converter="myStringConverter" />

@FacesConverter("myStringConverter")
public class MyStringConverter implements Converter {

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value) {
        // Write code here which converts the model value before displaying.
    }

    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) {
        // Write code here which converts the submitted value before updating model.
        // Note that this method isn't ever used in output text.
    }

}
<h:outputText value="#{myItem.myValue}" converter="myStringConverter" />