سؤال

i have a jsp page with struts2 jquery grid. I want to show errors in the jsp page from my action class. To show error i am adding error messsage using

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

code in my action class. And to display it i am using

<s:if test="hasActionErrors()">
   <div class="errors">
       <s:actionerror/>
    </div>
 </s:if>

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

-Thank you Ashutosh

Full Code:

index.jsp:

.....
.....

    <body>  

    <s:if test="hasActionErrors()">
               <div class="errors">
                  <s:actionerror/>
               </div>
            </s:if>

        <div id="setpage"> <s:url id="editurl" action="nedit"/>
            <s:url id="editurl" action="nedit"/>
            <s:url  id="remoteurl" action="ntable"/>  

            <sjg:grid
               id="gridtable"
                caption="List of Subject Details"
                dataType="json"
                href="%{remoteurl}"
                pager="true"
                gridModel="gridModel"
                rowList="50,100,5000"
                rowNum="20"
 .....
 ...... 

My action.java

                  .........
                  .........
                  else
               {
                   addActionMessage("Unable to delete row");
                      return ERROR;
               }  
               return SUCCESS;
                   .........
                   .........

struts.xml

                 <package name="gridedition" extends="struts-default,json-default"> 
                            <action name="editionntableshow" class="v.esoft.actions.actionfile" >
                                <result name="success" type="json"/> 
                                                         <result name="error" type="json"/> 
                            </action>  

                       <action name="editionedit" class="v.esoft.actions.editiondetails.EditiondetailsEditAction"> 
                            <result name="success" type="json"></result>          
                        </action>
                 </package>
هل كانت مفيدة؟

المحلول

This solved my problem...

<s:if test="hasActionErrors()">
  <div class="errors">
   <s:actionerror theme="jquery"/>
   </div>
 </s:if>

نصائح أخرى

jqGrid submit the delete row action by ajax, while those hasActionErrors are not ajax operations so they cannot be caught. In order to catch these action error/messages, that should not be a ajax/json action.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top