Java tutorial
/* * Copyright 2012 Eng Kam Hon (kamhon@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package net.kamhon.ieagle.struts2.jquery.datatables; import java.util.Map; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import com.opensymphony.xwork2.ActionInvocation; import com.opensymphony.xwork2.interceptor.Interceptor; public class DatatablesInterceptor implements Interceptor { private static final long serialVersionUID = 1L; private static final Log log = LogFactory.getLog(DatatablesInterceptor.class); public void destroy() { log.debug("call DatatablesInterceptor.destroy()"); } public void init() { log.debug("call DatatablesInterceptor.init()"); } public String intercept(ActionInvocation actionInvocation) throws Exception { Map<String, Object> params = actionInvocation.getInvocationContext().getParameters(); if (actionInvocation.getAction() instanceof BaseDatatablesJsonAction<?>) { BaseDatatablesJsonAction<?> action = (BaseDatatablesJsonAction<?>) actionInvocation.getAction(); Object obj = params.get("sColumns"); if (obj != null) { String columns = ((String[]) obj)[0]; String ss[] = StringUtils.split(columns, ","); action.setGridColumns(ss); } } return actionInvocation.invoke(); } }