Package com.opensymphony.xwork2.config.entities

Examples of com.opensymphony.xwork2.config.entities.ResultTypeConfig


public class SimpleServletConfigInterceptor extends AbstractInterceptor implements StrutsStatics {
  private static final long serialVersionUID = -595817586173434580L;

  public String intercept(ActionInvocation invocation) throws Exception {
    final Object action = invocation.getAction();
    final ActionContext context = invocation.getInvocationContext();

    if (action instanceof ServletRequestAware) {
      HttpServletRequest request = (HttpServletRequest) context.get(HTTP_REQUEST);
      ((ServletRequestAware) action).setServletRequest(request);
    }

    if (action instanceof ServletResponseAware) {
      HttpServletResponse response = (HttpServletResponse) context.get(HTTP_RESPONSE);
      ((ServletResponseAware) action).setServletResponse(response);
    }

    return invocation.invoke();
  }
View Full Code Here


  public Map<String, List<String>> getFieldErrors() {
    return validationAware.getFieldErrors();
  }

  public Locale getLocale() {
    ActionContext ctx = ActionContext.getContext();
    if (ctx != null) {
      return ctx.getLocale();
    } else {
      logger.debug("Action context not initialized");
      return null;
    }
  }
View Full Code Here

  protected ClassLoaderInterface getClassLoaderInterface() {
    if (isReloadEnabled()) return new ClassLoaderInterfaceDelegate(reloadingClassLoader);
    else {
      ClassLoaderInterface classLoaderInterface = null;
      ActionContext ctx = ActionContext.getContext();
      if (ctx != null) classLoaderInterface = (ClassLoaderInterface) ctx
          .get(ClassLoaderInterface.CLASS_LOADER_INTERFACE);
      return (ClassLoaderInterface) ObjectUtils.defaultIfNull(classLoaderInterface,
          new ClassLoaderInterfaceDelegate(getClassLoader()));
    }
  }
View Full Code Here

   
    if (!(action instanceof ActionSupport)) {
      log.warn("Full Hibernate Plugin Validation Allowed only in Actions that 'ISA' ActionSupport");
      return invocation.invoke();
    }
    ActionSupport actionAs = (ActionSupport) action;
    log.debug("Full Hibernate Plugin Validation in "+actionAs.getClass());
   
    Locale clientLocale = actionAs.getLocale();
   
//    List<InvalidValue> invalidValuesFromRequest = new ArrayList<InvalidValue>();
   
    Collection invalidValuesFromRequest = validator.validate(actionAs, clientLocale,getClass().getClassLoader());
    /*
    ResourceBundle clientResourceBundle = ResourceBundle.getBundle("org.hibernate.validator.resources.DefaultValidatorMessages", clientLocale, this.getClass().getClassLoader());
    InputStream stream = getClass().getResourceAsStream("/ValidatorMessages.properties");
    ClassValidator actionValidator = null;
    if (stream!=null) {
      PluginValidatorMessages validatorMessages = new PluginValidatorMessages(stream);
      validatorMessages.setParent(clientResourceBundle);
      actionValidator = new ClassValidator(action.getClass(),validatorMessages);
    } else {
      actionValidator = new ClassValidator(action.getClass(),clientResourceBundle);
    }
   
    // take all errors but discard when the field do not came from the request
    // Only the first validation error by field is used.
    InvalidValue[] invalidValues = actionValidator.getInvalidValues(action);
    List<String> invalidFieldNames = new ArrayList<String>();
    Map parameters = ActionContext.getContext().getParameters();
    for (InvalidValue invalidValue : invalidValues) {
      String fieldFullName = invalidValue.getPropertyPath();
      if (invalidFieldNames.contains(fieldFullName))
        continue;
      if (parameters.containsKey(fieldFullName)) {
        invalidValuesFromRequest.add(invalidValue);
        invalidFieldNames.add(fieldFullName);
      }
    }
    invalidValues=null;
    invalidFieldNames.clear();
    invalidFieldNames=null;
    actionValidator=null;
    */
    if (invalidValuesFromRequest.isEmpty()) {
      log.debug("Full Hibernate Plugin Validation found no erros.");
      actionAs.validate();
      if (actionAs.hasActionErrors() || actionAs.hasFieldErrors()) {
        log.debug("Full Hibernate Plugin found custom validation errors: "+actionAs.getFieldErrors()+" "+actionAs.getActionErrors());
        return actionAs.input();
      }
      else {
        return invocation.invoke();
      }
    } else {
      validator.addFieldErrors(actionAs, invalidValuesFromRequest);
      /*for (InvalidValue invalidValue : invalidValuesFromRequest) {
        StringBuilder sbMessage = new StringBuilder(actionAs.getText(invalidValue.getPropertyPath(),""));
        if (sbMessage.length()>0)
          sbMessage.append(" - ");
        sbMessage.append(actionAs.getText(invalidValue.getMessage()));
        actionAs.addFieldError(invalidValue.getPropertyPath(), sbMessage.toString());
      }*/
      log.debug("Full Hibernate Plugin Validation found "+actionAs.getFieldErrors().size()+" validation Errors.");
      actionAs.validate();
      if (action instanceof Preparable) {
        Method methodPrepare = Preparable.class.getDeclaredMethod("prepare");
        methodPrepare.invoke(action);
      }
      return actionAs.input();
    }

  }
