0

I'm working on a JSF project using PrimeFaces and I have some custom components to facilitate the work. One of them is a search component that is formed for a input text with a button that opens a dialog. In the dialog I have a data table that lists some data. When the user chooses some record, the input text is updated with this record and the the managedbean is updated too. To avoid curious users, that could change the value of the input text, I set this field to readonly, but the field is required. The problem arises when the user does not select a value in the datatable and the input field remains empty. In this case, JSF doesn't validate readonly fields, and my validation rules are broken when the user doesn't provide no value.

Is there a way to validate readonly fields when I submit the form?

Thanks.

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
Humberto Corrêa
  • 789
  • 1
  • 6
  • 17

1 Answers1

0

Although I marked it as a duplicate (which is the correct response to the question), Some alternatives/workarounds can be created

  • Force the user to select something in the datatable
  • Disable the submit button if no value was choosen in the datatable
  • Do a programmatic validation in the business method that return a message if the validation fails.
Kukeltje
  • 12,223
  • 4
  • 24
  • 47