sen*_*ale 8 jsf binding deprecated
我有一些JSF 1.0/1.1代码:
FacesContext context = FacesContext.getCurrentInstance();
ValueBinding vb = context.getApplication().createValueBinding("#{someBean}");
SomeBean sb = (SomeBean) vb.getValue(context);
Run Code Online (Sandbox Code Playgroud)
从JSF 1.2开始,ValueBinding不推荐使用并替换为ValueExpression.我不知道如何更改上面的代码才能使用ValueExpression.
Bal*_*usC 17
那个部分
ValueBinding vb = context.getApplication().createValueBinding("#{someBean}");
SomeBean sb = (SomeBean) vb.getValue(context);
Run Code Online (Sandbox Code Playgroud)
应该被替换
ValueExpression ve = context.getApplication().getExpressionFactory().createValueExpression(context.getELContext(), "#{someBean}", SomeBean.class);
SomeBean sb = (SomeBean) ve.getValue(context.getELContext());
Run Code Online (Sandbox Code Playgroud)
或更好
SomeBean bc = context.getApplication().evaluateExpressionGet(context, "#{someBean}", SomeBean.class);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7619 次 |
| 最近记录: |