I have two roles in my app, ROLE_ADMIN & ROLE_USER Also I have a form with some fields. I would like to have the following: When user has ADMIN role he is able to edit specific group of fields, when user has USER role he is not able to edit these fields. I don't want to have two different forms, or two copies of fields for every role.
I tried to do something like that:
<s:textfield key="..." disabled="${myFlag}" >, where myFlag evaluated from roles.
But I have warning "disabled" does not support runtime expressions.
Is there any way to do this? Or maybe there's better way, for example, by replacing generated input to label ?
Thanks in advance.
You should use the OGNL expression by %{expression}
syntax in a Struts2 tag.
<s:textfield disabled="%{myFlag}" />
how can I set such variable on page?
Doesn't work with %{myFlag}
? Or you could set the the variable by
<s:set var="flag">${myFlag}</s:set>
Implementation :
<s:textfield disabled="#flag" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With