Package org.beangle.struts2.action

Examples of org.beangle.struts2.action.ActionTextResource


  protected String redirect(String method, String message, String params) {
    return redirect(new Action((String) null, method, params), message);
  }

  protected String redirect(String method) {
    return redirect(new Action(method), null);
  }
View Full Code Here


   * @param method
   * @param message
   * @return
   */
  protected String redirect(String method, String message) {
    return redirect(new Action(method), message);
  }
View Full Code Here

      case 0:
        logger.warn("Cannot find bean definition for {}.", actionClass);
        break;
      case 1:
        Profile profile = actionBuilder.getProfileService().getProfile(actionClass.getName());
        Action action = actionBuilder.build(actionClass.getName());
        PackageConfig.Builder packageConfig = getPackageConfig(profile, packageConfigs, action,
            actionClass);
        if (createActionConfig(packageConfig, action, actionClass, beanNames[0])) {
          createCount++;
        }
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

        avatarBase.updateAvatar(getUsername(), files[0], type);
      } else {
        return forward("upload");
      }
    }
    return redirect(new Action(MyAction.class, "info"), "info.upload.success");
  }
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

TOP

Related Classes of org.beangle.struts2.action.ActionTextResource

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.