1

I'm trying to create a form compliant to XHTML 1.1 with JSF, but can't. This is my .xhtml file:

<h:form>
  <h:inputText value="foo"/>
  <h:commandButton action="search" value="Search" />
</h:form>

In the output HTML <input> tags are not enclosed in <div> or <dd> or something similar, as they should be in XHTML 1.1. Is there any legal workaround? I don't like the idea of adding these tags explicitly to .xhtml file.

yegor256
  • 102,010
  • 123
  • 446
  • 597

1 Answers1

2

Just add those block elements yourself?

<h:form>
  <p><h:inputText value="foo"/></p>
  <p><h:commandButton action="search" value="Search" /></p>
</h:form>

Note that JSF will never render 100% valid XHTML 1.1. Use XHTML 1.0 Transitional or HTML5.

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Such a pity... Thanks for the answer. – yegor256 Mar 01 '11 at 12:14
  • It's only a pity for ones who worships w3 and forget that browser hacks are sometimes simply mandatory. – BalusC Mar 01 '11 at 12:18
  • I did what you suggested, but now I'm getting `` right after `
    ` element, before my first `

    `.. Any ideas?

    – yegor256 Mar 01 '11 at 14:39
  • As said, JSF will never render 100% valid XHTML 1.1. JSF is on paper specified to render XHTML 1.0 Transitional. If you want XHTML 1.1, you need to create/extend/override a custom XHTML 1.1 renderer for components which need it (`HtmlForm` and so on). Or just use a HTML5 doctype. Feeding browsers a `text/html` response with a XHTML doctype makes IMO no sense. – BalusC Mar 01 '11 at 14:48