Search in sources :

Example 81 with ActionForward

use of org.apache.struts.action.ActionForward in project sonar-java by SonarSource.

the class TestMockBase method setUpSecondApp.

protected void setUpSecondApp() {
    ActionFormBean formBean = null;
    ActionMapping mapping = null;
    ModuleConfigFactory factoryObject = ModuleConfigFactory.createFactory();
    moduleConfig2 = factoryObject.createModuleConfig("/2");
    context.setAttribute(Globals.MODULE_KEY + "/2", moduleConfig2);
    // Forward "external" to "http://jakarta.apache.org/"
    moduleConfig2.addForwardConfig(new ActionForward("external", "http://jakarta.apache.org/", false));
    // Forward "foo" to "/baz.jsp" (different from default)
    moduleConfig2.addForwardConfig(new ActionForward("foo", "/baz.jsp", false));
    // Forward "relative1" to "relative.jsp" non-context-relative
    moduleConfig2.addForwardConfig(new ActionForward("relative1", "relative.jsp", false));
    // Forward "relative2" to "relative.jsp" context-relative
    moduleConfig2.addForwardConfig(new ActionForward("relative2", "relative.jsp", false));
    // Form Bean "static" is a standard ActionForm subclass (same as default)
    formBean = new ActionFormBean("static", "org.apache.struts.mock.MockFormBean");
    moduleConfig2.addFormBeanConfig(formBean);
    // Action "/static" uses the "static" form bean in request scope (same as default)
    mapping = new ActionMapping();
    mapping.setInput("/static.jsp");
    mapping.setName("static");
    mapping.setPath("/static");
    mapping.setScope("request");
    mapping.setType("org.apache.struts.mock.MockAction");
    moduleConfig2.addActionConfig(mapping);
    // Form Bean "dynamic2" is a DynaActionForm with the same properties
    formBean = new ActionFormBean("dynamic2", "org.apache.struts.action.DynaActionForm");
    formBean.addFormPropertyConfig(new FormPropertyConfig("booleanProperty", "boolean", "false"));
    formBean.addFormPropertyConfig(new FormPropertyConfig("stringProperty", "java.lang.String", null));
    moduleConfig2.addFormBeanConfig(formBean);
    // Action "/dynamic2" uses the "dynamic2" form bean in session scope
    mapping = new ActionMapping();
    mapping.setInput("/dynamic2.jsp");
    mapping.setName("dynamic2");
    mapping.setPath("/dynamic2");
    mapping.setScope("session");
    mapping.setType("org.apache.struts.mock.MockAction");
    moduleConfig2.addActionConfig(mapping);
    // Action "/noform" has no form bean associated with it (same as default)
    mapping = new ActionMapping();
    mapping.setPath("/noform");
    mapping.setType("org.apache.struts.mock.MockAction");
    moduleConfig2.addActionConfig(mapping);
    // Configure global forward declarations
    moduleConfig2.addForwardConfig(new ForwardConfig("moduleForward", "/module/forward", // No redirect, same module
    false));
    moduleConfig2.addForwardConfig(new ForwardConfig("moduleRedirect", "/module/redirect", // Redirect, same module
    true));
    moduleConfig2.addForwardConfig(new ForwardConfig("contextForward", // No redirect
    "/forward", // No redirect
    false, // Specify module
    "/context"));
    moduleConfig2.addForwardConfig(new ForwardConfig("contextRedirect", // Redirect
    "/redirect", // Redirect
    true, // Specify module
    "/context"));
    moduleConfig2.addForwardConfig(new ForwardConfig("moduleNoslash", "module/noslash", // No redirect, same module
    false));
    moduleConfig2.addForwardConfig(new ForwardConfig("contextNoslash", // No redirect
    "noslash", // No redirect
    false, // Specify module
    "/context"));
}
Also used : FormPropertyConfig(org.apache.struts.config.FormPropertyConfig) ActionMapping(org.apache.struts.action.ActionMapping) ModuleConfigFactory(org.apache.struts.config.ModuleConfigFactory) ForwardConfig(org.apache.struts.config.ForwardConfig) ActionForward(org.apache.struts.action.ActionForward) ActionFormBean(org.apache.struts.action.ActionFormBean)

Example 82 with ActionForward

use of org.apache.struts.action.ActionForward in project sonar-java by SonarSource.

the class TestMockBase method setUpDefaultApp.

