@ManagedProperty 在@PostConstruct 之后注入 [英] @ManagedProperty injected AFTER @PostConstruct

查看:27
本文介绍了@ManagedProperty 在@PostConstruct 之后注入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题已经在 MYFACES 2.1 实现中解决了

THIS PROBLEM IS ALREADY SOLVED IN THE MYFACES 2.1 IMPLEMENTATION

我有一个像这样正确传递整数参数的链接:

I have a link which passes an Integer parameter properly like this:

<h:link outcome="/process/createProcess">
    <f:param name="id" value="#{process.idprocess}" />
    Edit
</h:link>

它正确地转到createProcess.xhtml?id=21",我在请求范围内有此代码支持 Bean createProcess:

It goes to "createProcess.xhtml?id=21" properly, and I have this code in the request scope backing Bean createProcess:

@ManagedProperty(value="#{param.id}")
private Integer idProcess;

private Process newProcess;

@PostConstruct
public void init()
{
    log();
    if (idProcess!=null)
        newProcess = Dao.getProcessDAO().get(idProcess);
    else
        newProcess = new Process();
}

我注意到 idProcess 始终为空.经过调试,我意识到 setIdProcess 方法被称为 AFTER @PostConstruct.

I've notice that idProcess is always null. After debugging I realized that setIdProcess method is called AFTER @PostConstruct.

我知道注入是在构建 bean 之后完成的,并且所有 managedProperties 都在 @PostConstruct 中可用.

I understand that injection is done just after the construction of the bean and all the managedProperties are available in @PostConstruct.

我错过了什么?

推荐答案

仅供参考,我认为这篇文章的问题是MYFACES-3116,with已经固定在,所以2.0.6、2.1.0及以上版本没有.

Just for reference, I think the issue in this post is MYFACES-3116, with was already fixed at , so 2.0.6, 2.1.0 and upper versions does not have it.

这篇关于@ManagedProperty 在@PostConstruct 之后注入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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