Package com.opensymphony.xwork2.config.providers

Examples of com.opensymphony.xwork2.config.providers.MockConfigurationProvider


        return context.getSession().get(key);
    }
   
    protected void putActionObject(String name, Object item)
    {   // Put object
        ActionContext context = ActionContext.getContext();
        String key = getActionObjectName(context, name);
        if (key!=null)
            context.getSession().put(key, item);
    }
View Full Code Here


            context.getSession().put(key, item);
    }
   
    protected void removeActionObject(String name)
    {   // Clear object
        ActionContext context = ActionContext.getContext();
        String key = getActionObjectName(context, name);
        if (key!=null)
            context.getSession().remove(key);
    }
View Full Code Here

    public Object getActionBean(Class objClass, boolean create, String ownerProperty)
    {
        if (objClass==null)
            return null;
        // get the object key
        ActionContext context = ActionContext.getContext();
        String key = getActionBeanName(context, objClass, ownerProperty);
        if (key==null)
            return null;
        // get the object from the session
        Object obj = context.getSession().get(key);
        if (obj==null && create)
        {   try {
                obj = objClass.newInstance();
                context.getSession().put(key, obj);
            } catch(Exception e) {
                log.fatal("Cannot create Instance of type " + objClass.getName(), e);
            }
        }
        return obj;
View Full Code Here

        {   // Error
            log.error("Unable to store object on session. Object is null, a primitive type or a string!");
            return;
        }   
        // Put object
        ActionContext context = ActionContext.getContext();
        String key = getActionBeanName(context, obj.getClass(), ownerProperty);
        if (key!=null)
            context.getSession().put(key, obj);
    }
View Full Code Here

   
    public void removeActionBean(Class objClass, String propertyName)
    {
        if (objClass==null)
            return;
        ActionContext context = ActionContext.getContext();
        String key = getActionBeanName(context, objClass, propertyName);
        if (key!=null)
            context.getSession().remove(key);
    }
View Full Code Here

   
    // ------- Action Bean storage -------

    private ActionProxy getActionProxy(ActionContext context)
    {
        ActionInvocation invocation = context.getActionInvocation();
        if (invocation==null)
        {
            log.error("Action Invocation cannot be obtained. Calling from action constructor?");
            return null;
        }
        ActionProxy proxy = invocation.getProxy();
        if (proxy==null)
        {
            log.error("ActionProxy cannot be obtained. Calling from action constructor?");
            return null;
        }
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

    //  ------- Singleton getInstance -------
   
    public static TextProvider getInstance(Class clazz, LocaleProvider provider)
    {
        TextProvider instance=new TextProviderActionSupport(provider);
        if (instance instanceof ResourceBundleTextProvider)
        {
            ((ResourceBundleTextProvider) instance).setClazz(clazz);
        }
        return instance;
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

TOP

Related Classes of com.opensymphony.xwork2.config.providers.MockConfigurationProvider

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.