简体   繁体   English

将可收藏的URL应用于h:commandLink

[英]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:linkh: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.

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