protected void setUpDefaultApp() {
    ActionFormBean formBean = null;
    ActionMapping mapping = null;
    ModuleConfigFactory factoryObject = ModuleConfigFactory.createFactory();
    moduleConfig = factoryObject.createModuleConfig("");
    context.setAttribute(Globals.MODULE_KEY, moduleConfig);
    // Forward "external" to "http://jakarta.apache.org/"
    moduleConfig.addForwardConfig(new ActionForward("external", "http://jakarta.apache.org/", false));
    // Forward "foo" to "/bar.jsp"
    moduleConfig.addForwardConfig(new ActionForward("foo", "/bar.jsp", false));
    // Forward "relative1" to "relative.jsp" non-context-relative
    moduleConfig.addForwardConfig(new ActionForward("relative1", "relative.jsp", false));
    // Forward "relative2" to "relative.jsp" context-relative
    moduleConfig.addForwardConfig(new ActionForward("relative2", "relative.jsp", false));
    // Form Bean "static" is a standard ActionForm subclass
    formBean = new ActionFormBean("static", "org.apache.struts.mock.MockFormBean");
    moduleConfig.addFormBeanConfig(formBean);
    // Action "/static" uses the "static" form bean in request scope
    mapping = new ActionMapping();
    mapping.setInput("/static.jsp");
    mapping.setName("static");
    mapping.setPath("/static");
    mapping.setScope("request");
    mapping.setType("org.apache.struts.mock.MockAction");
    moduleConfig.addActionConfig(mapping);
    // Form Bean "dynamic" is a DynaActionForm with the same properties
    formBean = new ActionFormBean("dynamic", "org.apache.struts.action.DynaActionForm");
    formBean.addFormPropertyConfig(new FormPropertyConfig("booleanProperty", "boolean", "false"));
    formBean.addFormPropertyConfig(new FormPropertyConfig("stringProperty", "java.lang.String", null));
    moduleConfig.addFormBeanConfig(formBean);
    // Action "/dynamic" uses the "dynamic" form bean in session scope
    mapping = new ActionMapping();
    mapping.setInput("/dynamic.jsp");
    mapping.setName("dynamic");
    mapping.setPath("/dynamic");
    mapping.setScope("session");
    mapping.setType("org.apache.struts.mock.MockAction");
    moduleConfig.addActionConfig(mapping);
    // Form Bean "/dynamic0" is a DynaActionForm with initializers
    formBean = new ActionFormBean("dynamic0", "org.apache.struts.action.DynaActionForm");
    formBean.addFormPropertyConfig(new FormPropertyConfig("booleanProperty", "boolean", "true"));
    formBean.addFormPropertyConfig(new FormPropertyConfig("stringProperty", "java.lang.String", "String Property"));
    formBean.addFormPropertyConfig(new FormPropertyConfig("intArray1", "int[]", "{1,2,3}", // 4 should be ignored
    4));
    formBean.addFormPropertyConfig(new FormPropertyConfig("intArray2", "int[]", null, // 5 should be respected
    5));
    formBean.addFormPropertyConfig(new FormPropertyConfig("principal", "org.apache.struts.mock.MockPrincipal", null));
    formBean.addFormPropertyConfig(new FormPropertyConfig("stringArray1", "java.lang.String[]", "{aaa,bbb,ccc}", // 2 should be ignored
    2));
    formBean.addFormPropertyConfig(new FormPropertyConfig("stringArray2", "java.lang.String[]", null, // 3 should be respected
    3));
    moduleConfig.addFormBeanConfig(formBean);
    // Action "/dynamic0" uses the "dynamic0" form bean in request scope
    mapping = new ActionMapping();
    mapping.setName("dynamic0");
    mapping.setPath("/dynamic0");
    mapping.setScope("request");
    mapping.setType("org.apache.struts.mock.MockAction");
    moduleConfig.addActionConfig(mapping);
    // Action "/noform" has no form bean associated with it
    mapping = new ActionMapping();
    mapping.setPath("/noform");
    mapping.setType("org.apache.struts.mock.MockAction");
    moduleConfig.addActionConfig(mapping);
    // Configure global forward declarations
    moduleConfig.addForwardConfig(new ForwardConfig("moduleForward", "/module/forward", // No redirect, same module
    false));
    moduleConfig.addForwardConfig(new ForwardConfig("moduleRedirect", "/module/redirect", // Redirect, same module
    true));
    moduleConfig.addForwardConfig(new ForwardConfig("contextForward", // No redirect
    "/forward", // No redirect
    false, // Specify module
    "/context"));
    moduleConfig.addForwardConfig(new ForwardConfig("contextRedirect", // Redirect
    "/redirect", // Redirect
    true, // Specify module
    "/context"));
    moduleConfig.addForwardConfig(new ForwardConfig("moduleNoslash", "module/noslash", // No redirect, same module
    false));
    moduleConfig.addForwardConfig(new ForwardConfig("contextNoslash", // No redirect
    "noslash", // No redirect
    false, // Specify module
    "/context"));
}
Also used : FormPropertyConfig(org.apache.struts.config.FormPropertyConfig) ActionMapping(org.apache.struts.action.ActionMapping) ModuleConfigFactory(org.apache.struts.config.ModuleConfigFactory) ForwardConfig(org.apache.struts.config.ForwardConfig) ActionForward(org.apache.struts.action.ActionForward) ActionFormBean(org.apache.struts.action.ActionFormBean)

