Struts: best practice working with disabled fields

P

Per Jensen

Group,

I have a web application where some fields on a jsp page are disabled for some
users.

Say user 'admin' has set a bean property to true on a jsp page and
and user 'joe' now edits a page displaying this particular Boolean
property. (Fill in the copying of bean properties to form properties
yourself).

The disabled="true" is on for user joe in the Struts tag because he has
read-only access to the field, so when the form is submitted and
BeanUtils.copyproperties(bean, form) is used, the
Boolean value represented by the checkmark is set to null. This is
because the form has no value for the checkmark because it was disabled.

This is obviously not correct, as user 'joe' had read-only access to the
field.

One solution is to handcode the bean.setter(form.getter), writing logic
which takes into account a user's role.

I wonder what the best practice is in this situation. Pointers and good
advice much appreciated.

Regards,
Per
 
T

Tobias Schierge

Hi,
I have a web application where some fields on a jsp page are disabled for some
users.

for not loosing these properties add a second hidden field with the same
value to the form.


Regards,

Tobias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top