Spring Roo 更新密码字段或不更新所有字段
我有一个实体User
,它有用户名
、name
等...
User
也有一个密码属性。我在列表/显示表单中禁用了它的呈现,但在更新表单中,字段设置为
type="password"
。
让我烦恼的是,如果不重新输入密码,就无法更新用户,因为那里没有星星,如果不输入密码,password
将设置为 null
或 ""
。
我怎样才能绕过它?
还有一个问题。如果我从更新表单中删除某些字段,则所有其他字段都将设置为 null
。 我想要的是使用户能够更新某些实体的某些字段,但不是所有字段。
I have an entity User
that has username
, name
, etc ...
User
also has a password
property. And I disabled rendering of it in list/show forms, but in the update form, field is set to type="password"
.
What bugs me is that you can't update user without re-entering password as no stars are there, and if you don't enter the password, password
is set to null
or ""
.
How can I bypass that?
There is also another issue. If I remove some fields from update form, all other fields are set to null
.
What I want is to enable user to update some, but not all fields of some entitiy.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我创建了一个实体 Foo,其中包含四个字段 f1、f2、f3 和 f4。
在该实体的 update.jspx 中,我为字段 f1 设置了属性 render="false"。
在 FooController 更新方法中,在更新 foo 参数对象之前,我从数据库中获取旧值并将其粘贴到参数 foo 中,如下所示,因为我们不希望最终用户更新此字段。
我能够验证 Foo 实体中 f1 的旧值在更新操作完成后没有发生更改。
这可能是阻止用户更新实体对象中某些字段的一种方法,希望这种方法适合您。
干杯,
I created an entity Foo with four fields f1,f2, f3 and f4.
In update.jspx for this entity, I set the attribute render="false" for field f1.
In the FooController update method, before the foo parameter object was updated, I fetched the old value from the db and stick it in the parameter foo, as shown below, because we do not want the end user to update this field.
I am able to verify that old value for f1 in Foo entity is not getting changed after the update operation was completed.
This could be one way to prevent users from updating some fields in an entity object and hope this approach works for you.
Cheers,