I am using p:inputText
and the size
attribute does not effectively limit the number of allowed characters in the field:
<p:inputText id="limitedField" title="Limited Field"
size="16" required="true"
styleClass="plainInput"
value="#{entity.limitedField}" />
First of all, the user is physically allowed to enter more 16 characters. Secondly, when they do, instead of a graceful message displayed to the user in the front end they entered an invalid value, which should be a provision of the JSF framework error, they get a generic exception:
Caused by: java.sql.SQLException: ORA-12899: value too large for column "MYSCHEMA"."MY_TABLE"."LIMITED_FIELD" (actual: 22, maximum: 16)
I looked into the generated HTML and there is indeed a size attribute given to the text input but it is not effective:
<input id="..." name="limitedField" type="text" size="16" title="Limited Field"" aria-required="true" class="..." />
I thought simply setting the size attribute would prevent invalidly sized data to even be attempted to be written in the DB but apparently not. How do I fix this?