jquery grid results in "Could not find action or result" in struts2 when data is present

116 views Asked by At

I was having working project but after upgrading java, tomcat and few libraries one of inner jquery-grid stopped working. (yes, outer one "jsonPatientAppointments" is still working) If there is no data in that case it is not throwing any error but if data is present in that case struts2 action is throwing "Could not find action or result".

My action class is

   @ParentPackage(value = "patient")
 public class JsonAppointmentHistoryAction extends ActionSupport implements 
 SessionAware
{

private static final long   serialVersionUID    = 5078263227068533593L;
private static final Logger log = Logger.getLogger(JsonAppointmentHistoryAction.class);
private List<PatientAppointmentBkp>      gridModel;
private List<PatientAppointmentBkp>      refPatientAppointments;
private Integer             rows             = 0;
private Integer             page             = 0;
private Integer             total            = 0;
private Integer             record           = 0;
private String              sord;
private String              sidx;
private String              searchField;
private String              searchString;
private String              searchOper;
private boolean             loadonce         = false;
private Map<String, Object> session;
private int appointmentNo;


private int id;

    @Actions({
      @Action(value = "/jsonAppointmentHistory", results = {
    @Result(name = "success", type = "json")
      })
    })
    public String execute(){
          log.warn("Page " + getPage()+" Rows " + getRows() +" Sorting Order "+ getSord()+" Index Row :" + getSidx());
        log.warn("Search :" + searchField + " " + searchOper + " " + searchString);

          log.debug("Build new List");
          refPatientAppointments = getAppointmentHisotoryList();
setRecord(PatientAppointmentHisDao.getPatientAppointmentHisCount(refPatientAppointments));

        int to = (getRows() * getPage());
        int from = to - getRows();
        to=to-1;
        if (to > getRecord()) to = getRecord();
        log.warn("from ==="+from +"  to====="+to);
        if (loadonce)
        {
          setGridModel(refPatientAppointments);
        }
        else
        {
            setGridModel(PatientAppointmentHisDao.getPatientAppointmentHis(refPatientAppointments, from, to));

        }

        setTotal((int) Math.ceil((double) getRecord() / (double) getRows()));



        return SUCCESS;
    }

    public List<PatientAppointmentBkp> getRefPatientAppointments() {
        return refPatientAppointments;
    }

    public void setRefPatientAppointments(
            List<PatientAppointmentBkp> refPatientAppointments) {
        this.refPatientAppointments = refPatientAppointments;
    }

    public String getJSON()
      {
        return execute();
      }

      /**
       * @return how many rows we want to have into the grid
       */
      public Integer getRows()
      {
        return rows;
      }

      /**
       * @param rows
       *          how many rows we want to have into the grid
       */
      public void setRows(Integer rows)
      {
        this.rows = rows;
      }

      /**
       * @return current page of the query
       */
      public Integer getPage()
      {
        return page;
      }

      /**
       * @param page
       *          current page of the query
       */
      public void setPage(Integer page)
      {
        this.page = page;
      }

      /**
       * @return total pages for the query
       */
      public Integer getTotal()
      {
        return total;
      }

      /**
       * @param total
       *          total pages for the query
       */
      public void setTotal(Integer total)
      {
        this.total = total;
      }

      /**
       * @return total number of records for the query. e.g. select count(*) from
       *         table
       */
      public Integer getRecord()
      {
        return record;
      }

      /**
       * @param record
       *          total number of records for the query. e.g. select count(*) from
       *          table
       */
      public void setRecord(Integer record)
      {

        this.record = record;

        if (this.record > 0 && this.rows > 0)
        {
          this.total = (int) Math.ceil((double) this.record / (double) this.rows);
        }
        else
        {
          this.total = 0;
        }
      }

      /**
       * @return an collection that contains the actual data
       */
      public List<PatientAppointmentBkp> getGridModel()
      {
        return gridModel;
      }

      /**
       * @param gridModel
       *          an collection that contains the actual data
       */
      public void setGridModel(List<PatientAppointmentBkp> gridModel)
      {
        this.gridModel = gridModel;
      }

      /**
       * @return sorting order
       */
      public String getSord()
      {
        return sord;
      }

      /**
       * @param sord
       *          sorting order
       */
      public void setSord(String sord)
      {
        this.sord = sord;
      }

      /**
       * @return get index row - i.e. user click to sort.
       */
      public String getSidx()
      {
        return sidx;
      }

      /**
       * @param sidx
       *          get index row - i.e. user click to sort.
       */
      public void setSidx(String sidx)
      {
        this.sidx = sidx;
      }

      public void setSearchField(String searchField)
      {
        this.searchField = searchField;
      }

      public void setSearchString(String searchString)
      {
        this.searchString = searchString;
      }

      public void setSearchOper(String searchOper)
      {
        this.searchOper = searchOper;
      }

      public void setLoadonce(boolean loadonce)
      {
        this.loadonce = loadonce;
      }

      public void setSession(Map<String, Object> session)
      {
        this.session = session;
      }



    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getAppointmentNo() {
        return appointmentNo;
    }

    public void setAppointmentNo(int appointmentNo) {
        this.appointmentNo = appointmentNo;
    }

    private List<PatientAppointmentBkp> getAppointmentHisotoryList(){
        List<PatientAppointment> refAppRecords = new ArrayList<PatientAppointment>();
        PatientAppointment app = new PatientAppointment();
        if (refPatientAppointments == null){
            refPatientAppointments = new ArrayList<PatientAppointmentBkp>();
        }
        Object list = session.get("myApplist");
        int myPage = (int) session.get("myAppPage");
        int myRows = (int) session.get("myAppRows");
        if (list != null)
        {
            refAppRecords = (List<PatientAppointment>) list;
            app = refAppRecords.get(((myRows*(myPage-1))+id)-1);
        }

        refPatientAppointments = PatientAppointmentHisDao.buildAppList(app.getAppointNo());
        return refPatientAppointments;
    }

    public String getSearchField() {
        return searchField;
    }

    public String getSearchString() {
        return searchString;
    }

    public String getSearchOper() {
        return searchOper;
    }

    public boolean isLoadonce() {
        return loadonce;
    }


}

