user3365200
user3365200

Reputation: 2261

how to assign value dynamically to disabled attribute in spring mvc jsp

I have to disable checkbox and its associated radio buttons

Under one checkbox there are many radio buttons so i want to disable the radio button based on some flag which is coming from database

when i assign dynamic flag to its disabled property it is not working

flag value is coming as false eventhough radio button is not disabled

<form:checkbox path="lstAuthFactor" value="${authLevelFactor.key}" label="${authLevelFactor.key}" disabled="true" />
                             <ul class="verticalRadios">
<form:radiobuttons path="authChainCodes[${seq1.index}].levelId" items="${authLevelFactor.value}" itemValue="levelId" itemLabel="levelDesc" element="li" disabled="levelActive"/>

here levelactive is boolean value but that is not working

Anybody please suggest

Upvotes: 3

Views: 2427

Answers (2)

user3365200
user3365200

Reputation: 2261

I found solution after some time

<form:radiobuttons path="authChainCodes[${seq1.index}].levelId" items="${authLevelFactor.value}" itemValue="levelId" itemLabel="levelDesc" element="li"     disabled="${!authLevelFactor.value[seq1.index].levelActive}"/>

Here actually authLevelFactor.value is arraylist so i have assigned value from particular index

Thanks

Upvotes: 0

Braj
Braj

Reputation: 46871

Use JSTL & EL to set the HTML input disabled property

Sample code:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<form:checkbox path="lstAuthFactor" value="${authLevelFactor.key}" 
          label="${authLevelFactor.key}" <c:if test="${flag}">disabled</c:if>/>

Have a look at the similar posts here and here

Upvotes: 2

Related Questions