Spring Roo update password field or do not update all fields

I have a User object that has username , name , etc.

User also has a password property. And I turned off its display in the form of a list / show, but in the update form the field is set to type="password" .

What bothers me is that you cannot update the user without re-entering the password, since there are no stars, and if you do not enter the password, password set to null or "" .

How can I get around this?

There is another problem. If I remove some fields from the update form, all other fields will be set to null . I want the user to be able to update some, but not all, fields of an element.

+4
source share
1 answer

I created a Foo object with four fields f1, f2, f3 and f4.

In update.jspx for this object, I set the render = "false" attribute for the f1 field.

In the update method of FooController , before updating the object of the parameter foo , I extracted the old value from db and bound it to the parameter foo , as shown below, because we do not want the end user to update this field.

  Foo fromDB=Foo.findFoo(foo.getId()); foo.setF1(fromDB.getF1()); foo.merge(); 

I can verify that the old value for f1 in the Foo object does not change after the update operation is complete.

This may be one of the ways to prevent users from updating some fields of the entity object and we hope that this approach will work for you.

Greetings

+1
source

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


All Articles