sergionni
sergionni

Reputation: 13510

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.

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.

Upvotes: 1

Views: 784

Answers (1)

BalusC
BalusC

Reputation: 1108642

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.
    }

    // ...
}

Upvotes: 4

Related Questions