Announcement Announcement Module
Collapse
No announcement yet.
Disable form component on the basis of boolean variable Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Disable form component on the basis of boolean variable

    Hi All,
    I tried different ways to do this but
    Actually I have to disable some fields in form on the basis of a boolean variable.
    class myModelClass
    {
    boolean readOnly;
    /**
    * @return the readOnly
    */
    public String getReadOnly()
    {
    return readOnly;
    }

    /**
    * @param readOnly the readOnly to set
    */
    public void setReadOnly(String readOnly)
    {
    this.readOnly = readOnly;
    }
    }
    in my jsp page I am trying to disable few form fields as below..
    <form:input path="forename" maxlength="15" disabled="${myModelClassCommandName.readOnly}"/>
    Its not working properly...

    But if I tried in this way....its working fine.
    <c:if test="${assessment.readOnly}">
    <form:input path="forename" maxlength="15" disabled="true"/>
    </c:if>
    <c:if test="${! assessment.readOnly}">
    <form:input path="forename" maxlength="15" />
    </c:if>
    If anybody can explain why it is showing different behavior ....???
    and
    What should I do if I want to use 1st approach.


    Thanks in advance...

  • #2
    Take a look at the source of the html page once its generated and see what it looks like for the first option compared to the second option. I am suspicious that it may be missing some quotes.

    Comment

    Working...
    X