Package de.iritgo.aktera.struts

Examples of de.iritgo.aktera.struts.BeanRequest


          {
            parameters.put(key, request.getParameter(key));
          }
        }

        BeanRequest uiRequest = new BeanRequest();

        uiRequest.setLocale(request.getLocale());
        uiRequest.setBean(beanName.replace("_BEAN_.", ""));
        uiRequest.setParameters(parameters);
        uiRequest.setUserEnvironment(request.getUserEnvironment());

        BeanResponse uiResponse = new BeanResponse();

        BeanAction.execute(uiRequest, uiResponse);

        if (! UIController.DEFAULT_FORWARD.equals(uiResponse.getForward()))
        {
          response.setForward(uiResponse.getForward());
        }

        for (Map.Entry<String, ResponseElement> re : uiResponse.getElements().entrySet())
        {
          response.add(re.getValue());
        }

        for (Map.Entry<String, String> error : uiResponse.getErrors().entrySet())
        {
          response.addError(error.getKey(), error.getValue());
        }
      }
      catch (AuthorizationException x)
      {
        throw new UIControllerException(x);
      }
      catch (UIControllerException x)
      {
        throw new UIControllerException(x);
      }
    }

    if (response.getForward() == null)
    {
      String listingBeanName = (String) request.getParameter("_lm");
      BeanRequest uiRequest = new BeanRequest();

      uiRequest.setLocale(request.getLocale());
      uiRequest.setBean(listingBeanName.replace("_BEAN_.", ""));

      Map<String, Object> parameters = new HashMap();

      for (Iterator i = request.getParameters().keySet().iterator(); i.hasNext();)
      {
        String key = (String) i.next();

        if (key.startsWith("_lp"))
        {
          parameters.put(key.substring(3), request.getParameter(key));
        }
      }

      uiRequest.setParameters(parameters);
      uiRequest.setUserEnvironment(request.getUserEnvironment());

      try
      {
        BeanAction.execute(uiRequest, response);
      }
View Full Code Here


  }

  public void execute(UIRequest request, UIResponse response) throws UIControllerException
  {
    UIController controller = (UIController) SpringTools.getBean(request.getParameterAsString("_cmodel"));
    BeanRequest newRequest = new BeanRequest();

    newRequest.setBean(request.getParameterAsString("_cmodel"));
    newRequest.setLocale(request.getLocale());
    newRequest.setUserEnvironment(request.getUserEnvironment());

    for (Object entry : request.getParameters().entrySet())
    {
      String key = (String) ((Map.Entry) entry).getKey();

      if (key.startsWith("_cp") && ! "_cmodel".equals(key))
      {
        newRequest.setParameter(key.substring(3), ((Map.Entry) entry).getValue());
      }
    }

    controller.execute(newRequest, response);
  }
View Full Code Here

      }

      if (NumberTools.toBool(request.getParameter("AKTERA_auto"), false))
      {
        String bean = cmdPage != null && cmdPage.getModel() != null ? cmdPage.getModel() : cmdEdit.getModel();
        BeanRequest newRequest = new BeanRequest();
        newRequest.setBean(bean);
        newRequest.setLocale(request.getLocale());
        newRequest.setUserEnvironment(request.getUserEnvironment());
        for (Iterator i = request.getParameters().keySet().iterator(); i.hasNext();)
        {
          String key = (String) i.next();

          if (! "model".equals(key) && ! "SEQUENCE_NAME".equals(key) && ! "SEQUENCE_NUMBER".equals(key))
          {
            newRequest.setParameter(key, request.getParameters().get(key));
          }
        }
        newRequest.setParameter(keyName, id);
        newRequest.setParameter("reedit", "Y");
        if (request.getParameter("ajax") != null)
        {
          newRequest.setParameter("ajax", "Y");
        }
        redirect(bean, newRequest, response);
        return;
      }

      handler.preStorePersistents(wrappedRequest, formular, formular.getPersistents(), new Boolean(modified));

      if (request.getParameter(NO_FORM_STORE) == null && validate
              && ! NumberTools.toBool(request.getParameter(SYSTEM_EDIT), false))
      {
        ValidationResult result = null;

        try
        {
          result = FormTools.validateInput(wrappedRequest, wrappedResponse, formular, formular
                  .getPersistents());
          handler.validatePersistents(persistentConfig, wrappedRequest, wrappedResponse, formular, formular
                  .getPersistents(), NumberTools.toInt(id, - 1) == - 1, result);
        }
        catch (Exception x)
        {
          System.out.println("[Save] Error while validating input: " + x);
          x.printStackTrace();
        }

        if (result.hasErrors())
        {
          formular.setPage(Math.max(formular.getPageWithField(result.getFirstErrorField(formular).replaceAll(
                  "_", ".")), 0));
        }

        result.createResponseElements(wrappedResponse, formular);

        if (result.hasErrors())
        {
          if (! NumberTools.toBool(request.getParameter(SYSTEM_EDIT), false))
          {
            BeanRequest newRequest = new BeanRequest();
            newRequest.setBean(cmdEdit.getModel());
            newRequest.setLocale(request.getLocale());
            newRequest.setUserEnvironment(request.getUserEnvironment());
            newRequest.setParameter(keyName, id);
            newRequest.setParameter("error", result.getFirstErrorField(formular));
            redirect(cmdEdit.getModel(), newRequest, response);
            return;
          }
          else
          {
            return;
          }
        }
      }

      if (NumberTools.toInt(id, - 1) != - 1)
      {
        try
        {
          handler.updatePersistents(wrappedRequest, formular, formular.getPersistents(), persistentConfig,
                  modified);
        }
        catch (Exception x)
        {
          logger.error("Unable to update persistents: " + x);
          throw new ModelException(x);
        }

        if (! preserveContext)
        {
          UserTools.removeContextObject(wrappedRequest, persistentsId);
        }
      }
      else
      {
        id = new Integer(handler.createPersistents(wrappedRequest, formular, formular.getPersistents(),
                persistentConfig));

        if (NumberTools.toInt(id, - 1) != - 1)
        {
          if (! preserveContext)
          {
            UserTools.removeContextObject(wrappedRequest, FormTools.createContextKey(contextId, - 1));
          }
          else
          {
            UserTools.setContextObject(wrappedRequest, FormTools.createContextKey(contextId, id), formular);
          }
        }
      }

      if (! NumberTools.toBool(request.getParameter(SYSTEM_EDIT), false))
      {
        context.setSaveId(id);
        BeanRequest newRequest = new BeanRequest();
        cmdOk.setParameters(newRequest, context);
        newRequest.setBean(cmdOk.getModel());
        newRequest.setLocale(request.getLocale());
        newRequest.setUserEnvironment(request.getUserEnvironment());
        redirect(cmdOk.getModel(), newRequest, response);
        return;
      }
      else
      {
View Full Code Here

          {
            parameters.put(key, req.getParameter(key));
          }
        }

        BeanRequest uiRequest = new BeanRequest();

        uiRequest.setLocale(req.getLocale());
        uiRequest.setBean(modelName.replace("_BEAN_.", ""));
        uiRequest.setParameters(parameters);
        uiRequest.setUserEnvironment((UserEnvironment) req.getContext().get(UserEnvironment.CONTEXT_KEY));

        BeanResponse uiResponse = new BeanResponse();

        BeanAction.execute(uiRequest, uiResponse);
View Full Code Here

TOP

Related Classes of de.iritgo.aktera.struts.BeanRequest

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.