4

struts 2 jQuery グリッドの値に対してサーバー側の検証を行った後、グリッドの上にアクション エラーを表示したいと考えていました。どんな助けでも大歓迎です。

これが私のアクションエラーです。

addActionError("You can not delete this  data");

残念ながら、jsp ページにエラーを表示できません。この問題に関する知識を共有してください。

4

2 に答える 2

0

これを試して

基本的な概念:1つのjspを作成する必要があります。

error.jspと言い、エラーが戻ったら、error.jspをロードします。

error.jspに書き込み addActionError("You can not delete this data");ます。

そして、このerror.jspを、エラーメッセージを表示したいメイングリッドページに含めます。

于 2013-03-06T11:41:12.413 に答える
0

サーバー側の検証では、以下に示すように aftersubmit イベントで json 応答を使用します

   navGrid("#pager2",{}, //options
            {height:280,width:700,reloadAfterSubmit:false}, // edit options
            {height:280,width:700,reloadAfterSubmit:false, 
            afterSubmit : function(response, postdata) { 
                var msg = "noError";
                var res = $.parseJSON(response.responseText);
                if (res && res.userMessage) {
                    alert(res.userMessage);
                    msg = res.userMessage;
                }

                //alert(msg);
            if(msg == "noError") {
                return [true, "Validation pass"];
            }   else {
                return [false, msg];
            } 
            }}, // add options

            {reloadAfterSubmit:false}, // del options
            {} // search options
    );

そしてストラットエントリー

         <action name="jsontableEditValidationApartmentResource" class="com.loa.monitor.action.JsonActionResource" method="editValidate" >
    <result name="success" type = "json"></result>
    <result name="error" type="redirectAction">
            <param name="actionName">proceedApartment</param>
    </result>
</action>

とアクション方法

        public String editValidate() {
    userMessage = "test msg1";
    return "success";
}

private String userMessage ;


public String getUserMessage() {
    return userMessage;
}

public void setUserMessage(String userMessage) {
    this.userMessage = userMessage;
}

これが役立つかどうか教えてください

于 2013-03-27T10:02:56.587 に答える