문제

As I read in docs and tried myself, JSF 2.0 applied bookmarkable urls to h:link and h:button elements.

Is it possible to make bookmarkable URL for h:commandLink element? I experience that f:param is not applied to the result URL of h:commandLink.

도움이 되었습니까?

해결책

h:commandLink fires a POST request, so no, it's not possible. Just use 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. You can access f:param values by @ManagedProperty.

public BeanOfTargetPage {
    @ManagedProperty(value="#{param.foo}")
    private String foo;

    @PostConstruct
    public void init() {
        // Parameter 'foo' is available here.
    }

    // ...
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top