Ginkgochris
Ginkgochris

Reputation: 465

If JavaScript enabled submit form, else navigate to view

Is there a JSF-component which

a) acts like a h:commandLink if JavaScript is enabled and does a form submit

b) acts like a h:link if JavaScript is disabled and simply navigates to a given page?

Background: I develop a barrier-free webapplication. The form submit is a convenience function. But users with inactive JavaScript should at least navigate to the page to which the bean action of the form submit would redirect a JavaScript-enabled webbrowser.

My problem: h:commandLink does nothing if JavaScript is disabled.

Upvotes: 0

Views: 141

Answers (1)

Ginkgochris
Ginkgochris

Reputation: 465

Possible solution: Write your own CommandLink-Renderer (Mojarra: com.sun.faces.renderkit.html_basic.CommandLinkRenderer) which evaluates a href-Param and sets it as a href="JF-Outcome" instead of the href="#"

<h:commandLink value="Klick me" action="#{beanAction}">
    <f:param name="href" value="JSF-Outcome" />
</h:commandLink>

Non JavaScript users follow the link, the others post the form.

Upvotes: 0

Related Questions