1

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.

Leah
  • 43
  • 6
  • What kind of disabilities? I'm no expert in this area, but from what I read 'ARIA' specs work perfectly for browsers with Javascript **enabled**. – Kukeltje Aug 24 '18 at 08:40
  • Blind/visually impared people tends to disable JS because there are so many websites with JS that are a hindrance to the screen reader – Leah Aug 24 '18 at 08:46
  • Hmmmm... Are you sure that sites that have js which hinders the screen reader work at all if js is disabled. I'd personally think they would not. So the net result of disabling javascript is null. But then again, I only use PrimeFaces with fairly good ARIA support and JS (and never got the request to make the site fully functional with javascript disabled). – Kukeltje Aug 24 '18 at 08:56
  • Well, I' m not disabled myself so I 'm not really sure but it's part of my specification that disabling JS must not hinder any action.....T_T Well using p:commandButton is pretty much the same. The button becomes useless when JS in desactivated. – Leah Aug 24 '18 at 09:17
  • 99.9% of serious webframeworks become useless when javascript is disabled. -> 99.9% of web applications become useless. And since the ARIA specs do require javascript to be disabled, I'd think that there is no reason to disable it. The button is just the fist thing, if you'd like to make a FULL application that is both userfriendly to a non-disabled user and the disabled user where the latter is **not** using javascript, is almost like developping two applications (which might be easier in the end anyway) – Kukeltje Aug 24 '18 at 09:37
  • I found a library similar to primefaces who has a button that works for me. But thank you for thinking about it ^ ^ – Leah Aug 24 '18 at 10:19
  • Good luck with your endeavor. CommandButton is 'simple'. rest of the application won't be... But I admire the effort – Kukeltje Aug 24 '18 at 10:22

1 Answers1

1

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

Leah
  • 43
  • 6