Example 83 with ActionForward

use of org.apache.struts.action.ActionForward in project sonar-java by SonarSource.

the class ConfigHelper method getLink.

/**
 * <p> Return the path for the specified forward, otherwise return
 * <code>null</code>. </p>
 *
 * @param name Name given to local or global forward.
 */
public String getLink(String name) {
    ActionForward forward = getActionForward(name);
    if (forward == null) {
        return null;
    }
    StringBuffer path = new StringBuffer(this.request.getContextPath());
    path.append(forward.getPath());
    // :TODO: What about runtime parameters?
    return getEncodeURL(path.toString());
}
Also used : ActionForward(org.apache.struts.action.ActionForward)

Example 84 with ActionForward

use of org.apache.struts.action.ActionForward in project cu-kfs by CU-CommunityApps.

the class DisbursementVoucherAction method renderCustomerAddressSelection.

/**
 * render the customer address lookup results if there are multiple addresses for the selected customer
 */
protected ActionForward renderCustomerAddressSelection(ActionMapping mapping, HttpServletRequest request, DisbursementVoucherForm dvForm) {
    Properties props = new Properties();
    props.put(KRADConstants.SUPPRESS_ACTIONS, Boolean.toString(true));
    props.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, AccountsReceivableCustomerAddress.class.getName());
    props.put(KRADConstants.LOOKUP_ANCHOR, KRADConstants.ANCHOR_TOP_OF_FORM);
    props.put(KRADConstants.LOOKED_UP_COLLECTION_NAME, KFSPropertyConstants.VENDOR_ADDRESSES);
    String conversionPatttern = "{0}" + KFSConstants.FIELD_CONVERSION_PAIR_SEPERATOR + "{0}";
    StringBuilder filedConversion = new StringBuilder();
    filedConversion.append(MessageFormat.format(conversionPatttern, KFSPropertyConstants.CUSTOMER_NUMBER)).append(KFSConstants.FIELD_CONVERSIONS_SEPERATOR);
    filedConversion.append(MessageFormat.format(conversionPatttern, KFSPropertyConstants.CUSTOMER_ADDRESS_IDENTIFIER));
    props.put(KRADConstants.CONVERSION_FIELDS_PARAMETER, filedConversion);
    props.put(KFSPropertyConstants.CUSTOMER_NUMBER, dvForm.getPayeeIdNumber());
    props.put(KFSPropertyConstants.ACTIVE, KFSConstants.ACTIVE_INDICATOR);
    props.put(KRADConstants.RETURN_LOCATION_PARAMETER, this.getReturnLocation(request, mapping));
    props.put(KRADConstants.BACK_LOCATION, this.getReturnLocation(request, mapping));
    props.put(KRADConstants.LOOKUP_AUTO_SEARCH, "Yes");
    props.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, KFSConstants.SEARCH_METHOD);
    props.put(KRADConstants.DOC_FORM_KEY, GlobalVariables.getUserSession().addObjectWithGeneratedKey(dvForm));
    props.put(KRADConstants.DOC_NUM, dvForm.getDocument().getDocumentNumber());
    // TODO: how should this forward be handled
    String url = UrlFactory.parameterizeUrl(getApplicationBaseUrl() + "/kr/" + KRADConstants.LOOKUP_ACTION, props);
    dvForm.registerEditableProperty("methodToCall");
    return new ActionForward(url, true);
}
Also used : AccountsReceivableCustomerAddress(org.kuali.kfs.integration.ar.AccountsReceivableCustomerAddress) Properties(java.util.Properties) ActionForward(org.apache.struts.action.ActionForward)

