Question

I wanted to display action errors on top of the grid after doing some server side validations on the values of struts 2 jQuery grid. Any help would be appreciated.

here is my action error.

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

But unfortunately ,I am unable to show error in my jsp page. Please share your knowledge regarding this issue.

Was it helpful?

Solution

Try this

Basic concept: you have to make one jsp.

Say error.jsp and on error return, just load the error.jsp.

In error.jsp write addActionError("You can not delete this data"); .

And include this error.jsp into your main grid page where you wish to show error message

OTHER TIPS

for server side validation i use json response on aftersubmit event as shown below

   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
    );

and the struts entry

         <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>

and action method

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

private String userMessage ;


public String getUserMessage() {
    return userMessage;
}

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

Let me know if this is useful

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top