How to set inputText to required without affecting output label in Primefaces?
jsf, primefaces
Solution
I would recommend using the plain JSF `<h:ouputLabel… />`
<h:outputLabel value="Target Species" for="idInputText" />
<p:inputText id="idInputText" required="true" value="#{controller.string}"/>
This removes the asterisk but keeps the label correctly associated with the input element. This is important for accessibility.
Problem
When I set an inputText to required, the the outputLabel I have associated with the inputText gets an asterisk added to it automatically. How do I prevent the asterisk from appearing? ``` <p:outputLabel value="Target Species" for="idInputText" /> <p:inputText id="idInputText" required="true" value="#{controller.string}"/> ``` I am using PrimeFaces 4.0