Can I create write-only field bindings in Java Server Faces?

I am creating a form in JSF to save a new bean. I bind the properties of the new object to the input elements, using the value property, for example, where the bean support is the JSF-managed average value, and newEntity is stored in the bean database, which contains a new instance of my object. For properties that are types of values ​​(for example, numbers), input fields will be populated with default values ​​(for example, 0). I want all the fields to be empty and keep a new instance of the object when the page was submitted. I believe that I could make all null properties available using types such as Integer, but the values ​​do not have a null value in the database, and it does not seem correct that the requirements of my user interface should dictate the form at the business level. Am I considering this wrong?

+3
source share
1 answer

I assume that if the fields are not null, then they are required. If you put required="true"in a field, then the check should fail before the value is assigned. This means that it will not try to assign null values ​​to your attribute. You may need to write a special validator to do this for some types of fields.

. , -1, , , . , -1 . -.

, . , -.

+1

Source: https://habr.com/ru/post/1734675/


All Articles