ManagedProperty not injected in @FacesConverter
I'm trying to inject a ManagedBean in my FacesConverted the following way:
@ManagedBean
@RequestScoped
@FacesConverter(forClass = Group.class)
public class GroupConverter implements Converter { @ManagedProperty("#{groupService}")
private GroupService groupService; @Override
public Group getAsObject(FacesContext context, UIComponent arg1,
String groupName) {
return groupService.findGroupByName(groupName);
} @Override
public String getAsString(FacesContext arg0, UIComponent arg1, Object group) {
return ((Group) group).getName();
} public GroupService getGroupService() {
return groupService;
} public void setGroupService(GroupService groupService) {
this.groupService = groupService;
} }
The problem is that groupService isn't being injected and I get a NullPointerEx. Shouldn't it be autowired automatically since it's also a ManagedBean? It all works when I change "getAsObject" to "return new Group();" obviously.
Any ideas?
The solution:
It is likely that you are not resolving the managed bean name.
@ManagedBean(name = "myConverter")
@RequestScoped
@FacesConverter(value = "myConverter")
public class MyConverter implements Converter {
For example, consider these two components:
<h:inputText converter="myConverter" value="#{foo.prop}" />
<h:inputText converter="#{myConverter}" value="#{bar.prop}" />
When the converter is set on the first component, it will be created by Application.createConverter. A converter is not a managed bean. The same rules apply if you match a converter by type.
In the second component, a value expression is used to return a class that implements Converter. This uses the usual managed bean mechanisms. In this case, the @FacesConverter annotation is irrelevant.
ManagedProperty not injected in @FacesConverter的更多相关文章
- 【九】注入框架RoboGuice使用:(Your First Injected Service and BroadcastReceiver)
上一篇我们简单的介绍了一下RoboGuice的使用([八]注入框架RoboGuice使用:(Your First Injected Fragment)),今天我们来看下服务(Service)和广播接受 ...
- @EnableAsync annotation metadata was not injected
[问题描述] @EnableAsync annotation metadata was not injected spring配置初始化时候报错 nested exception is java.la ...
- @EnableAsync annotation metadata was not injected Spring容器启动后访问Servlet报错
@EnableAsync annotation metadata was not injected 2015年12月20日 20:06:54 7570 在初始化spring事务部分碰到该错误, 详细错 ...
- The bean 'xxx' could not be injected as a 'xxx'because it is a JDK dynamic proxy that implements
启动springboot项目的时候示以下错误 Error starting ApplicationContext. To display the conditions report re-run yo ...
- Bean with name 'xxxService' has been injected into other beans [xxxServiceA,xxxServiceB] in its raw version as part of a circular reference, but has eventually been wrapped
启动项目,通过@Autowired注入对象,出现循环依赖,导致项目启动失败,具体报错信息如下: Exception encountered during context initialization ...
- injected stylesheet 谷歌扩展插件,造成样式异常
今天在开发的时候,遇到一个问题,就是我们我在写发送广告的功能,然后我用了一个textare文本框,这个时候,发现了一个问题.这个文本框凭空消失了.不见了,我以为是自己的那个样式不小心把这个隐藏掉了后来 ...
- QIBO /do/jf.php EvilCode Execution Injected By /hack/jfadmin/admin.php
catalog . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 这个漏洞的成因简单来说可以归纳为如下几点 . 类似于ECSHOP的的模版 ...
- spring报nested exception is java.lang.IllegalArgumentException: @EnableAsync annotation metadata was not injected错误
http://www.oschina.net/question/1539472_159699
- 【八】注入框架RoboGuice使用:(Your First Injected Fragment)
上一篇我们简单的介绍了一下RoboGuice的使用([七]注入框架RoboGuice使用:(Your First Custom Binding)),今天我们来看下fragment的注解 ...
随机推荐
- Linux下weblogic启动报错unable to get file lock的问题
非正常结束weblogic进程导致weblogic无法启动 由于先前服务器直接down掉了,所有进程都非正常的进行关闭了,也就导致了下次启动weblogic的时候报了以下错误:<2012-3-2 ...
- JS object(对象)的学习汇总
Object(对象)是在所有的编程语言中都十分重要的一个概念,对于事物我们可以把他们看作是一个对象,而每一个事物都有自己的表示的属性和对于某一信息作出的相应的操作.而这些东西就变成了事物的属性和方法. ...
- HTTP相关知识点
一.工作原理 HTTP协议工作于客户端-服务器架构上.浏览器作为HTTP客户端通过URL向HTTP服务端(即web服务端)发送所有请求. Web服务器接收到请求后,向客户端发送相应的响应信 ...
- Ubuntu 16.04 日常工具
shutter sudo apt-get install shutter indicator-sysmonitor 之前需要通过deb包安装,现在可以通过添加PPA安装: sudo add-apt-r ...
- java的代理(编程思想)
代理 第三种关系被称为代理,java并没有提供对它的直接支持.这是继承和组合之间的中庸之道,因为我们将一个对象置于所要构造的类中(就像组合),但与此同时我们在新类中暴露了该成员对象的所有方法(就像继承 ...
- OPENCV Linux安装
https://docs.opencv.org/master/d7/d9f/tutorial_linux_install.html
- Nginx 反向代理 如何在web应用中获取用户ip
转载:http://blog.csdn.net/bao19901210/article/details/52537279 问题背景: 在实际应用中,我们可能需要获取用户的ip地址,比如做异地登陆的判断 ...
- python3高阶函数:map(),reduce(),filter()的区别
转载请注明出处:https://www.cnblogs.com/shapeL/p/9057152.html 1.map():遍历序列,对序列中每个元素进行操作,最终获取新的序列 print(list( ...
- Tensorflow 模型文件结构、模型中Tensor查看
tensorflow训练后保存的模型主要包含两部分,一是网络结构的定义(网络图),二是网络结构里的参数值. 1. .meta文件 .meta 文件以 "protocol buffer&qu ...
- matlab 读多个文件夹(有名字规律)中的文件名字保存到txt中
save_file_name='C:\Users\cong\Desktop\研一实战\项目\图像中时间数字识别\OCR\result6\'; :: image_path=strcat('C:\User ...