Example 85 with ActionForward

use of org.apache.struts.action.ActionForward in project cu-kfs by CU-CommunityApps.

the class DisbursementVoucherAction method renderVendorAddressSelection.

/**
 * render the vendor address lookup results if there are multiple addresses for the selected vendor
 */
protected ActionForward renderVendorAddressSelection(ActionMapping mapping, HttpServletRequest request, DisbursementVoucherForm dvForm) {
    Properties props = new Properties();
    props.put(KRADConstants.SUPPRESS_ACTIONS, Boolean.toString(true));
    props.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, VendorAddress.class.getName());
    props.put(KRADConstants.LOOKUP_ANCHOR, KRADConstants.ANCHOR_TOP_OF_FORM);
    props.put(KRADConstants.LOOKED_UP_COLLECTION_NAME, KFSPropertyConstants.VENDOR_ADDRESSES);
    String conversionPatttern = "{0}" + KFSConstants.FIELD_CONVERSION_PAIR_SEPERATOR + "{0}";
    StringBuilder filedConversion = new StringBuilder();
    filedConversion.append(MessageFormat.format(conversionPatttern, KFSPropertyConstants.VENDOR_ADDRESS_GENERATED_ID)).append(KFSConstants.FIELD_CONVERSIONS_SEPERATOR);
    filedConversion.append(MessageFormat.format(conversionPatttern, KFSPropertyConstants.VENDOR_HEADER_GENERATED_ID)).append(KFSConstants.FIELD_CONVERSIONS_SEPERATOR);
    filedConversion.append(MessageFormat.format(conversionPatttern, KFSPropertyConstants.VENDOR_DETAIL_ASSIGNED_ID));
    props.put(KRADConstants.CONVERSION_FIELDS_PARAMETER, filedConversion);
    props.put(KFSPropertyConstants.VENDOR_HEADER_GENERATED_ID, dvForm.getVendorHeaderGeneratedIdentifier());
    props.put(KFSPropertyConstants.VENDOR_DETAIL_ASSIGNED_ID, dvForm.getVendorDetailAssignedIdentifier());
    props.put(KFSPropertyConstants.ACTIVE, KFSConstants.ACTIVE_INDICATOR);
    props.put(KRADConstants.RETURN_LOCATION_PARAMETER, this.getReturnLocation(request, mapping));
    props.put(KRADConstants.BACK_LOCATION, this.getReturnLocation(request, mapping));
    props.put(KRADConstants.LOOKUP_AUTO_SEARCH, "Yes");
    props.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, KFSConstants.SEARCH_METHOD);
    props.put(KRADConstants.DOC_FORM_KEY, GlobalVariables.getUserSession().addObjectWithGeneratedKey(dvForm));
    props.put(KRADConstants.DOC_NUM, dvForm.getDocument().getDocumentNumber());
    // TODO: how should this forward be handled
    String url = UrlFactory.parameterizeUrl(getApplicationBaseUrl() + "/kr/" + KRADConstants.LOOKUP_ACTION, props);
    dvForm.registerEditableProperty("methodToCall");
    return new ActionForward(url, true);
}
Also used : Properties(java.util.Properties) VendorAddress(org.kuali.kfs.vnd.businessobject.VendorAddress) ActionForward(org.apache.struts.action.ActionForward)

Aggregations

ActionForward (org.apache.struts.action.ActionForward)125 AbstractContest (cn.edu.zju.acm.onlinejudge.bean.AbstractContest)16 ActionMessages (org.apache.struts.action.ActionMessages)14 Problem (cn.edu.zju.acm.onlinejudge.bean.Problem)11 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)11 UserProfile (cn.edu.zju.acm.onlinejudge.bean.UserProfile)9 ActionMessage (org.apache.struts.action.ActionMessage)9 KualiDocumentFormBase (org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase)8 IWantDocument (edu.cornell.kfs.module.purap.document.IWantDocument)7 PurApFavoriteAccountLineBuilderForIWantDocument (edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)7 ActionMapping (org.apache.struts.action.ActionMapping)7 UserContext (org.mifos.security.util.UserContext)7 IOException (java.io.IOException)6 Date (java.util.Date)6 AuthorizationPersistence (cn.edu.zju.acm.onlinejudge.persistence.AuthorizationPersistence)5 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 List (java.util.List)5 Cookie (javax.servlet.http.Cookie)5 IWantDocumentService (edu.cornell.kfs.module.purap.document.service.IWantDocumentService)4