开发者

html:options collection - No getter method available for property value

I need to create a drop down menu where I need to display 5 account numbers which comes from data base. What I'm planning to do is, set those 5 account number into a array list and then the list will be saved in a session constant. This constant needs to get from my JSP.

in my action class -

            HttpSession session = request.getSession();

            ArrayList  accts = new ArrayList();
            String acct1 = data.getAccountId1();
            String acct2 = data.getAccountId2();
            accts.add(acct1);
            accts.add(acct2);
            session.setAttribute(
                    WorkConstants.TEST1,   
                    accts);

TEST1 is defined as public string as follows : public String TEST1 = "Test1";

in my jsp I coded like this.

<td valign="top">
    1. accounts<span class="bodyCopy"><font color="#ff0000"> * </font></span>:
    <br/>
    <html:select name="MyDataForm" property="accountNumber" 
    styleClass="formContent">
        <html:options collection="<%= WorkConstants.TEST1 %>" 
        property="value" labelProperty="label" styleClass="formContent"/>
    </html:select>
    <br/>
</td>

but this doesnt work. getting error as - No getter method available for property value for bean under name Test1. Looks like my arr开发者_运维百科ay values are not getting set into TEST1. why ?


Wrap acct1 and acct2 with Strut's LabelValueBean, like this:-

ArrayList  accts = new ArrayList();

String acct1 = data.getAccountId1();
String acct2 = data.getAccountId2();

accts.add(new LabelValueBean(acct1, acct1));
accts.add(new LabelValueBean(acct2, acct2));

session.setAttribute(WorkConstants.TEST1,accts);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