Java – spring roo updates password fields or does not update all fields

I have an entity user with user name, name, etc

The user also has a password attribute I disabled its rendering in the list / display form, but in the update form, the field is set to type = "password"

What I don't know is that if you don't re-enter the password, you can't update the user, because there is no star. If you don't enter the password, the password is set to null or ""

How can I get around that?

There is another problem If I delete some fields from the update form, all other fields are set to null What I want is to enable users to update certain areas of certain rights, but not all areas

Solution

I created an entity foo with four fields F1, F2, F3 and F4

In this entity's update In jspx, I set the attribute render = "false" for field F1

In the foocontroller update method, before updating the foo parameter object, I get the old value from DB and paste it into the parameter foo, as shown below, because we don't 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 of F1 in the foo entity has not been changed after the update operation is completed

This may be a way to prevent users from updating some fields in entity objects, and hope this method is suitable for you

Cheers!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>