I Want to get selected checkbox value from checkbox Key property on Action Class as List.

My code look like this

<s:form action="SearchEmail">
    <s:iterator value="ls">
        <s:checkbox name="chk"  key="number" />
    </s:iterator>

    <s:submit value="Go"/>
</s:form>

<s:iterator value="ls" status="stat">
    <s:checkbox name="chk[%{#stat.index}]"  key="number" /> 
    <%-- <s:property value="number"/> --%>
</s:iterator>   

The output is:

Value of CheckBox:{0=true, 1=false, 2=true}

But I need value in String format I don't need Index I need Value of Key property of Checkbox. I want to get the value of Selected Property.

2

There are 2 answers

0
Amrit Singh On

 <s:property value="number"/>

 <s:checkbox  fieldValue="%{number}" name="chk" key="number">  </s:checkbox>  <!-- key="number" -->

</s:iterator>   

wow it's working with above code.Something Magic. Thank every one to letting me resolve it on my own.

0
gani On

here 'var' attribute makes the sense

<s:iterator value="ls" var="val">

<s:checkbox name="%{val}" id="%{val}"  label="%{val}"></s:checkbox>

</s:iterator>