2015-02-10 58 views
0

我需要使用@SessionScope使清單在刷新後留在頁面中,但是當我使用它時,Stripes:錯誤不再顯示。 Stripes:實際上運行錯誤(因爲我看不到任何事情會發生),但它只是不再顯示頁面中的錯誤消息。我確信@SessionScope有一些東西,因爲當我運行代碼時沒有顯示頁面中顯示的所有錯誤。 任何想法如何解決這個問題?條紋@SessionScope隱藏條紋:錯誤

注意:我也嘗試使用@Wizard(startEvents =「event」),它可以讓錯誤顯示,但是不會對保存頁面中的列表做任何事情!

的Java

@SessionScope 
@UrlBinding("/Student/import.action") 
public class ImportAction implements ActionBean { 
    private String userCheckBox; 
    public Resolution importStudents() throws IOException { 
     if (userCheckBox == null) { 
         this.getContext().getValidationErrors().add("userCheckBox",new SimpleError(error)); 
      } 
    return new RedirectResolution("import.action"); 
} 
public String getUserCheckBox() { 
    return userCheckBox; 
} 
public void setUserCheckBox(String userCheckBox) { 
    this.userCheckBox = userCheckBox; 
} 
} 

JSP

<stripes:checkbox name="userCheckBox"/> 
<stripes:errors field="userCheckBox"/> 
<stripes:submit name="importStudents" value="Import"/> 
+0

不應該在userCheckBox上使用@Validate,以便您不必執行手動錯誤檢查? – lumpynose 2015-02-11 06:35:33

回答

0

我不知道這是正確的方式來做到這一點,但不是使用@SessionScope怎麼樣通過直接在會話存儲列表你的子類ActionBeanContext?例如,我的

public class IlmpActionBeanContext extends ActionBeanContext { 
private static final String REQUEST_TOKEN = "request_token"; 

public Token getRequestToken() { 
    return (Token) this.getRequest().getSession() 
     .getAttribute(IlmpActionBeanContext.REQUEST_TOKEN); 
} 

public void setRequestToken(final Token requestToken) { 
    this.getRequest() 
    .getSession() 
    .setAttribute(IlmpActionBeanContext.REQUEST_TOKEN, requestToken); 
}