コード例 #1
0
ファイル: AccountAction.java プロジェクト: ParadoxHacker/jfox
  @ActionMethod(
      name = "newaccount",
      successView = "NewAccountForm.vhtml",
      httpMethod = ActionMethod.HttpMethod.GET)
  public void doGetNewAccount(ActionContext actionContext) throws Exception {
    // do nothing
    PageContext pageContext = actionContext.getPageContext();
    pageContext.setAttribute("languages", languages);

    List<Category> categories = categoryBO.getCategoryList();
    pageContext.setAttribute("categories", categories);
  }
コード例 #2
0
ファイル: AccountAction.java プロジェクト: ParadoxHacker/jfox
  /**
   * 在 doPostEdit 发生异常时,通过该方法设置 PageContext account, 以便跳转到 errorView 时,可以预设数据
   *
   * @param actionContext invocationContext
   */
  public void doActionFailed(ActionContext actionContext) {
    if (actionContext.getActionMethod().getName().equals("doPostEdit")) {
      SessionContext sessionContext = actionContext.getSessionContext();
      Account account = (Account) sessionContext.getAttribute(ACCOUNT_SESSION_KEY);

      PageContext pageContext = actionContext.getPageContext();
      pageContext.setAttribute("account", account);
      pageContext.setAttribute("languages", languages);

      List<Category> categories = categoryBO.getCategoryList();
      pageContext.setAttribute("categories", categories);
    } else if (actionContext.getActionMethod().getName().equals("doPostCreate")) {
      NewAccountParameterObject invocation =
          (NewAccountParameterObject) actionContext.getParameterObject();
      Account newAccount = EntityFactory.newEntityObject(Account.class);
      newAccount.setUsername(invocation.getUsername());
      newAccount.setStatus("OK");
      newAccount.setPassword(invocation.getPassword());
      newAccount.setAddress1(invocation.getAddress1());
      newAccount.setAddress2(invocation.getAddress2());
      newAccount.setBannerOption(invocation.getBannerOption());
      newAccount.setCity(invocation.getCity());
      newAccount.setCountry(invocation.getCountry());
      newAccount.setEmail(invocation.getEmail());
      newAccount.setFavouriteCategoryId(invocation.getFavouriteCategoryId());
      newAccount.setFirstName(invocation.getFirstName());
      newAccount.setLanguagePreference(invocation.getLanguagePreference());
      newAccount.setLastName(invocation.getLastName());
      newAccount.setListOption(invocation.getListOption());
      newAccount.setPassword(invocation.getPassword());
      newAccount.setPhone(invocation.getPhone());
      newAccount.setState(invocation.getState());
      newAccount.setZip(invocation.getZip());
      PageContext pageContext = actionContext.getPageContext();
      pageContext.setAttribute("account", newAccount);
      try {
        doGetNewAccount(actionContext);
      } catch (Exception e) {
        logger.error("doActionFailed error.", e);
      }
    }
  }
コード例 #3
0
ファイル: AccountAction.java プロジェクト: ParadoxHacker/jfox
  @ActionMethod(
      name = "editaccount",
      successView = "EditAccount.vhtml",
      errorView = "signon.vhtml",
      httpMethod = ActionMethod.HttpMethod.GET)
  public void doGetEditAccount(ActionContext actionContext) throws Exception {
    SessionContext sessionContext = actionContext.getSessionContext();
    Account account = (Account) sessionContext.getAttribute(ACCOUNT_SESSION_KEY);

    if (account == null) {
      throw new IllegalArgumentException("Not login, please login first!");
    }

    PageContext pageContext = actionContext.getPageContext();
    pageContext.setAttribute("account", account);
    pageContext.setAttribute("languages", languages);

    List<Category> categories = categoryBO.getCategoryList();
    pageContext.setAttribute("categories", categories);
  }