java 在 JSF 2 中操作后导航到同一页面
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2777852/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Navigate to the Same Page After Action in JSF 2
提问by shipmaster
I have a component done in JSF 1.x, this component has a command button as follows
我有一个在 JSF 1.x 中完成的组件,这个组件有一个命令按钮如下
<h:commandButton ... action="#{templateController.next}" />
Where templateController was passed as an EL binding and can be any object that implements a certain interface. The generic implementation of next() was just executing code and then returning an empty string causing the same page to refresh:
其中 templateController 作为 EL 绑定传递并且可以是实现某个接口的任何对象。next() 的通用实现只是执行代码,然后返回一个空字符串,导致同一页面刷新:
public String next() {
.....
return "";
}
Now I am trying to port that component to JSF 2, my problem is that an empty string doesn't cause the same page to refresh anymore, instead, the framework tries to redirect to a page called ".jsf" i.e it just appends .jsf to whatever the outcome is. My question is how to return an outcome that causes the current page to refresh. My component is generic and I don't know before hand the name of the page it is going to be used on.
现在我正在尝试将该组件移植到 JSF 2,我的问题是空字符串不再导致同一页面刷新,相反,框架尝试重定向到名为“.jsf”的页面,即它只是 appends 。无论结果如何,jsf。我的问题是如何返回导致当前页面刷新的结果。我的组件是通用的,我事先不知道要使用它的页面的名称。
Thanks
谢谢
回答by BalusC
Return nullinstead or just declare method void.
null改为返回或仅声明方法void。

