struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Dimitrov <soul...@gmail.com>
Subject How can I process form with custom index-like properties
Date Thu, 12 Mar 2009 14:46:23 GMT
Hello,

I'm working on complicated data generated form

<code>

<s:form action="NewOrdItm" theme="simple">
    <table>
        <tr>
            <td>name</td>
            <td>params</td>
            <td>comb1</td>
            <td>comb2</td>
            <td>comb3</td>
        </tr>

        <s:iterator value="itemColl">
            <s:if test="%{!hidden}">
                <tr>
                    <td nowrap="true">
                        <s:if test="%{formRadio}">
                            <s:radio
name="radio[%{formRadioGroupName}]" list="{item.id}"/>
                            <s:property value="item.name"/>
                        </s:if>
                        <s:elseif test="%{formCheckBox}">
                            <s:checkbox name="checkBox[%{item.id}]"
label="item.name"/>
                            <s:property value="item.name"/>
                        </s:elseif>
                        <s:else>
                            <s:property value="item.name"/>
                        </s:else>
                    </td>
                    <td>
                        <s:if test="%{int}">
                            <s:textfield name="intParam[%{item.id}]"/>
                        </s:if>
                        <s:elseif test="%{float}">
                            <s:textfield name="floatParam[%{item.id}]"/>
                        </s:elseif>
                        <s:elseif test="%{area}">
                            X:<s:textfield name="areaXParam[%{item.id}]"/>
                            Y:<s:textfield name="areaYParam[%{item.id}]"/>
                        </s:elseif>
                        <s:elseif test="%{areaCm}">
                            Col:<s:textfield name="areaColParam[%{item.id}]"/>
                            h:<s:textfield name="areaMmParam[%{item.id}]"/>
                        </s:elseif>
                        <s:else>
                            &nbsp;
                        </s:else>
                    </td>
                    <td>
                        <s:if test="%{item.comb1 != null}">
                            <s:property value="item.comb1.name"/>:
                            <s:select name="comb1[%{item.id}]"
list="item.comb1.items" listKey="id" listValue="name" />
                        </s:if>
                        <s:else>
                            &nbsp;
                        </s:else>
                    </td>
                    <td>
                        <s:if test="%{item.comb2 != null}">
                            <s:property value="item.comb2.name"/>:
                            <s:select name="comb2[%{item.id}]"
list="item.comb2.items" listKey="id" listValue="name" />
                        </s:if>
                        <s:else>
                            &nbsp;
                        </s:else>
                    </td>
                    <td>
                        <s:if test="%{item.comb3 != null}">
                            <s:property value="item.comb3.name"/>:
                            <s:select name="comb3[%{item.id}]"
list="item.comb3.items" listKey="id" listValue="name" />
                        </s:if>
                        <s:else>
                            &nbsp;
                        </s:else>
                    </td>
                </tr>
            </s:if>
        </s:iterator>
    </table>
    <s:submit value="Create"/>
</s:form>

</code>

I have defined getters and setters with additional parameter on the
receiving action class:

<code>

public class OrdItm extends ActionSupport implements ParameterAware {
...
    public int getRadio(String radioGroupName) {
...
    }

    public void setRadio(String radioGroupName, int value) {
...
    }

    public boolean getCheckBox(int id) {
...
    }

    public void setCheckBox(int id, boolean value) {
...
    }
}

</code>

Too bad that none of the getters/setters are called when form is posted

I included parametersAware interceptor to see what I receive from post
Here is list the list of received values

<code>

key=checkBox[226] value=[true]
key=checkBox[223] value=[false]
key=itemDate value=[]
key=checkBox[221] value=[false]
key=checkBox[222] value=[true]
key=comb2[212] value=[100]
key=areaMmParam[212] value=[]
key=areaMmParam[211] value=[]
key=checkBox[225] value=[false]
key=checkBox[224] value=[true]
key=areaMmParam[210] value=[25]
key=areaColParam[211] value=[]
key=comb1[211] value=[400]
key=itemText value=[]
key=comb1[212] value=[400]
key=radio[RG201] value=[210]
key=comb1[210] value=[401]
key=areaColParam[212] value=[]
key=areaColParam[210] value=[1]

</code>


Thanks in advance for your help

Regards,
Alexander

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message