@Override
  public void present(IWContext iwc) throws Exception {
    this.iwrb = getResourceBundle(iwc);
    this.iwb = getBundle(iwc);

    List<ICLocale> locales = ICLocaleBusiness.listOfLocales();

    String action = iwc.getParameter(PARAMETER_ACTION);
    if (ACTION_CREATE.equals(action)) {
      getCategoryCreationForm(iwc, null, locales);
    } else if (ACTION_EDIT.equals(action)) {
      ApplicationCategory category =
          getApplicationBusiness(iwc)
              .getApplicationCategoryHome()
              .findByPrimaryKey(Integer.parseInt(iwc.getParameter("id")));
      getCategoryCreationForm(iwc, category, locales);
    } else if (ACTION_SAVE.equals(action)) {
      String id = iwc.getParameter("id");
      String name = iwc.getParameter("name");
      String desc = iwc.getParameter("desc");
      String priority = iwc.getParameter("priority");

      if (name != null && !name.trim().equals("")) {
        ApplicationCategory cat = null;
        if (id != null) {
          try {
            cat =
                getApplicationBusiness(iwc)
                    .getApplicationCategoryHome()
                    .findByPrimaryKey(new Integer(iwc.getParameter("id")));
          } catch (FinderException f) {
            f.printStackTrace();
          }
        } else {
          cat = getApplicationBusiness(iwc).getApplicationCategoryHome().create();
        }

        cat.setName(name);
        cat.setDescription(desc);
        if (priority != null && !priority.equals("")) {
          cat.setPriority(new Integer(priority));
        }
        cat.store();

        for (Iterator<ICLocale> it = locales.iterator(); it.hasNext(); ) {
          ICLocale locale = it.next();
          String locName = iwc.getParameter(locale.getName() + "_locale");

          if (locName != null && !locName.equals("")) {
            LocalizedText locText = cat.getLocalizedText(locale.getLocaleID());
            boolean newText = false;
            if (locText == null) {
              locText = getLocalizedTextHome().create();
              newText = true;
            }

            locText.setLocaleId(locale.getLocaleID());
            locText.setBody(locName);

            locText.store();

            if (newText) {
              cat.addLocalizedName(locText);
            }
          }
        }

        IWCacheManager.getInstance(iwc.getIWMainApplication())
            .invalidateCache(ApplicationCategoryViewer.CACHE_KEY);
        IWCacheManager.getInstance(iwc.getIWMainApplication())
            .invalidateCache(ApplicationFavorites.CACHE_KEY);
      }
      listExisting(iwc);
    } else if (ACTION_CATEGORY_UP.equals(action)) {
      String id = iwc.getParameter("id");

      ApplicationCategory cat = null;
      if (id != null) {
        try {
          cat =
              getApplicationBusiness(iwc)
                  .getApplicationCategoryHome()
                  .findByPrimaryKey(new Integer(id));
        } catch (FinderException f) {
          f.printStackTrace();
        }
      }
      Integer priority = cat.getPriority();
      ApplicationCategory upperCat = null;
      if (priority != null) {
        try {
          upperCat =
              getApplicationBusiness(iwc)
                  .getApplicationCategoryHome()
                  .findByPriority(priority.intValue() - 1);
          upperCat.setPriority(-1);
          upperCat.store();
        } catch (FinderException f) {
          f.printStackTrace();
        }
        cat.setPriority(priority.intValue() - 1);
      }

      cat.store();

      if (upperCat != null) {
        upperCat.setPriority(priority.intValue());
        upperCat.store();
      }

      clearApplicationCategoryViewerCache(iwc);

      listExisting(iwc);
    } else if (ACTION_CATEGORY_DOWN.equals(action)) {
      String id = iwc.getParameter("id");

      ApplicationCategory cat = null;
      if (id != null) {
        try {
          cat =
              getApplicationBusiness(iwc)
                  .getApplicationCategoryHome()
                  .findByPrimaryKey(new Integer(id));
        } catch (FinderException f) {
          f.printStackTrace();
        }
      }
      Integer priority = cat.getPriority();
      ApplicationCategory lowerCat = null;
      if (priority != null) {
        try {
          lowerCat =
              getApplicationBusiness(iwc)
                  .getApplicationCategoryHome()
                  .findByPriority(priority.intValue() + 1);
          lowerCat.setPriority(-1);
          lowerCat.store();
        } catch (FinderException f) {
          f.printStackTrace();
        }
        cat.setPriority(priority.intValue() + 1);
      }

      cat.store();

      if (lowerCat != null) {
        lowerCat.setPriority(priority.intValue());
        lowerCat.store();
      }

      clearApplicationCategoryViewerCache(iwc);

      listExisting(iwc);
    } else if (ACTION_APP_UP.equals(action)) {
      String appId = iwc.getParameter("app_id");
      String id = iwc.getParameter("id");

      Application app = null;
      ApplicationCategory category = null;
      if (appId != null) {
        try {
          app =
              getApplicationBusiness(iwc).getApplicationHome().findByPrimaryKey(new Integer(appId));
        } catch (FinderException f) {
          f.printStackTrace();
        }
      }
      Integer priority = app.getPriority();
      Application upperApp = null;
      if (priority != null) {
        try {
          category =
              getApplicationBusiness(iwc)
                  .getApplicationCategoryHome()
                  .findByPrimaryKey(new Integer(id));

          upperApp =
              getApplicationBusiness(iwc)
                  .getApplicationHome()
                  .findByCategoryAndPriority(category, priority.intValue() - 1);
          upperApp.setPriority(-1);
          upperApp.store();
        } catch (FinderException f) {
          f.printStackTrace();
        }
        app.setPriority(priority.intValue() - 1);
      }

      app.store();

      if (upperApp != null) {
        upperApp.setPriority(priority.intValue());
        upperApp.store();
      }

      clearApplicationCategoryViewerCache(iwc);

      getCategoryCreationForm(iwc, category, locales);
    } else if (ACTION_APP_DOWN.equals(action)) {
      String appId = iwc.getParameter("app_id");
      String id = iwc.getParameter("id");

      Application app = null;
      ApplicationCategory category = null;
      if (appId != null) {
        try {
          app =
              getApplicationBusiness(iwc).getApplicationHome().findByPrimaryKey(new Integer(appId));
        } catch (FinderException f) {
          f.printStackTrace();
        }
      }
      Integer priority = app.getPriority();
      Application lowerApp = null;
      if (priority != null) {
        try {
          category =
              getApplicationBusiness(iwc)
                  .getApplicationCategoryHome()
                  .findByPrimaryKey(new Integer(id));

          lowerApp =
              getApplicationBusiness(iwc)
                  .getApplicationHome()
                  .findByCategoryAndPriority(category, priority.intValue() + 1);
          lowerApp.setPriority(-1);
          lowerApp.store();
        } catch (FinderException f) {
          f.printStackTrace();
        }
        app.setPriority(priority.intValue() + 1);
      }

      app.store();

      if (lowerApp != null) {
        lowerApp.setPriority(priority.intValue());
        lowerApp.store();
      }

      clearApplicationCategoryViewerCache(iwc);

      getCategoryCreationForm(iwc, category, locales);
    } else if (ACTION_DELETE.equals(action)) {
      try {
        ApplicationCategory cat =
            getApplicationBusiness(iwc)
                .getApplicationCategoryHome()
                .findByPrimaryKey(new Integer(iwc.getParameter("id")));
        cat.remove();
      } catch (FinderException f) {
        f.printStackTrace();
      }
      listExisting(iwc);
    } else if (ACTION_LIST.equals(action)) {
      listExisting(iwc);
    } else {
      listExisting(iwc);
    }
  }