为什么@FacesConverter(forClass = String.class)不起作用 [英] Why is @FacesConverter(forClass=String.class) not working

查看:81
本文介绍了为什么@FacesConverter(forClass = String.class)不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里遵循以下示例:为什么< h:inputTextrequired ="true"允许空格?创建一个全局"转换器以修剪所有输入字段.但是,提交输入字段时未调用转换器.

I followed the example here: Why does <h:inputText required="true"> allow blank spaces? to create a "Global" converter to trim all input fields. However, the converter is not being invoked when input fields are submitted.

@FacesConverter(forClass=String.class) 
... 
<p:inputText value="#{controller.inputValue}"/> 

但是当我更改为:

@FacesConverter("StringTrimmer") 
... 
<p:inputText value="#{controller.inputValue}" converter="StringTrimmer"/> 

有效.

使用Mojarra 2.1.7和PrimeFaces 3.2

Using Mojarra 2.1.7 and PrimeFaces 3.2

推荐答案

这没用,因为inputValue实际上不是String类型的.更改为String类型后,它就起作用了.

This didnt work because the inputValue was not actually of type String. Once changed to type String-- it worked.

这篇关于为什么@FacesConverter(forClass = String.class)不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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