4

On JBoss AS 7.1.1 using Moharra JSF 2, an XHTML file created with an inputText element will not render the attribute required="true".

No errors but the output HTML does not contain the required attribute. If writing pure HTML input element the required attribute renders as part of the JSF form. Anyone know why this attribute would be stripped out? The case is a container managed login form so there is no backing bean. Many thanks in advance.

praseodym
  • 2,134
  • 15
  • 29
Darrell Teague
  • 4,132
  • 1
  • 26
  • 38

1 Answers1

7

That's expected behavior, that attribute is not for the HTML input tag, but for the required attribute of the UIInput component that stays on the server side.

See these related questions:

Community
  • 1
  • 1
Elias Dorneles
  • 22,556
  • 11
  • 85
  • 107
  • 1
    I read the posting from the link (thank you). I am being required to use JSF on this project for supportability reasons but I struggle to understand how JSF is better/faster/cheaper when a simple 'required' attribute of an HTML5-compliant component has to be re-engineered with custom-coded renders to get back to `required="true"` and all of the HTML-5 benefits that are provided out of the box such as client-side instant validation and prompting. Anyway, `answered=yes` (oh wait ... that is a custom attribute)... – Darrell Teague Jan 15 '13 at 16:13
  • 1
    @DarrellTeague Yeah, well, I assure you I often have the same doubts myself, JSF can be a pain sometimes. Especially for things that you know it would be ridiculously simple to do if you had more control over the HTML output. Anyway, it's certainly not a case of being better, faster nor cheaper: there is always a tradeoff. We have to find out what is it that we are trading. :) – Elias Dorneles Jan 15 '13 at 18:09
  • Very old post but in retrospect after several JSF projects (not my design choice) ... the jury from my teams and myself is to avoid JSF at all costs. It had good intentions but it is clear the framework created more problems than it solves. Better to do front-end with tools like Angular and logic on server (in Java without JSF). Transliteration from JSON (using schema) model data to presentation is then purely relegated to front-end. – Darrell Teague May 29 '20 at 18:00
  • 1
    @DarrellTeague Yes, I agree! Browsers have evolved a lot in the recent years, JSF is not able to keep up with the quick pace of that and the frontend tech ecossytem. Funny, I was revisiting this post not long ago precisely to read our discussion in the comments. :) Good luck with your next projects! – Elias Dorneles May 29 '20 at 19:20