0

我正在使用 Spring MVC。我的命令对象包含一个集合对象,如下所示:

public class DimensionStoneBean {

    int stoneNo;
    float length;
    float breadth;
    float height;
    float dimension;
    String isIssued;

    public int getStoneNo() {
        return stoneNo;
    }
    public void setStoneNo(int stoneNo) {
        this.stoneNo = stoneNo;
    }
    public float getLength() {
        return length;
    }
    public void setLength(float length) {
        this.length = length;
    }
    public float getBreadth() {
        return breadth;
    }
    public void setBreadth(float breadth) {
        this.breadth = breadth;
    }
    public float getHeight() {
        return height;
    }
    public void setHeight(float height) {
        this.height = height;
    }
    public float getDimension() {
        return dimension;
    }
    public void setDimension(float dimension) {
        this.dimension = dimension;
    }
    public String getIsIssued() {
        return isIssued;
    }
    public void setIsIssued(String isIssued) {
        this.isIssued = isIssued;
    }

}


public class UpdateStockBean {

    @SuppressWarnings("rawtypes")
    private List dimensionStones =
        LazyList.decorate(new LinkedList(),FactoryUtils.instantiateFactory(DimensionStoneBean.class));
    long openbalance;

    public UpdateStockBean() {
        super();
    }

    @SuppressWarnings("rawtypes")
    public List getDimensionStones() {
        return dimensionStones;
    }
    public void setDimensionStones(@SuppressWarnings("rawtypes") List dimensionStones) {
        this.dimensionStones = dimensionStones;
    }
    public long getOpenbalance() {
        return openbalance;
    }
    public void setOpenbalance(long openbalance) {
        this.openbalance = openbalance;
    }

}

用于此的控制器类 extends AbstractWizardFormController

我习惯于formBackingObject()填充命令对象,将其返回到表单中。

表格如下所示:

<form:form commandName="updateStock" method="post" name="stockEntry" action="updateStock.nic" id="updateStock">
    <br><br><br>

    <table border="1" width="700">
        <tr>     
            <td class="textClr1" align="left" width="50"><nobr>Total No Of Stones</nobr></td>
            <td colspan="6"><form:input tabindex="1" path="openbalance" id="openbalance" cssClass="controlStock"/></td>
        </tr>    

        <tr>
            <td></td>
            <td colspan="6"><form:errors cssClass="error" path="openbalance"/></td>
        </tr> 
    </table>

    <table>
        <tr>
            <td colspan="3">

            <table  border="1" width="400">
                <tbody id="dimensionList">                           
                    <c:forEach  var="DimensionStones" items="${updateStock.dimensionStones}" varStatus="i" begin="0">

                    <tr class="dimensionStone">    
                        <td><form:input path="dimensionStones[${i.index}].stoneNo" id="stoneNo${i.index}" cssClass="controlStock"/></td>
                        <td><form:input path="dimensionStones[${i.index}].length" id="length${i.index}" onchange="findDimension(this.id)" cssClass="controlStock"/></td>
                        <td><form:input path="dimensionStones[${i.index}].breadth" id="breadth${i.index}" onchange="findDimension(this.id)" cssClass="controlStock"/></td>
                        <td><form:input path="dimensionStones[${i.index}].height" id="height${i.index}" onchange="findDimension(this.id)" cssClass="controlStock"/></td>
                        <td><form:input path="dimensionStones[${i.index}].dimension" id="dimension${i.index}" cssClass="controlStock"/></td>                 
                        <td><form:checkbox path="dimensionStones[${i.index}].isIssued" id="isIssued${i.index}" value="" cssClass="check"/></td>
                        <td><a href="#" class="removeDimensionStone"><img src="images/cross1.jpg" width="20" height="20" title="Remove Dimension Stone"/></a></td>
                    </tr>

                    </c:forEach>   

                <tr></tr>             

                <c:if test="${empty updateStock.dimensionStones}">

                    <tr class="dimensionStone defaultRow">    
                        <td><input type="text" name="dimensionStones[].stoneNo" value="" id="stoneNo" Class="controlStock"/></td>
                        <td><input type="text" name="dimensionStones[].length" value="" id="length" onchange="findDimension(this.id)" Class="controlStock"/></td>
                        <td><input type="text" name="dimensionStones[].breadth" value="" id="breadth" onchange="findDimension(this.id)" Class="controlStock"/></td>
                        <td><input type="text" name="dimensionStones[].height" value="" id="height" onchange="findDimension(this.id)" Class="controlStock"/></td>
                        <td><input type="text" name="dimensionStones[].dimension" value="" id="dimension" disabled="disabled" Class="controlStock"/></td>                            
                        <td><input type="checkbox" name="dimensionStones[].isIssued" value="Yes" id="isIssued" Class="controlStock"/></td> 
                        <td><a href="#" class="removeDimensionStone"><img src="images/cross1.jpg" width="20" height="20" title="Remove Dimension Stone"/></a></td>
                    </tr>

                </c:if>   

                </tbody>  
            </table>           

            </td>    
        </tr>    
    </table>

    <table  border="1" width="600"> 
        <tr>
            <td colspan="3" align="left"><a href="#" id="addDimensionStone"><img src="images/plus3.png" width="20" height="20" title="Add Dimension Stone"/></a></td>
        </tr> 
        <tr></tr> 
        <tr></tr> 
        <tr>
            <td colspan="3" align="center" width="200" height="180">
                <input type="submit" name="_target0" value="Submit" class="butn" />
            </td>
        </tr>  
    </table>  
</form:form>

在上面的表格中,我可以删除或清除列表中的项目updateStock.dimensionStones吗?如果有可能,JSTL请尽快给我答案。ELscriptlet

4

1 回答 1

0

您可以像这样调用控制器并在该控制器中编写代码以删除列表。

<a href="clearstock.so?id=${DimensionStones.id} 
于 2013-03-12T08:48:43.513 回答