1 16 package com.blandware.atleap.webapp.action.core.grid; 17 18 import com.blandware.atleap.webapp.form.core.NumberFilterForm; 19 import com.blandware.atleap.webapp.taglib.core.grid.util.Grid; 20 import com.blandware.atleap.webapp.taglib.core.grid.util.NumberFilter; 21 import com.blandware.atleap.webapp.util.core.WebappUtil; 22 import org.apache.struts.action.ActionForm; 23 import org.apache.struts.action.ActionForward; 24 import org.apache.struts.action.ActionMapping; 25 26 import javax.servlet.http.HttpServletRequest ; 27 import javax.servlet.http.HttpServletResponse ; 28 import javax.servlet.http.HttpSession ; 29 import javax.servlet.jsp.JspException ; 30 31 47 public final class CallNumberFilterAction extends BaseGridAction { 48 49 58 public ActionForward execute(ActionMapping mapping, ActionForm form, 59 HttpServletRequest request, HttpServletResponse response) throws JspException { 60 61 HttpSession session = request.getSession(); 62 63 NumberFilterForm numberFilterForm = (NumberFilterForm) form; 64 String fieldName = numberFilterForm.getFieldName(); 65 String gridName = numberFilterForm.getGridName(); 66 67 Grid grid = getGridByName(gridName, session); 68 69 if ( grid == null ) { 70 if ( log.isErrorEnabled() ) { 71 String errorMessage = "No grid with name " + gridName + " could be found in session"; 72 log.error(errorMessage); 73 } 74 return mapping.findForward("filterError"); 75 } 76 77 NumberFilter filter = null; 78 try { 79 filter = (NumberFilter) grid.getFilterByFieldName(fieldName); 80 } catch ( ClassCastException e ) { 81 if ( log.isErrorEnabled() ) { 82 String errorMessage = "Filter for field \'" + fieldName + "\' in grid \'" + gridName + "\' is not instance of com.blandware.atleap.webapp.taglib.core.grid.util.NumberFilter"; 83 log.error(errorMessage); 84 } 85 return mapping.findForward("filterError"); 86 } 87 88 89 if ( filter != null ) { 90 try { 91 String rowIterators = numberFilterForm.getRowIterators(); 92 WebappUtil.copyProperties(numberFilterForm, filter, request); 93 numberFilterForm.setRowIterators(rowIterators); 94 } catch ( Exception e ) { 95 if ( log.isErrorEnabled() ) { 96 log.error(e); 97 } 98 throw new JspException (e); 99 } 100 } 101 102 if ( log.isDebugEnabled() ) { 103 log.debug("Returning filter page: " + mapping.findForward("showFilterPage").getPath()); 104 } 105 106 return mapping.findForward("showFilterPage"); 107 } 108 } | Popular Tags |