开发者

Struts2. How get chosen option of some comboboxes in one variable?

Using I am trying to paint on my jsp some comboboxes which must be connected with variable in my Action class. Because of amount of my comboboxes are dynamic calculated I cann't create exact amount of variables in Action class. So I was trying to apply principle of index to my comboboxes. But my Action class gets misunderstood Object value.

 <s:iterator value="question.answers" id="entry" status="status">
            <s:property value="text"/>开发者_如何学Python;
            <s:combobox list = "question.answers" listValue="rightText" listKey="rightText" name="%{'chosenComboOption['+#status.count+']'}"  emptyOption="false"/>
            <br />
        </s:iterator>

Please help me to get chosen values from my comboboxes!


A couple of things jump out at me. First of all, you don't want to use "status.count", because that returns the total number of items in the list, not the current iteration index. Instead you would want to use "status.index". Second, I think your syntax is incorrect in the index selection. Trying to do things manually like this is a sort of black magic that you have to tweak to try to get just right.

In a project that I was working on recently, I had to do something similar to this. Not sure if this exact syntax will work for you or not, but it is worth a shot. Try to change:

name="%{'chosenComboOption['+#status.count+']'}"

to this:

name="chosenComboOption[%{#status.index}]"
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