2012-02-06 42 views
0

我有@ViewScoped@ManagedBean@RequestParam来初始化我的@PostConstruct方法中的某些内容。在@ViewScoped Bean中使用AJAX焊接@RequestParam

@ManagedBean @ViewScoped 
public class MyBean implements Serializable 
{ 
    @javax.inject.Inject 
    @org.jboss.solder.servlet.http.RequestParam("id") 
    private long id; 

    @PostConstruct 
    public void init() {...} 

    ... 
} 

ID与像test.jsf?id=1357调用正确的注射,但现在我想添加一些p:ajax东西在我的XHTML页面。如果我删除了@Inject @RequestParam(并在init()硬编码的id)这工作正常,但如果我想使用此注射没有任何反应和萤火虫给了我这样的响应:

<partial-response><error> 
    <error-name>class java.lang.IllegalStateException</error-name> 
    <error-message><![CDATA[Can not set long field MyBean.id to null value]]></error-message> 
</error></partial-response> 

更改类型 private Long id结果
<partial-response><error> 
    <error-name>class java.lang.IllegalStateException</error-name> 
    <error-message><![CDATA[]]></error-message> 
</error></partial-response> 

如何在@ViewScoped Bean中使用@RequestParam

+0

我不知道缝焊接是什么,它应该做的,但你可以用标准的JSF2''标签实现相同的基本功能要求。 – BalusC 2012-02-06 16:06:12

+0

谢谢你的解决方法,目前我已经删除了@Inject @ RequestParam并使用了''。 – Thor 2012-02-08 07:30:58

回答

0

id必须封装在javax.enterprise.inject.Instance;中,以与Seams RequestParam一起使用。

@javax.inject.Inject 
@org.jboss.solder.servlet.http.RequestParam("id") 
private Instance<Long> id; 

(在我从@ManagedBean @ViewScoped切换到@Named @ViewScoped,但我认为这是不相关的这个问题,同时)

相关问题