2013-02-13 239 views
0

我已經成功實現了AutoPopulatingList。我有一個JavaScript遞增ID和背景春天正在創建我的漂亮列表。從AutoPopulatingList中刪除項目

我遇到了一些問題,刪除項目順便說一句。我正在使用嚮導控制器,並試圖「回去」並刪除一些項目。然後,前進......驚喜!物品還在那裏!

那麼,我該如何強制Spring每次創建一個新的AutoPopulatingList?或者我錯過了什麼?

這是我的名單與工廠:

private AutoPopulatingList<Event> events = new AutoPopulatingList<Event>(new EventElementFactory()); 

public class EventElementFactory implements ElementFactory { 
    @Override 
    public Event createElement(int index) throws ElementInstantiationException {    
     Event e = new Event(); 
     e.setModContr(""); 
     e.setDesc("");   
     return e; 
    } 
} 

,我已經這個initBinder控制器(不知道爲什麼,但它並非沒有工作):

binder.setAutoGrowNestedPaths(false); 

謝謝!

回答

1

最後,我已經解決了這個辦法:

在我的JSP我已在我的控制器上的隱藏字段

<input name="_clearEventList" type="hidden" value="true" /> 

protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { 
    if(Boolean.valueOf(request.getParameter("_clearEventList"))) { 
     ((MyForm)binder.getTarget()).getEvents().clear(); 
    } 
    binder.setAutoGrowNestedPaths(false); 
} 

所以這將清零我的列表就是從該頁面前進(或後退),並迫使Spring重新填充它。 :)