View Javadoc

1   /*
2    * Copyright 2007-2009 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kim.web.struts.action;
17  
18  import javax.servlet.http.HttpServletRequest;
19  import javax.servlet.http.HttpServletResponse;
20  
21  import org.apache.struts.action.ActionForm;
22  import org.apache.struts.action.ActionForward;
23  import org.apache.struts.action.ActionMapping;
24  import org.kuali.rice.core.util.RiceConstants;
25  import org.kuali.rice.kim.service.KIMServiceLocatorInternal;
26  import org.kuali.rice.kim.service.UiDocumentService;
27  import org.kuali.rice.kim.web.struts.form.IdentityManagementDocumentFormBase;
28  import org.kuali.rice.kns.web.struts.action.KualiAction;
29  import org.kuali.rice.kns.web.struts.form.KualiTableRenderFormMetadata;
30  
31  /**
32   * This is a description of what this class does - jonathan don't forget to fill this in. 
33   * 
34   * @author Kuali Rice Team (rice.collab@kuali.org)
35   *
36   */
37  public abstract class IdentityManagementBaseInquiryAction extends KualiAction {
38  
39  	protected UiDocumentService uiDocumentService;
40  
41      protected UiDocumentService getUiDocumentService() {
42  		if ( uiDocumentService == null ) {
43  			uiDocumentService = KIMServiceLocatorInternal.getUiDocumentService();
44  		}
45  		return uiDocumentService;
46  	}
47  	
48  	/**
49  	 * This overridden method ...
50  	 * 
51  	 * @see org.kuali.rice.krad.web.struts.action.KualiAction#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
52  	 */
53  	@Override
54  	public ActionForward execute(ActionMapping mapping, ActionForm form,
55  			HttpServletRequest request, HttpServletResponse response)
56  			throws Exception {
57  		IdentityManagementDocumentFormBase idmForm = (IdentityManagementDocumentFormBase) form;
58  		idmForm.setInquiry(true);
59  
60          loadKimObject( request, idmForm );
61  
62          KualiTableRenderFormMetadata memberTableMetadata = idmForm.getMemberTableMetadata();
63          memberTableMetadata.jumpToPage(memberTableMetadata.getSwitchToPageNumber(), idmForm.getMemberRows().size(), idmForm.getRecordsPerPage());
64      	
65  		return super.execute(mapping, form, request, response);
66  	}
67  	
68      protected abstract void loadKimObject( HttpServletRequest request, IdentityManagementDocumentFormBase form );
69  	    
70      public ActionForward inquiry(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
71          return mapping.findForward(RiceConstants.MAPPING_BASIC);
72      }
73   
74      /**
75       * @see org.kuali.rice.krad.web.struts.action.KualiTableAction#switchToPage(org.apache.struts.action.ActionMapping,
76       *      org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
77       */
78      public ActionForward switchToPage(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
79          IdentityManagementDocumentFormBase idmForm = (IdentityManagementDocumentFormBase) form;
80          
81          KualiTableRenderFormMetadata memberTableMetadata = idmForm.getMemberTableMetadata();
82          memberTableMetadata.jumpToPage(memberTableMetadata.getSwitchToPageNumber(), idmForm.getMemberRows().size(), idmForm.getRecordsPerPage());
83          memberTableMetadata.setColumnToSortIndex(memberTableMetadata.getPreviouslySortedColumnIndex());
84          return mapping.findForward(RiceConstants.MAPPING_BASIC);
85      }
86      
87  
88  }