Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package net.nan21.dnet.core.web.controller.data;
  
  import java.util.List;
  
  import  javax.servlet.http.HttpServletRequest;
  import  javax.servlet.http.HttpServletResponse;
  
  import  org.springframework.web.bind.annotation.PathVariable;
 import  org.springframework.web.bind.annotation.RequestMapping;
 import  org.springframework.web.bind.annotation.RequestMethod;
 import  org.springframework.web.bind.annotation.RequestParam;
 import  org.springframework.web.bind.annotation.ResponseBody;
 
 
 public abstract class AbstractAsgnController<M, F, P> extends
Default handler for find action.

Parameters:
resourceName
dataformat
dataString
paramString
resultStart
resultSize
orderByCol
orderBySense
Returns:
Throws:
Exception
 
 	@RequestMapping(method = RequestMethod.POST, params = "action=findLeft")
 	@ResponseBody
 	public String find(
 			@PathVariable String resourceName,
 			@PathVariable String dataFormat,
 			@RequestParam(value = "objectId", required = trueLong objectId,
 			@RequestParam(value = "selectionId", required = trueString selectionId,
 			@RequestParam(value = "data", required = false, defaultValue = "{}"String dataString,
 			@RequestParam(value = "params", required = false, defaultValue = "{}"String paramString,
 			@RequestParam(value = "resultStart", required = false, defaultValue = "0"int resultStart,
 			@RequestParam(value = "resultSize", required = false, defaultValue = "500"int resultSize,
 			@RequestParam(value = "orderByCol", required = false, defaultValue = ""String orderByCol,
 			@RequestParam(value = "orderBySense", required = false, defaultValue = ""String orderBySense,
 			HttpServletRequest request, HttpServletResponse response)
 			throws Exception {
 		try {
 			this.prepareRequest(requestresponse);
 
 			this.authorizeAsgnAction(resourceName"find");
 
 			IAsgnService<M, F, P> service = this.findAsgnService(this
 					.serviceNameFromResourceName(resourceName));
 
 			service.setObjectId(objectId);
 			service.setSelectionId(selectionId);
 
 			IQueryBuilder<M, F, P> builder = service.createQueryBuilder()
 					.addFetchLimit(resultStartresultSize)
 					.addSortInfo(orderByColorderBySense);
 
 			IDsMarshaller<M, F, P> marshaller = service
 					.createMarshaller(dataFormat);
 
 			F filter = marshaller.readFilterFromString(dataString);
 			P params = marshaller.readParamsFromString(paramString);
 
 			List<M> list = service.findLeft(filterparamsbuilder);
 			long totalCount = service.countLeft(filterparamsbuilder); // service.count(filter,
 			// params,
 			// builder);
 
 			IActionResultFind result = this.packfindResult(listparams,
 					totalCount);
 			return marshaller.writeResultToString(result);
 		} catch (Exception e) {
 			return this.handleException(eresponse);
 		} finally {
 			this.finishRequest();
 		}
 
 	}

Default handler for find action.

Parameters:
resourceName
dataformat
dataString
paramString
resultStart
resultSize
orderByCol
orderBySense
Returns:
Throws:
Exception
	@RequestMapping(method = RequestMethod.POST, params = "action=findRight")
	@ResponseBody
	public String findRight(
			@PathVariable String resourceName,
			@PathVariable String dataFormat,
			@RequestParam(value = "objectId", required = trueLong objectId,
			@RequestParam(value = "selectionId", required = trueString selectionId,
			@RequestParam(value = "data", required = false, defaultValue = "{}"String dataString,
			@RequestParam(value = "params", required = false, defaultValue = "{}"String paramString,
			@RequestParam(value = "resultStart", required = false, defaultValue = "0"int resultStart,
			@RequestParam(value = "resultSize", required = false, defaultValue = "500"int resultSize,
			@RequestParam(value = "orderByCol", required = false, defaultValue = ""String orderByCol,
			@RequestParam(value = "orderBySense", required = false, defaultValue = ""String orderBySense,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		try {
			this.prepareRequest(requestresponse);
			this.authorizeAsgnAction(resourceName"find");
			IAsgnService<M, F, P> service = this.findAsgnService(this
			service.setObjectId(objectId);
			service.setSelectionId(selectionId);
			IQueryBuilder<M, F, P> builder = service.createQueryBuilder()
					.addFetchLimit(resultStartresultSize)
					.addSortInfo(orderByColorderBySense);
			IDsMarshaller<M, F, P> marshaller = service
					.createMarshaller(dataFormat);
filter = marshaller.readFilterFromString(dataString);
params = marshaller.readParamsFromString(paramString);
			List<M> list = service.findRight(filterparamsbuilder);
			long totalCount = service.countRight(filterparamsbuilder); // service.count(filter,
			// params,
			// builder);
			IActionResultFind result = this.packfindResult(listparams,
					totalCount);
			return marshaller.writeResultToString(result);
catch (Exception e) {
			return this.handleException(eresponse);
finally {
		}
	}

Parameters:
resourceName
dataFormat
objectId
selectionId
response
Returns:
Throws:
Exception
	@RequestMapping(method = RequestMethod.POST, params = "action=setup")
	@ResponseBody
	public String setup(
			@PathVariable String resourceName,
			@PathVariable String dataFormat,
			@RequestParam(value = "objectId", required = trueLong objectId,
			@RequestParam(value = "selectionId", required = trueString selectionId,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		try {
			this.prepareRequest(requestresponse);
			this.authorizeAsgnAction(resourceName"find");
			IAsgnService<M, F, P> service = this.findAsgnService(this
			service.setObjectId(objectId);
			return service.setup(resourceName);
catch (Exception e) {
			return this.handleException(eresponse);
finally {
		}
	}

Parameters:
resourceName
dataFormat
objectId
selectionId
response
Returns:
Throws:
Exception
	@RequestMapping(method = RequestMethod.POST, params = "action=moveLeft")
	@ResponseBody
	public String moveLeft(
			@PathVariable String resourceName,
			@PathVariable String dataFormat,
			@RequestParam(value = "objectId", required = trueLong objectId,
			@RequestParam(value = "selectionId", required = trueString selectionId,
			@RequestParam(value = "p_selected_ids", required = trueString selectedIds,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		try {
			this.prepareRequest(requestresponse);
			this.authorizeAsgnAction(resourceName"update");
			IAsgnService<M, F, P> service = this.findAsgnService(this
			service.setObjectId(objectId);
			service.setSelectionId(selectionId);
			String[] tmp = selectedIds.split(",");
			List<Longids = new ArrayList<Long>();
			for (String i : tmp) {
				ids.add(new Long(i));
			}
			service.moveLeft(ids);
			return "";
catch (Exception e) {
			return this.handleException(eresponse);
finally {
		}
	}

Parameters:
resourceName
dataFormat
objectId
selectionId
response
Returns:
Throws:
Exception
	@RequestMapping(method = RequestMethod.POST, params = "action=moveRight")
	@ResponseBody
	public String moveRight(
			@PathVariable String resourceName,
			@PathVariable String dataFormat,
			@RequestParam(value = "objectId", required = trueLong objectId,
			@RequestParam(value = "selectionId", required = trueString selectionId,
			@RequestParam(value = "p_selected_ids", required = trueString selectedIds,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		try {
			this.prepareRequest(requestresponse);
			this.authorizeAsgnAction(resourceName"update");
			IAsgnService<M, F, P> service = this.findAsgnService(this
			service.setObjectId(objectId);
			service.setSelectionId(selectionId);
			String[] tmp = selectedIds.split(",");
			List<Longids = new ArrayList<Long>();
			for (String i : tmp) {
				ids.add(new Long(i));
			}
			service.moveRight(ids);
			return "";
catch (Exception e) {
			return this.handleException(eresponse);
finally {
		}
	}
	@RequestMapping(method = RequestMethod.POST, params = "action=moveLeftAll")
	@ResponseBody
			@PathVariable String resourceName,
			@PathVariable String dataFormat,
			@RequestParam(value = "data", required = false, defaultValue = "{}"String dataString,
			@RequestParam(value = "params", required = false, defaultValue = "{}"String paramString,
			@RequestParam(value = "objectId", required = trueLong objectId,
			@RequestParam(value = "selectionId", required = trueString selectionId,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		try {
			this.prepareRequest(requestresponse);
			this.authorizeAsgnAction(resourceName"update");
			IAsgnService<M, F, P> service = this.findAsgnService(this
			IDsMarshaller<M, F, P> marshaller = service
					.createMarshaller(dataFormat);
filter = marshaller.readFilterFromString(dataString);
params = marshaller.readParamsFromString(paramString);
			service.setObjectId(objectId);
			service.setSelectionId(selectionId);
			service.moveLeftAll(filterparams);
			return "";
catch (Exception e) {
			return this.handleException(eresponse);
finally {
		}
	}
	@RequestMapping(method = RequestMethod.POST, params = "action=moveRightAll")
	@ResponseBody
			@PathVariable String resourceName,
			@PathVariable String dataFormat,
			@RequestParam(value = "data", required = false, defaultValue = "{}"String dataString,
			@RequestParam(value = "params", required = false, defaultValue = "{}"String paramString,
			@RequestParam(value = "objectId", required = trueLong objectId,
			@RequestParam(value = "selectionId", required = trueString selectionId,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		try {
			this.prepareRequest(requestresponse);
			this.authorizeAsgnAction(resourceName"update");
			IAsgnService<M, F, P> service = this.findAsgnService(this
			service.setObjectId(objectId);
			service.setSelectionId(selectionId);
			IDsMarshaller<M, F, P> marshaller = service
					.createMarshaller(dataFormat);
filter = marshaller.readFilterFromString(dataString);
params = marshaller.readParamsFromString(paramString);
			service.moveRightAll(filterparams);
			return "";
catch (Exception e) {
			return this.handleException(eresponse);
finally {
		}
	}
	@RequestMapping(method = RequestMethod.POST, params = "action=reset")
	@ResponseBody
	public String reset(
			@PathVariable String resourceName,
			@PathVariable String dataFormat,
			@RequestParam(value = "objectId", required = trueLong objectId,
			@RequestParam(value = "selectionId", required = trueString selectionId,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		try {
			this.prepareRequest(requestresponse);
			IAsgnService<M, F, P> service = this.findAsgnService(this
			service.setObjectId(objectId);
			service.setSelectionId(selectionId);
			service.reset();
			return "";
catch (Exception e) {
			return this.handleException(eresponse);
finally {
		}
	}
	@RequestMapping(method = RequestMethod.POST, params = "action=save")
	@ResponseBody
	public String save(
			@PathVariable String resourceName,
			@PathVariable String dataFormat,
			@RequestParam(value = "objectId", required = trueLong objectId,
			@RequestParam(value = "selectionId", required = trueString selectionId,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		try {
			this.prepareRequest(requestresponse);
			this.authorizeAsgnAction(resourceName"update");
			IAsgnService<M, F, P> service = this.findAsgnService(this
			service.setObjectId(objectId);
			service.setSelectionId(selectionId);
			service.save();
			return "";
catch (Exception e) {
			return this.handleException(eresponse);
finally {
		}
	}
	protected String serviceNameFromResourceName(String resourceName) {
		return resourceName + "AsgnService";
	}
	public IActionResultFind packfindResult(List<M> data, P params,
			long totalCount) {
		pack.setData(data);
		pack.setParams(params);
		pack.setTotalCount(totalCount);
		return pack;
	}
	public IAsgnService<M, F, P> findAsgnService(String asgnName)
			throws Exception {
		return this.getServiceLocator().findAsgnService(asgnName);
	}
New to GrepCode? Check out our FAQ X