我需要转换h:outputtext [英] I need to convert h:outputtext

查看:47
本文介绍了我需要转换h:outputtext的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个rich:datatable来显示数据库上的记录,并且其中有一些列.这是一个示例:

I have a rich:datatable to show records on a DB and there are some columns in. Here is an example :

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

表显示记录很好.我想将 h:outputText 值显示为其他值(我是说将其转换).例如,反向字符串或它的查找和替换"结果.有numberConvertors,dateConvertors,但找不到Strings.客户端解决方案(如javascript,jquery)也可能是合理的.有什么建议吗?

Table shows the records fine. I want to show h:outputText value as a different value (I mean convert it). For example, reversed string or "find&replaced" result of it. There are numberConvertors, dateConvertors but couldn't find for Strings. A client side solution (like javascript,jquery) also could be plausible. Any suggestions?

推荐答案

有numberConvertors,dateConvertors,但找不到字符串

只需自己创建一个.

@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" />

这篇关于我需要转换h:outputtext的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