jspstrutsscriptlet

How to use a Scriptlet variable in an attribute of a Struts tag?


the listBean is already fill with data this is what i want to achieve :

<html:checkbox name="listBean" 
        property="checked" indexed="true" 
        disabled="listBean[i].disabled" />

this what i have tried :

    <bean:define id="disabledVal" name="listBean" property="disabled"/>
    <html:checkbox name="listBean" 
    property="checked" indexed="true" 
    disabled="<%=disabledVal%>" />

this code throws me a jsp error :

BWEB004062: Unable to compile class for JSP: JBWEB004060: An error occurred at line ### : 119 in the jsp file: .jsp The method setDisabled(boolean) in the type BaseHandlerTag is not applicable for the arguments (Object) 116: codeFonctionnalite="<%= NAME %>"> 117: 118: 119: 122: JBWEB004060: An error occurred at line: 136 in the jsp file: .jsp The method setDisabled(boolean) in the type BaseHandlerTag is not applicable for the arguments (Object) 133: 135: 136: 138: 139: JBWEB004211: Stacktrace:'**


Solution

  • using EL Rather than scriptlet working fine use this ${disabledVal} and not <%=disabledVal%> :

    <bean:define id="disabledVal" name="listBean" property="disabled"/>
    <html:checkbox name="listBean" property="checked" indexed="true" 
    disabled="${disabledVal}" />