Class CmsCategoriesBean

java.lang.Object
io.goobi.viewer.managedbeans.CmsCategoriesBean
All Implemented Interfaces:
Serializable

@Named("cmsCategoriesBean") @SessionScoped public class CmsCategoriesBean extends Object implements Serializable
Managed Bean for editing, deleting and creating categories.
Author:
Florian Alpers
See Also:
  • Constructor Details

    • CmsCategoriesBean

      public CmsCategoriesBean()
  • Method Details

    • isValid

      public boolean isValid() throws DAOException
      Check if getCategoryName() is empty or equal (ignoring case) to the name of any existing category. If we are editing a category, obviously ignore this category for the check
      Returns:
      true if getCategoryName() returns a valid name for a category
      Throws:
      DAOException - if any.
    • edit

      public void edit(CMSCategory category)
      Start editing the given category. Editing will continue until either saveCategoryAction() or cancelAction() is executed
      Parameters:
      category - The category to edit
    • saveCategoryAction

      public String saveCategoryAction()
      If editing mode is active, set categoryName and categoryDescription to the currently selected category, persist it and end the editing mode.

      Otherwise, if isValid() is true, create a new category based on getCategoryName() and getCategoryDescription() and persist it. Also clear categoryName and categoryDescription.

      Returns:
      Navigation outcome
    • deleteCategoryAction

      public String deleteCategoryAction(CMSCategory category)
      Delete the given Category in DAO. Also clear categoryName and categoryDescription
      Parameters:
      category - category to delete from the database
      Returns:
      Navigation outcome
    • cancelAction

      public String cancelAction()
      End the editing mode if active without persisting anything. Also clear categoryName and categoryDescription
      Returns:
      Navigation outcome
    • isEditing

      public boolean isEditing()
      Check is we are currently editing an existing category, i.e. getSelectedCategory() doesn't return null
      Returns:
      true if we are currently editing an existing category, i.e. getSelectedCategory() doesn't return null
    • endEditing

      public void endEditing()

      endEditing.

    • getAllCategories

      public List<CMSCategory> getAllCategories() throws DAOException
      Returns a newly created list of all saved categories.
      Returns:
      a newly created list of all saved categories
      Throws:
      DAOException - if any.
    • getCategoryName

      public String getCategoryName()
      Getter for the field categoryName.
      Returns:
      the name entered for the new or edited category
    • setCategoryName

      public void setCategoryName(String categoryName)
      Setter for the field categoryName.
      Parameters:
      categoryName - name entered for the new or edited category
    • getCategoryDescription

      public String getCategoryDescription()
      Getter for the field categoryDescription.
      Returns:
      the description entered for the new or edited category
    • setCategoryDescription

      public void setCategoryDescription(String categoryDescription)
      Setter for the field categoryDescription.
      Parameters:
      categoryDescription - description entered for the new or edited category
    • getSelectedCategory

      public CMSCategory getSelectedCategory()
      Getter for the field selectedCategory.
      Returns:
      the currently selected CMS category, or null if none is selected
    • getSelectedCategoryId

      public Long getSelectedCategoryId()

      getSelectedCategoryId.

      Returns:
      ID of the selected category
    • setSelectedCategoryId

      public void setSelectedCategoryId(Long id) throws DAOException

      setSelectedCategoryId.

      Parameters:
      id - database ID of the category to edit
      Throws:
      DAOException