简体   繁体   English

JSF 2.2将Deltaspike(CDI)windowId注入Bean

[英]JSF 2.2 inject Deltaspike (CDI) windowId into Bean

I'm currently using JSF 2.2 with Deltaspike. 我目前正在将JSF 2.2与Deltaspike一起使用。 We use the Multi-Window-Handling from Deltaspike to handle separate windows. 我们使用Deltaspike的“多窗口处理”来处理单独的窗口。 It works great but in a specific case, we need the window ID. 效果很好,但在特定情况下,我们需要窗口ID。

I am able to read it with: FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("dswid"); 我可以通过以下方式读取它: FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("dswid");

Is there a more elegant way, maybe with injection into my bean? 有没有更优雅的方法,也许是在我的豆子中注入?

Regards, 问候,

Sebastian 塞巴斯蒂安

You can use Param from OmniFaces. 您可以使用OmniFaces中的Param I find it more elegant, but it is a third libary. 我觉得它更优雅,但是它是第三个库。

@Inject @Param
private String dswid;

If you don't want to add a library, you can also inject the external context. 如果您不想添加库,也可以注入外部上下文。

@Inject private ExternalContext externalContext; @Inject private ExternalContext externalContext;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM