Tuesday, July 9, 2013

Display Selected Values for drop down in ATG

Select Values can be displayed using JSTL or DSP tags. Will see one by one

Using JSTL:

<dsp:select id="state" name="state" bean="PersonaFormHandler.PersonalInfoInputBean.driversLicenseBean.State">

<option value="FL"<c:if test="${State == 'FL'}">selected="selected"</c:if>>Florida</option>
<option value="GA"<c:if test="${State == 'GA'}">selected="selected"</c:if>>Georgia</option>
<option value="HI"<c:if test="${State == 'HI'}">selected="selected"</c:if>>Hawaii</option>

</dsp:select>

Here, C:if checks the dynamic variable State agaist static value 'FL' and if so, selected is applied

Using ATG DSP:

<dsp:select id="state" name="state" bean="PersonaFormHandler.PersonalInfoInputBean.driversLicenseBean.State">

<dsp:option value="FL" selected="${State == 'FL'}">Florida</dsp:option>
<dsp:option value="GA" selected="${State == 'GA'}">Georgia</dsp:option>
<dsp:option value="HI" selected="${State == 'HI'}">Hawaii</dsp:option>
<dsp:option value="ID" selected="${State == 'ID'}">Idaho</dsp:option>

</dsp:select>

DSP accepts selected="true" or selected="false"   
and the equality check is handled by ${State == 'FL'}. If dynamic variable State value is equal to 'FL' then true is returned and that particular drop down is selected

No comments:

Post a Comment