Search code examples
javascriptajaxjsfprogressive-enhancementgraceful-degradation

Full page reaload for ajax when Javascript is disabled


I'm using JSF2.

I have a button that calls an action and then render a part of the page ( pretty basic)

 <h:commandButton value="foo" action="#{myBean.myAction}" >
              <f:ajax execute="@form" render="#content" />
  </h:commandButton>

The site needs to be usable by people with disabilities so I need to support browsing when JavaScript is disabled.

For me the best solution would be that the page is fully reloaded when JS is disabled.

I thought of setting a cookie on the first page load saying whether js is here or not and then using rendered="someBeanThatReadsCookies" to display an ajaxed button if js is here and a normal button if not but I find this solution slightly ugly.

If anyone had a more elegant solution I would be glad.

I know problem is pretty similar to this issue Ajax fallback when Javascript is disabled

However I don't find the given answer satisfying. I'm already using commandButtons and disabling JS just make the button do nothing.


Solution

  • For anyone interested, the library Bootsfaces offers exactly the behaviour I was looking for.

     <b:container id="update-me" > 
           <b:commandButton value="button" ajax="true" update="update-me" action="#{barreOutilsControleur.fontSizePlus}"  >
           </b:commandButton>
     </b:container>
    

    It reloads the page when JS is disabled ^^.