本文整理汇总了Java中org.apache.struts.config.ForwardConfig类的典型用法代码示例。如果您正苦于以下问题:Java ForwardConfig类的具体用法?Java ForwardConfig怎么用?Java ForwardConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ForwardConfig类属于org.apache.struts.config包,在下文中一共展示了ForwardConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteImage
import org.apache.struts.config.ForwardConfig; //导入依赖的package包/类
/**
* Save file or url imageGallery item into database.
*
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
private ActionForward deleteImage(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
IImageGalleryService service = getImageGalleryService();
Long imageUid = new Long(request.getParameter(ImageGalleryConstants.PARAM_IMAGE_UID));
String sessionMapID = request.getParameter(ImageGalleryConstants.ATTR_SESSION_MAP_ID);
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession().getAttribute(sessionMapID);
ToolAccessMode mode = (ToolAccessMode) sessionMap.get(AttributeNames.ATTR_MODE);
Long sessionId = (Long) sessionMap.get(ImageGalleryConstants.ATTR_TOOL_SESSION_ID);
service.deleteImage(sessionId, imageUid);
// redirect
ForwardConfig redirectConfig = mapping.findForwardConfig(ImageGalleryConstants.SUCCESS);
ActionRedirect redirect = new ActionRedirect(redirectConfig);
redirect.addParameter(AttributeNames.ATTR_MODE, mode);
redirect.addParameter(AttributeNames.PARAM_TOOL_SESSION_ID, sessionId);
return redirect;
}
示例2: verifyForwardConfigs
import org.apache.struts.config.ForwardConfig; //导入依赖的package包/类
/**
* <p>Return <code>true</code> if information returned by
* <code>config.findForwardConfigs</code> is all valid;
* otherwise, log error messages and return <code>false</code>.</p>
*/
protected boolean verifyForwardConfigs() {
boolean ok = true;
ForwardConfig fcs[] = config.findForwardConfigs();
for (int i = 0; i < fcs.length; i++) {
String path = fcs[i].getPath();
if (path == null) {
log(servlet.getInternal().getMessage
("verifyForwardConfigs.missing",
fcs[i].getName()));
ok = false;
} else if (!path.startsWith("/")) {
log(servlet.getInternal().getMessage
("verifyForwardConfigs.invalid", path,
fcs[i].getName()));
}
}
return (ok);
}
示例3: handle
import org.apache.struts.config.ForwardConfig; //导入依赖的package包/类
protected ForwardConfig handle(ActionContext context, Exception exception,
ExceptionConfig exceptionConfig, ActionConfig actionConfig,
ModuleConfig moduleConfig)
throws Exception {
// Look up the remaining properties needed for this handler
ServletActionContext sacontext = (ServletActionContext) context;
ActionForm actionForm = (ActionForm) sacontext.getActionForm();
HttpServletRequest request = sacontext.getRequest();
HttpServletResponse response = sacontext.getResponse();
// Handle this exception
org.apache.struts.action.ExceptionHandler handler =
(org.apache.struts.action.ExceptionHandler) ClassUtils
.getApplicationInstance(exceptionConfig.getHandler());
return (handler.execute(exception, exceptionConfig,
(ActionMapping) actionConfig, actionForm, request, response));
}
示例4: findForward
import org.apache.struts.config.ForwardConfig; //导入依赖的package包/类
/**
* <p>Find and return the <code>ForwardConfig</code> instance defining how
* forwarding to the specified logical name should be handled. This is
* performed by checking local and then global configurations for the
* specified forwarding configuration. If no forwarding configuration can
* be found, return <code>null</code>.</p>
*
* @param forwardName Logical name of the forwarding instance to be
* returned
* @return The local or global forward with the specified name.
*/
public ActionForward findForward(String forwardName) {
ForwardConfig config = findForwardConfig(forwardName);
if (config == null) {
config = getModuleConfig().findForwardConfig(forwardName);
}
if (config == null) {
if (log.isWarnEnabled()) {
log.warn("Unable to find '" + forwardName + "' forward.");
}
}
return ((ActionForward) config);
}
示例5: testNullForwardPath
import org.apache.struts.config.ForwardConfig; //导入依赖的package包/类
public void testNullForwardPath()
throws Exception {
ForwardConfig config = new ForwardConfig();
config.setPath(null);
try {
command.perform(saContext, config);
fail(
"Didn't throw an illegal argument exception on null forward path");
} catch (IllegalArgumentException ex) {
System.out.println("exception: " + ex.getMessage());
// Do nothing, the test passed
}
}
示例6: testProcessForwardConfigClassNoExtends
import org.apache.struts.config.ForwardConfig; //导入依赖的package包/类
/**
* Make sure processForwardConfigClass() returns what it was given if the
* forward passed to it doesn't extend anything.
*/
public void testProcessForwardConfigClassNoExtends()
throws Exception {
moduleConfig.addForwardConfig(baseForward);
ForwardConfig result = null;
try {
result =
actionServlet.processForwardConfigClass(baseForward,
moduleConfig, null);
} catch (UnavailableException e) {
fail("An exception should not be thrown when there's nothing to do");
}
assertSame("Result should be the same as the input.", baseForward,
result);
}
示例7: testProcessForwardConfigClassSubConfigCustomClass
import org.apache.struts.config.ForwardConfig; //导入依赖的package包/类
/**
* Make sure processForwardConfigClass() returns the same class instance
* if the base config isn't using a custom class.
*/
public void testProcessForwardConfigClassSubConfigCustomClass()
throws Exception {
moduleConfig.addForwardConfig(baseForward);
ForwardConfig customSub = new ActionForward();
customSub.setName("failure");
customSub.setExtends("success");
moduleConfig.addForwardConfig(customSub);
ForwardConfig result =
actionServlet.processForwardConfigClass(customSub, moduleConfig,
null);
assertSame("The instance returned should be the param given it.",
customSub, result);
}
示例8: testProcessForwardConfigClassOverriddenSubConfigClass
import org.apache.struts.config.ForwardConfig; //导入依赖的package包/类
/**
* Test the case where the subconfig has already specified its own config
* class. If the code still attempts to create a new instance, an error
* will be thrown.
*/
public void testProcessForwardConfigClassOverriddenSubConfigClass()
throws Exception {
moduleConfig.addForwardConfig(baseForward);
ForwardConfig customSub =
new CustomForwardConfigArg("failure", "/failure.jsp");
customSub.setExtends("success");
moduleConfig.addForwardConfig(customSub);
try {
actionServlet.processForwardConfigClass(customSub, moduleConfig,
null);
} catch (Exception e) {
fail("Exception should not be thrown");
}
}
示例9: testProcessActionExtensionWithForwardConfig
import org.apache.struts.config.ForwardConfig; //导入依赖的package包/类
/**
* Test that an ActionConfig's ForwardConfig can inherit from a
* global ForwardConfig.
*/
public void testProcessActionExtensionWithForwardConfig()
throws ServletException {
ForwardConfig forwardConfig = new ForwardConfig();
forwardConfig.setName("sub");
forwardConfig.setExtends("success");
baseAction.addForwardConfig(forwardConfig);
moduleConfig.addActionConfig(baseAction);
moduleConfig.addForwardConfig(baseForward);
actionServlet.processActionConfigExtension(baseAction, moduleConfig);
forwardConfig = baseAction.findForwardConfig("sub");
assertEquals("'sub' forward's inheritance was not processed.",
baseForward.getPath(), forwardConfig.getPath());
}
示例10: testExecute_validate
import org.apache.struts.config.ForwardConfig; //导入依赖的package包/类
/**
* @throws Exception
*/
public void testExecute_validate() throws Exception {
register(CccAction.class, "cccAction");
ActionCustomizer customizer = new ActionCustomizer();
customizer.customize(getComponentDef("cccAction"));
S2ActionMapping actionMapping = (S2ActionMapping) moduleConfig
.findActionConfig("/ccc");
getRequest().setParameter("execute", "submit");
S2ExecuteConfigUtil.setExecuteConfig(actionMapping
.findExecuteConfig(getRequest()));
CccAction action = (CccAction) getComponent(CccAction.class);
action.aaa = "111";
ActionWrapper wrapper = new ActionWrapper(actionMapping);
ForwardConfig forward = wrapper.execute(actionMapping, null,
getRequest(), getResponse());
assertNotNull(forward);
assertEquals("/ccc.do?SAStruts.method=input", forward.getPath());
assertNotNull(getRequest().getAttribute(Globals.ERROR_KEY));
assertNull(getRequest().getAttribute("aaa"));
}
示例11: testExecute_parentActionValidateMethod
import org.apache.struts.config.ForwardConfig; //导入依赖的package包/类
/**
* @throws Exception
*/
public void testExecute_parentActionValidateMethod() throws Exception {
register(OooAction.class, "oooAction");
register(MyForm.class, "myForm");
ActionCustomizer customizer = new ActionCustomizer();
customizer.customize(getComponentDef("oooAction"));
S2ActionMapping actionMapping = (S2ActionMapping) moduleConfig
.findActionConfig("/ooo");
getRequest().setParameter("execute", "submit");
S2ExecuteConfigUtil.setExecuteConfig(actionMapping
.findExecuteConfig(getRequest()));
ActionWrapper wrapper = new ActionWrapper(actionMapping);
ForwardConfig forward = wrapper.execute(actionMapping, null,
getRequest(), getResponse());
assertNotNull(forward);
assertEquals("/ooo/index.jsp", forward.getPath());
assertNotNull(getRequest().getAttribute(Globals.ERROR_KEY));
assertNull(getRequest().getAttribute("aaa"));
}
示例12: testExecute_validator
import org.apache.struts.config.ForwardConfig; //导入依赖的package包/类
/**
* @throws Exception
*/
public void testExecute_validator() throws Exception {
register(EeeAction.class, "eeeAction");
ActionCustomizer customizer = new ActionCustomizer();
customizer.customize(getComponentDef("eeeAction"));
S2ActionMapping actionMapping = (S2ActionMapping) moduleConfig
.findActionConfig("/eee");
S2ExecuteConfigUtil.setExecuteConfig(actionMapping
.findExecuteConfig(getRequest()));
ActionWrapper wrapper = new ActionWrapper(actionMapping);
ForwardConfig forward = wrapper.execute(actionMapping, null,
getRequest(), getResponse());
assertNotNull(forward);
assertEquals("/eee/input.jsp", forward.getPath());
assertNotNull(getRequest().getAttribute(Globals.ERROR_KEY));
}
示例13: testExecute_validate_session
import org.apache.struts.config.ForwardConfig; //导入依赖的package包/类
/**
* @throws Exception
*/
public void testExecute_validate_session() throws Exception {
register(DddAction.class, "dddAction");
ActionCustomizer customizer = new ActionCustomizer();
customizer.customize(getComponentDef("dddAction"));
S2ActionMapping actionMapping = (S2ActionMapping) moduleConfig
.findActionConfig("/ddd");
S2ExecuteConfigUtil.setExecuteConfig(actionMapping
.findExecuteConfig(getRequest()));
ActionWrapper wrapper = new ActionWrapper(actionMapping);
ForwardConfig forward = wrapper.execute(actionMapping, null,
getRequest(), getResponse());
assertNotNull(forward);
assertEquals("/ddd/input.jsp", forward.getPath());
assertNotNull(getRequest().getSession().getAttribute(Globals.ERROR_KEY));
}
示例14: testExecute_stopOnValidationError
import org.apache.struts.config.ForwardConfig; //导入依赖的package包/类
/**
* @throws Exception
*/
public void testExecute_stopOnValidationError() throws Exception {
register(HhhAction.class, "hhhAction");
ActionCustomizer customizer = new ActionCustomizer();
customizer.customize(getComponentDef("hhhAction"));
S2ActionMapping actionMapping = (S2ActionMapping) moduleConfig
.findActionConfig("/hhh");
S2ExecuteConfigUtil.setExecuteConfig(actionMapping
.findExecuteConfig(getRequest()));
ActionWrapper wrapper = new ActionWrapper(actionMapping);
ForwardConfig forward = wrapper.execute(actionMapping, null,
getRequest(), getResponse());
assertNotNull(forward);
assertEquals("/hhh/input.jsp", forward.getPath());
ActionMessages errors = (ActionMessages) getRequest().getAttribute(
Globals.ERROR_KEY);
assertNotNull(errors);
assertFalse(errors.isEmpty());
assertEquals(2, errors.size());
assertNotNull(errors.get("hoge"));
assertNotNull(errors.get("hoge2"));
}
示例15: testExecute_notExportPropertiesToRequest
import org.apache.struts.config.ForwardConfig; //导入依赖的package包/类
/**
* @throws Exception
*/
public void testExecute_notExportPropertiesToRequest() throws Exception {
ActionCustomizer customizer = new ActionCustomizer();
customizer.customize(getComponentDef("bbbAction"));
S2ActionMapping actionMapping = (S2ActionMapping) moduleConfig
.findActionConfig("/bbb");
getRequest().setParameter("execute3", "submit");
S2ExecuteConfigUtil.setExecuteConfig(actionMapping
.findExecuteConfig(getRequest()));
BbbAction action = (BbbAction) getComponent("bbbAction");
action.hoge = "111";
ActionWrapper wrapper = new ActionWrapper(actionMapping);
ForwardConfig forward = wrapper.execute(actionMapping, null,
getRequest(), getResponse());
assertNotNull(forward);
assertEquals("/bbb/execute", forward.getPath());
assertNull(getRequest().getAttribute("hoge"));
}