Reputation: 7403
Working with a struts 1 project, I'm trying to save myself hours of coding by using the output value of a JSTL tag to set the disabled property of some input boxes on a JSP page. unfortunately the following doesn't work:
<html:text property="name" size="15" maxlength="50" disabled="${not empty empRights}"/>
or
<html:text property="name" size="15" maxlength="50" disabled='<c:out value = "${not empty empRights}" />' />`
where empRights can only have true or false values. Is there anyway to achieve this? Thanks
Upvotes: 1
Views: 674
Reputation: 160211
There are many ways to achieve it. (None of which include arbitrary nesting of custom tags, which is never legal.)
If empRights
can only be true
or false
, checking it for empty seems weird. The easiest would be to set a value based on it, but you need it to be "disabled"
or ""
(empty), not "true"
/"false"
. Easiest is to use a ternary (assuming JSP 2.0+ container):
${empRights ? 'disabled' : ''}
(Or the opposite; not sure what you were trying to achieve via empty
.)
Alternatively, set another variable and use that instead.
Upvotes: 2