View Full Code Here

  public void test21() {
    ActionBuilder actionNameBuilder = new DefaultActionBuilder();
    ProfileService profileService = new ProfileServiceImpl();
    actionNameBuilder.setProfileService(profileService);

    ObjectFactory of = new ObjectFactory();
    final DummyContainer mockContainer = new DummyContainer();
    Configuration configuration = new DefaultConfiguration() {
      @Override
      public Container getContainer() {
        return mockContainer;
View Full Code Here

   *
   * @return reference to field with TextProvider
   */
  private TextProvider getTextProvider() {
    if (textProvider == null) {
      TextProviderFactory tpf = new TextProviderFactory();
      if (container != null) {
        container.inject(tpf);
      }
      textProvider = tpf.createInstance(getClass(), this);
    }
    return textProvider;
  }
View Full Code Here

    ProfileService profileService = new ProfileServiceImpl();
    actionNameBuilder.setProfileService(profileService);

    ObjectFactory of = new ObjectFactory();
    final DummyContainer mockContainer = new DummyContainer();
    Configuration configuration = new DefaultConfiguration() {
      @Override
      public Container getContainer() {
        return mockContainer;
      }
    };
    PackageConfig strutsDefault = makePackageConfig("beangle", null, null, "dispatcher", null, null, null);
    configuration.addPackageConfig("beangle", strutsDefault);
    // ResultMapBuilder resultMapBuilder =
    // createStrictMock(ResultMapBuilder.class);
    // set beans on mock container
    mockContainer.setActionNameBuilder(actionNameBuilder);
    // mockContainer.setResultMapBuilder(resultMapBuilder);
    // mockContainer.setConventionsService(new ConventionsServiceImpl(""));

    SmartActionConfigBuilder builder = new SmartActionConfigBuilder(configuration, mockContainer, of);
    builder.setActionBuilder(actionNameBuilder);
    builder.buildActionConfigs();
    Set<String> names = configuration.getPackageConfigNames();
    for (String a : names) {
      System.out.println("pkgname:" + a);
      PackageConfig pkgConfig = configuration.getPackageConfig(a);
      System.out.println("namespace:" + pkgConfig.getNamespace());
      Map<String, ActionConfig> configs = pkgConfig.getAllActionConfigs();
      for (String actionName : configs.keySet()) {
        ActionConfig config = configs.get(actionName);
        System.out.println(config.getClassName());
View Full Code Here

    }
    if (null == parentPkg) {
      actionPkg = defaultParentPackage;
      parentPkg = configuration.getPackageConfig(actionPkg);
    }
    if (parentPkg == null) { throw new ConfigurationException("Unable to locate parent package ["
        + actionClass.getPackage().getName() + "]"); }
    String actionPackage = actionClass.getPackage().getName();
    PackageConfig.Builder pkgConfig = packageConfigs.get(actionPackage);
    if (pkgConfig == null) {
      PackageConfig myPkg = configuration.getPackageConfig(actionPackage);
View Full Code Here

      System.out.println("pkgname:" + a);
      PackageConfig pkgConfig = configuration.getPackageConfig(a);
      System.out.println("namespace:" + pkgConfig.getNamespace());
      Map<String, ActionConfig> configs = pkgConfig.getAllActionConfigs();
      for (String actionName : configs.keySet()) {
        ActionConfig config = configs.get(actionName);
        System.out.println(config.getClassName());
        System.out.println(config.getName());
        System.out.println(config.getMethodName());
      }
    }
  }
View Full Code Here

    String actionName = action.getName();
    // check action exists on that package (from XML config probably)
    PackageConfig existingPkg = configuration.getPackageConfig(pkgCfg.getName());
    boolean create = true;
    if (existingPkg != null) {
      ActionConfig existed = existingPkg.getActionConfigs().get(actionName);
      create = (null == existed);
    }
    if (create) {
      pkgCfg.addActionConfig(actionName, actionConfig.build());
      logger.debug("Add {}/{} for {} in {}", new Object[] { pkgCfg.getNamespace(), actionName,
View Full Code Here

TOP

Related Classes of com.opensymphony.xwork2.config.entities.ResultTypeConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.