grid提前加载因缺少参数造成的后台异常

grid提前加载因缺少参数造成的后台错误

grid提前加载因缺少参数造成的后台异常

一般是由后台方法缺少必要的参数造成的。可加入判断,如果参数为空,则返回一个空的grid.

完成方法代码如下:

//分页查询所有修改人
	public String findAll(){
		String searchWord = ServletActionContext.getRequest().getParameter("searchWord");
		String testId = ServletActionContext.getRequest().getParameter("testIdStr");
		Condition condition = null;
		ConditionRuleGroup crg = new ConditionRuleGroup();
		if(condition ==null){
			condition = new Condition();
		}
		if(searchWord != null && !"".equals(searchWord)){
			ConditionRule cr1 = new ConditionRule("userName",searchWord,Mode.CONTAIN,Condition.Type.AND);
			ConditionRule cr2 = new ConditionRule("testId",Integer.parseInt(testId),Condition.Mode.EQUAL,Condition.Type.AND);
			crg.addRule(cr1,cr2);
			condition.addRuleGroup(crg);
		}
		else if(testId !=null){
			condition.addRuleByEqual("testId", Integer.parseInt(testId));
		}
		else{
			JSONObject map=new JSONObject();
			map.put("gridRoot", "[]");
			map.put("totalCount", 0);
			BeanUtil.servletOutPrint(map);
			return null;
		}
		Ordinal ordinal = new Ordinal();
		try {
			if(!EJBServiceFactory.lookupSuccess || EJBServiceFactory.remoteInterfacetestModifier==null){
				throw new BanyanException(BanyanException.LOOKUP_FOR_REMOTE_NAMING_EXCEPTION_INFO);
			}
			JSONArray ary = new JSONArray();
			List<RstestModifier> list = ((RstestModifierFacadeRemote)EJBServiceFactory.remoteInterfacetestModifier).findPagedList(start, limit, condition, ordinal);
			for (RstestModifier rstestModifier : list) {
				JSONObject temp = JSONObject.fromObject(rstestModifier);		
				ary.add(temp);
			}
			Integer count = ((RstestModifierFacadeRemote) EJBServiceFactory.remoteInterfacetestModifier).findRecordCount(condition);
			Map<String,Object> map = new HashMap<String,Object>();
			map.put("gridRoot", ary);
			map.put("totalCount", count);
			String json = JsonUtil.map2json(map);
			BeanUtil.servletOutPrint(json);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}