Package com.opensymphony.xwork2.validator.validators

Examples of com.opensymphony.xwork2.validator.validators.FieldExpressionValidator


  private UserVO vo;
 
  public String execute(){
    String result = "";
    int sabun = 0;   
    ActionContext context = ActionContext.getContext();
    Map<String, UserVO> userMap = context.getSession();
    vo = userMap.get("user");
    try {
      sabun = vo.getSabun();
    } catch (NullPointerException e) {
      sabun = 0;
View Full Code Here


    }   
    return result;   
  }
 
  public int getSessionSabun(){
    ActionContext context = ActionContext.getContext();
    Map<String, UserVO> userMap = context.getSession();
    UserVO vo = userMap.get("user");
    int sabun = vo.getSabun();
    return sabun;
  }
View Full Code Here

      // 직급 테이블로부터 얻어온 보안등급 초기값 설정     
      uVO.setSlevel(orgDAO.getSlevel(uVO.getJobno()));
      // 실제 업데이트 수행
      userDAO.updateUser(uVO);
      // 수정된 vo객체를 세션에 저장
      ActionContext context = ActionContext.getContext();
      Map<String, UserVO> session = (Map<String, UserVO>)context.getSession();
      uVO = userDAO.getUserInfo(uVO.getSabun());
      session.put("user", uVO);       
      context.setSession(session);     
      result = "success";
    } catch (Exception e) {
      System.out.println("UserInputAction.updateUser():"+e.toString());     
      result = "error";
    }
View Full Code Here

