Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 org.apache.struts2.views.gxp;
import com.google.common.annotations.VisibleForTesting;
import com.google.gxp.base.GxpContext;
import com.google.gxp.base.MarkupClosure;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.util.ValueStack;
import com.opensymphony.xwork2.util.ValueStackFactory;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* Struts2 to GXP adapter. Can be used to write a GXP or create a
* {@link MarkupClosure}. Pulls GXP parameters from Struts2 value stack.
*
* @author Bob Lee
*/
public abstract class AbstractGxp {
ValueStackFactory valueStackFactory;
Map defaultValues = new HashMap();
List params;
Class gxpClass;
Method writeMethod;
Method getGxpClosureMethod;
boolean hasBodyParam;
protected AbstractGxp(Class gxpClass) {
this(gxpClass, lookupMethodByName(gxpClass, "write"), lookupMethodByName(gxpClass, "getGxpClosure"));
}
protected AbstractGxp(Class gxpClass, Method writeMethod, Method getGxpClosureMethod) {
this.gxpClass = gxpClass;
this.writeMethod = writeMethod;
this.getGxpClosureMethod = getGxpClosureMethod;
this.params = lookupParams();
}
/**
* Writes GXP. Pulls GXP parameters from Struts2's value stack.
*
* @param out Appendable
* @param gxpContext GXP content
*/
public void write(Appendable out, GxpContext gxpContext) {
write(out, gxpContext, null);
}
/**
* Writes GXP. Pulls GXP parameters from Struts2's value stack.
*
* @param out Appendable
* @param gxpContext GXP content
* @param overrides parameter map pushed onto the value stack
*/
protected void write(Appendable out, GxpContext gxpContext, Map overrides) {
Object[] args = getArgs(out, gxpContext, overrides);
try {
writeMethod.invoke(getGxpInstance(), args);
} catch (Exception e) {
throw new RuntimeException(createDebugString(args, e), e);
}
}
protected Object[] getArgs(Appendable out, GxpContext gxpContext, Map overrides) {
List