Package org.beangle.struts2.convention.route

Examples of org.beangle.struts2.convention.route.Action


      } else {
        addActionError("不支持的文件类型");
        return forward("info");
      }
    }
    return redirect(new Action(UserAction.class, "info", "&user.name=" + userName), "info.save.success");
  }
View Full Code Here


    String testResult = codeGenerator.test(codeFixture);
    if (null == testResult) {
      testResult = "null";
    }
    put("testResult", testResult);
    return forward(new Action(this.getClass(), "edit"));
  }
View Full Code Here

        updated.add(newCategory);
      }
    }
    if (duplicatedNames.size() > 0) {
      addFlashErrorNow("dictionary.error.duplicateCategoryName", StrUtils.join(duplicatedNames,","));
      return forward(new Action(this, "categories"));
    } else {
      entityDao.save(updated);
      return redirect("categories", "info.save.success");
    }
  }
View Full Code Here

    if (!error) {
      addFlashMessage("info.save.success");
      entityDao.saveOrUpdate(meta);
      return redirect("index");
    } else {
      return forward(new Action(this, "edit"));
    }
  }
View Full Code Here

@Test
public class SmartActionConfigBuilderTest {

  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
View Full Code Here

      throw new RuntimeException(e);
    }
  }

  public Profile getProfile(String className) {
    Profile matched = cache.get(className);
    if (null != matched) { return matched; }
    int index = -1;
    int patternLen = 0;
    for (Profile profile : profiles) {
      int newIndex = profile.matchedIndex(className);
View Full Code Here

  private List<Profile> buildProfiles(URL url, boolean isDefault) {
    List<Profile> myProfiles = CollectUtils.newArrayList();
    Properties props = getProperties(url);
    if (isDefault) {
      Profile profile = populatProfile(props, "default");
      myProfiles.add(profile);
    } else {
      int profileIndex = 0;
      while (true) {
        Profile profile = populatProfile(props, "profile" + profileIndex);
        if (null == profile) {
          break;
        } else {
          myProfiles.add(profile);
        }
View Full Code Here

    }
    return myProfiles;
  }

  private Profile populatProfile(Properties props, String name) {
    Profile profile = new Profile();
    profile.setName(name);
    String actionPattern = props.getProperty(profile.getName() + ".actionPattern");
    if (isEmpty(actionPattern)) { return null; }
    populateAttr(profile, "actionPattern", props);
    populateAttr(profile, "actionSuffix", props);
    populateAttr(profile, "viewPath", props);
    populateAttr(profile, "viewExtension", props);
View Full Code Here

   */
  public String getViewPath(String className, String methodName, String viewName) {
    if (StringUtils.isNotEmpty(viewName)) {
      if (viewName.charAt(0) == Constants.separator) { return viewName; }
    }
    Profile profile = profileServie.getProfile(className);
    if (null == profile) { throw new RuntimeException("no convention profile for " + className); }
    StringBuilder buf = new StringBuilder();
    if (profile.getViewPathStyle().equals(Constants.FULL_VIEWPATH)) {
      buf.append(Constants.separator);
      buf.append(profile.getSimpleName(className));
    } else if (profile.getViewPathStyle().equals(Constants.SIMPLE_VIEWPATH)) {
      buf.append(profile.getViewPath());
      // 添加中缀路径
      buf.append(profile.getInfix(className));
    } else if (profile.getViewPathStyle().equals(Constants.SEO_VIEWPATH)) {
      buf.append(profile.getViewPath());
      buf.append(StrUtils.unCamel(profile.getInfix(className)));
    } else {
      throw new RuntimeException(profile.getViewPathStyle() + " was not supported");
    }
    // add method mapping path
    buf.append(Constants.separator);
    if (StringUtils.isEmpty(viewName) || viewName.equals("success")) {
      viewName = methodName;
View Full Code Here

   *
   * @param clazz
   * @return
   */
  public Action build(String className) {
    Profile profile = profileService.getProfile(className);
    Action action = new Action();
    StringBuilder sb = new StringBuilder();
    // namespace
    sb.append(profile.getUriPath());
    if (Constants.SHORT_URI.equals(profile.getUriPathStyle())) {
      String simpleName = className.substring(className.lastIndexOf('.') + 1);
      sb.append(StringUtils.uncapitalize(simpleName.substring(0, simpleName.length()
          - profile.getActionSuffix().length())));
    } else if (Constants.SIMPLE_URI.equals(profile.getUriPathStyle())) {
      sb.append(profile.getInfix(className));
    } else if (Constants.SEO_URI.equals(profile.getUriPathStyle())) {
      sb.append(StrUtils.unCamel(profile.getInfix(className)));
    } else {
      throw new RuntimeException("unsupported uri style " + profile.getUriPathStyle());
    }
    action.path(sb.toString()).method(profile.getDefaultMethod()).extention(profile.getUriExtension());
    return action;
  }
View Full Code Here

TOP

Related Classes of org.beangle.struts2.convention.route.Action

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.