[英]Apply bookmarkable URL to h:commandLink
As I read in docs and tried myself, JSF 2.0 applied bookmarkable urls to h:link
and h:button
elements. 当我在文档中阅读并尝试自己时,JSF 2.0将可收藏的URL应用于
h:link
和h:button
元素。
Is it possible to make bookmarkable URL for h:commandLink
element? 是否可以为
h:commandLink
元素创建可收藏的URL? I experience that f:param
is not applied to the result URL of h:commandLink
. 我体验到
f:param
不会应用于h:commandLink
的结果URL。
h:commandLink
fires a POST request, so no, it's not possible. h:commandLink
触发POST请求,所以不,这是不可能的。 Just use h:link
. 只需使用
h:link
。
If the sole reason of using h:commandLink
is that you'd like to fire a bean action method, then just move that to the bean constructor or @PostConstruct
of a request scoped bean which is attachted to the view which is opened by h:link
. 如果使用
h:commandLink
的唯一原因是你想要触发一个bean动作方法,那么只需将它移动到一个请求范围的bean的bean构造函数或@PostConstruct
,该bean附加到由h:link
打开的视图h:link
。 You can access f:param
values by @ManagedProperty
. 您可以通过
@ManagedProperty
访问f:param
值。
public BeanOfTargetPage {
@ManagedProperty(value="#{param.foo}")
private String foo;
@PostConstruct
public void init() {
// Parameter 'foo' is available here.
}
// ...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.