JSP Code

<%@ taglib uri="/struts-tags" prefix="s" %>
<%@ taglib uri="/struts-jquery-tags" prefix="sj" %>
<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags"%>

<link href="/HospitalCare/css/style.css" rel="stylesheet" type="text/css">
<link href="/HospitalCare/css/menu.css" rel="stylesheet" type="text/css">

<div align="center">
<s:url id="remoteurl" action="jsonPatientAppointments">
<s:param name="patientId" value="%{patientId}"></s:param>
</s:url>
<s:url id="appointdetailsurl" action="jsonAppointmentHistory" />
<s:url id="editurl" action="edit-grid-entry"/>

<sjg:grid
    id="appointmentNo"
    caption="Appointment Records"
    dataType="json"
    href="%{remoteurl}"
    pager="true"
    gridModel="gridModel"
    navigatorView="true"
    rowList="10,15,20"
    rowNum="15"
    rownumbers="true"
    viewrecords="true"
>
<sjg:grid 
        id="orderssubgridtable" 
        subGridUrl="%{appointdetailsurl}"
        gridModel="gridModel"
        rowNum="15"
        dataType="json"
        pager="true"
        navigatorView="true"
        rowList="10,15,20"
        footerrow="true"
        rownumbers="true"
        viewrecords="true"
    >
        <sjg:gridColumn name="appointmentDate" index="appointmentDate" 
  width="200" formatter="date" formatoptions="{newformat : 'd/m/Y H:i', 
 srcformat : 'Y-m-d H:i:s'}" title="Appintment Date" editable="false" 
 edittype="text" sortable="true" search="false"/>
        <sjg:gridColumn name="status" index="status" title="Status" 
 sortable="false" hidden="false"/>
        <sjg:gridColumn name="createDate" index="createDate" width="200" 
 formatoptions="{newformat : 'd/m/Y H:i', srcformat : 'Y-m-d H:i:s'}"  
 formatter="date" title="Scheduled On"  search="false" sortable="false" 
 hidden="false"/>
        <sjg:gridColumn name="modifyDate" index="modifyDate" width="200" 
 formatoptions="{newformat : 'd/m/Y H:i', srcformat : 'Y-m-d H:i:s'}" 
 formatter="date" title="Rescheduled On"  search="false" sortable="false" 
 hidden="false"/>
    </sjg:grid>
    <sjg:gridColumn name="appointmentDate" index="appointmentDate" 
   width="200" formatter="date" formatoptions="{newformat : 'd/m/Y H:i', 
  srcformat : 'Y-m-d H:i:s'}" title="Appintment Date" editable="false" 
  edittype="text" sortable="true" search="false"/>
    <sjg:gridColumn name="status" index="status" title="Status" 
  sortable="false" hidden="false"/>
    <sjg:gridColumn name="createDate" index="createDate" width="200" 
 formatoptions="{newformat : 'd/m/Y H:i', srcformat : 'Y-m-d H:i:s'}"  
    formatter="date" title="Scheduled On"  search="false" sortable="false" 
 hidden="false"/>
    <sjg:gridColumn name="modifyDate" index="modifyDate" width="200" 
   formatoptions="{newformat : 'd/m/Y H:i', srcformat : 'Y-m-d H:i:s'}" 
 formatter="date" title="Rescheduled On"  search="false" sortable="false" 
 hidden="false"/>
 </sjg:grid>
   <br/>

</div>

it is throwing below error 08:45:57,475 WARN Dispatcher:64 - Could not find action or result: /HospitalCare/patient/jsonAppointmentHistory.action?id=1&&search=false&nd=1504494957407&rows=15&page=1&sidx=&sord=asc&=1504494947623 No result defined for action org.arshiya.struts.action.patient.JsonAppointmentHistoryAction and result exception at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:373) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:275) at org.arshiya.hibernate.util.SessionCheck.intercept(SessionCheck.java:34) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246) at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54) at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:562) at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77) at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1115) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Unknown Source)

1

There are 1 answers

0
Yasser Zamani On BEST ANSWER

According to

no result defined for action and result exception

I think your execute method throws some exception. I can recommend Struts Global Exception Handling to see what happens.