Question

I am using a dropdown optionCollection to select the set of values.

<html:select property="cddSourceOfFunds" styleId="cddSourceOfFunds" styleClass="selectDefault" onchange="return mtmrsValRequiredselect(this.id,'selectDefault','selectDefault errorBdr','errorSpan1','0')">
                        <logic:present name="sourceOfFundsList" scope="request">
                            <html:option value="0">
                                <bean:message key="mtmrs.validation.select" />
                            </html:option>
                            <html:optionsCollection name="sourceOfFundsList" label="value"
                                value="value" />
                        </logic:present>
                        <logic:notPresent name="sourceOfFundsList" scope="request">
                            <html:option value="0">
                                <bean:message key="mtmrs.validation.select" />
                            </html:option>
                        </logic:notPresent>

I set the value of cddSourceOfFunds form the action form and return to jsp. But the dropdown still shows no sent data.. ie 'select' as default . However, i can write the property value in the form using

<bean:write name = "/remittanceTransactionCdd" property ="cddSourceOfFunds" />

I want the dropdown to show the value i set from action method as default in dropdown when it loads.The property value is in the form. But cannot display in the dropdown. How shall i make it happen. Help Appreciated.

Was it helpful?

Solution

Since you are using logic iterate to load the items in the list box, you are facing the issue Options 1. using jquery or javascript on load set the value of the list box accessing the form data using jstl which will be available in the request scope 2. or instead of iterating over the list using logic iterator use html:options http://www.coderanch.com/t/57329/Struts/populate-html-select-options-struts

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top