import com.opensymphony.xwork2.ActionContext;
public class UserLogoutAction {
  public String execute(){
    try {
      // 세션에 저장된 유저정보를 삭제한다
      ActionContext context = ActionContext.getContext();
      Map<String, UserVO> session = context.getSession();     
      session.remove("user");
      context.setSession(session);     
    } catch (Exception e) {
      System.out.println("UserLogoutAction.execute():"+e.toString());
    }
    return "success";
  }
View Full Code Here

  }
 
  public String getUserInfo(){
    String result = "";
    try {     
      ActionContext context = ActionContext.getContext();
      vo = (UserVO) context.getSession().get("user");
      vo = userDAO.getUserInfo(vo.getSabun());
      jlist = orgDAO.getJobList();
      dlist = orgDAO.getDeptList();
      result = "success";
    } catch (Exception e) {
View Full Code Here

  public String intercept(ActionInvocation invoc) throws Exception {
    String result = "";
    try {
      jlist = orgDAO.getJobList();
      dlist = orgDAO.getDeptList();     
      ActionContext ac = ActionContext.getContext();
      Map<String, List> orgMap = ac.getParameters();
      orgMap.put("jlist", jlist);
      orgMap.put("dlist", dlist);
     
      result = "success";
    } catch (Exception e) {
View Full Code Here

        assertNotNull(result);
        assertTrue(result instanceof ServletRedirectResult);

        Mock invMock = new Mock(ActionInvocation.class);
        ActionInvocation inv = (ActionInvocation) invMock.proxy();
        ActionContext ctx = ActionContext.getContext();
        ctx.put(ServletActionContext.HTTP_REQUEST, request);
        StrutsMockHttpServletResponse response = new StrutsMockHttpServletResponse();
        ctx.put(ServletActionContext.HTTP_RESPONSE, response);
        invMock.expectAndReturn("getInvocationContext", ctx);
        invMock.expectAndReturn("getStack", ctx.getValueStack());
        result.execute(inv);
        assertEquals("http://www.google.com", response.getRedirectURL());
        //TODO: need to test location but there's noaccess to the property/method, unless we use reflection
    }
View Full Code Here

    }

    protected String lookupExtension(String extension) {
        if (extension == null) {
            // Look for the current extension, if available
            ActionContext context = ActionContext.getContext();
            if (context != null) {
                ActionMapping orig = (ActionMapping) context.get(ServletActionContext.ACTION_MAPPING);
                if (orig != null) {
                    extension = orig.getExtension();
                }
            }
            if (extension == null) {
View Full Code Here

   * @see
   * com.opensymphony.xwork2.interceptor.Interceptor#intercept(com.opensymphony
   * .xwork2.ActionInvocation)
   */
  public String intercept(ActionInvocation invocation) throws Exception {
    ActionContext ac = invocation.getInvocationContext();

    HttpServletRequest request = (HttpServletRequest) ac
        .get(ServletActionContext.HTTP_REQUEST);

    if (!(request instanceof GaeMultiPartRequestWrapper)) {
      if (LOG.isDebugEnabled()) {
        ActionProxy proxy = invocation.getProxy();
        LOG.debug(getTextMessage(
            "struts.messages.bypass.request",
            new Object[] { proxy.getNamespace(),
                proxy.getActionName() }, ac.getLocale()));
      }

      return invocation.invoke();
    }

    ValidationAware validation = null;

    Object action = invocation.getAction();

    if (action instanceof ValidationAware) {
      validation = (ValidationAware) action;
    }

    GaeMultiPartRequestWrapper multiWrapper = (GaeMultiPartRequestWrapper) request;

    if (multiWrapper.hasErrors()) {
      for (String error : multiWrapper.getErrors()) {
        if (validation != null) {
          validation.addActionError(error);
        }

        LOG.error(error);
      }
    }

    // bind allowed Files
    Enumeration<String> fileParameterNames = multiWrapper
        .getFileParameterNames();
    while (fileParameterNames != null
        && fileParameterNames.hasMoreElements()) {
      // get the value of this input tag
      String inputName = fileParameterNames.nextElement();

      // get the content type
      String[] contentType = multiWrapper.getContentTypes(inputName);

      if (isNonEmpty(contentType)) {
        // get the name of the file from the input tag
        String[] fileName = multiWrapper.getFileNames(inputName);

        if (isNonEmpty(fileName)) {

          String[] fileItemStreams = multiWrapper
              .getFileContents(inputName);
          // get a File object for the uploaded File
          if (fileItemStreams != null && fileItemStreams.length > 0) {
            List<String> acceptedFiles = new ArrayList<String>(
                fileItemStreams.length);
            List<String> acceptedContentTypes = new ArrayList<String>(
                fileItemStreams.length);
            List<String> acceptedFileNames = new ArrayList<String>(
                fileItemStreams.length);
            String contentTypeName = inputName + "ContentType";
            String fileNameName = inputName + "FileName";

            for (int index = 0; index < fileItemStreams.length; index++) {
              if (acceptFile(action, fileItemStreams[index],
                  fileName[index], contentType[index],
                  inputName, validation, ac.getLocale())) {
                acceptedFiles.add((fileItemStreams[index]));
                acceptedContentTypes.add(contentType[index]);
                acceptedFileNames.add(fileName[index]);
              }
            }

            if (!acceptedFiles.isEmpty()) {
              Map<String, Object> params = ac.getParameters();

              params.put(inputName, acceptedFiles
                  .toArray(new String[acceptedFiles.size()]));
              params.put(contentTypeName, acceptedContentTypes
                  .toArray(new String[acceptedContentTypes
                      .size()]));
              params.put(fileNameName, acceptedFileNames
                  .toArray(new String[acceptedFileNames
                      .size()]));
            }
          }
        } else {
          LOG.error(getTextMessage(action,
              "struts.messages.invalid.file",
              new Object[] { inputName }, ac.getLocale()));
        }
      } else {
        LOG.error(getTextMessage(action,
            "struts.messages.invalid.content.type",
            new Object[] { inputName }, ac.getLocale()));
      }
    }

    // invoke action
    String result = invocation.invoke();
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

TOP

Related Classes of com.opensymphony.xwork2.validator.validators.FieldExpressionValidator

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.