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
There are many ways to achieve it. (None of which include arbitrary nesting of custom tags, which is never legal.)
If
empRightscan only betrueorfalse, 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):(Or the opposite; not sure what you were trying to achieve via
empty.)Alternatively, set another variable and use that instead.