Class PanelComponentController

  • All Implemented Interfaces:
    DelegatedController, ComponentAware, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware, org.springframework.web.context.ServletContextAware, org.springframework.web.servlet.mvc.Controller

    public abstract class PanelComponentController
    extends ComponentController
    This class is the base class for panel component controllers. Component controllers are controllers that are registered by a component. These controllers are not running in the Spring application context but controller methods are delegated to it by a MainSpringController which does run inside the Spring application context. A panel only contains one controller controlling all tabs. Dependend on the current selected tab however different form backing objects may be returned by this controller. This controller contains base functionality to define (horizontal and vertical) panel tabs. Custom controllers for panel components should extend this class.
    Since:
    WebManager 9.0.8
    Author:
    ivol
    • Field Detail

      • PANEL_TAB_ID_KEY

        public static final String PANEL_TAB_ID_KEY
        request key for tabid of the active tab.
        See Also:
        Constant Field Values
      • COMMAND_OBJECT_KEY

        public static final String COMMAND_OBJECT_KEY
        key to set/get the command object on the session for implementaiton of the springmvc post and redirect patern.
        See Also:
        Constant Field Values
      • PANEL_ID_KEY

        public static final String PANEL_ID_KEY
        key to get the request attribute for selection of the current pannel class.
        See Also:
        Constant Field Values
    • Constructor Detail

      • PanelComponentController

        public PanelComponentController()
    • Method Detail

      • formBackingObject

        public Object formBackingObject​(javax.servlet.http.HttpServletRequest request)
                                 throws javax.servlet.ServletException
        Description copied from class: ComponentController
        Retrieve a form backing object for the current form from the given request. Override this method to return the form backing object
        Specified by:
        formBackingObject in interface DelegatedController
        Overrides:
        formBackingObject in class ComponentController
        Parameters:
        request - current HTTP request
        Returns:
        the FormBackingObject
        Throws:
        javax.servlet.ServletException - in case of errors
      • onBind

        public void onBind​(javax.servlet.http.HttpServletRequest request,
                           Object command,
                           org.springframework.validation.BindException errors)
                    throws Exception
        Process the Siteworks protocol and process the WebManager Spring protocol.
        Specified by:
        onBind in interface DelegatedController
        Overrides:
        onBind in class BaseWebmanagerController
        Parameters:
        request - current HTTP request
        command - the command object to perform further binding on
        errors - validation errors holder, allowing for additional custom registration of binding errors
        Throws:
        Exception - in case of invalid state or arguments
      • onSubmit

        public void onSubmit​(javax.servlet.http.HttpServletRequest request,
                             javax.servlet.http.HttpServletResponse response,
                             Object command,
                             org.springframework.validation.BindException errors,
                             org.springframework.web.servlet.ModelAndView modelAndView)
                      throws Exception
        Methods that override this method MUST call super.onSubmit in order to function properly. Delegates the onSubmit to all registered sub components.
        Specified by:
        onSubmit in interface DelegatedController
        Overrides:
        onSubmit in class BaseWebmanagerController
        Parameters:
        request - current servlet request
        response - current servlet response
        command - form object with request parameters bound onto it
        errors - Errors instance without errors (subclass can add errors if it wants to)
        modelAndView - the model and view prepared by the main spring controller
        Throws:
        Exception - in case of errors
      • showForm

        public org.springframework.web.servlet.ModelAndView showForm​(javax.servlet.http.HttpServletRequest request,
                                                                     javax.servlet.http.HttpServletResponse response,
                                                                     org.springframework.validation.BindException errors,
                                                                     Map controlModel)
                                                              throws Exception
        Returns the Model and view to be used when rendering the form backing object that is returned by this controller
        Specified by:
        showForm in interface DelegatedController
        Overrides:
        showForm in class ComponentController
        Parameters:
        request - Current servlet request
        response - Current servlet response
        errors - Errors instance without errors (subclass can add errors if it wants to)
        controlModel - The model passed by the platform controller
        Returns:
        The model and view to be used when rendering the form backing object
        Throws:
        Exception - in case of errors
      • referenceData

        public Map<String,​Object> referenceData​(javax.servlet.http.HttpServletRequest request,
                                                      Object command,
                                                      org.springframework.validation.Errors errors)
                                               throws Exception
        Add panel object to the model rendered by the PanelController.
        Specified by:
        referenceData in interface DelegatedController
        Overrides:
        referenceData in class BaseWebmanagerController
        Parameters:
        request - current HTTP request
        command - the command object to perform further binding on
        errors - validation errors holder, allowing for additional custom registration of binding errors
        Returns:
        Map with reference data
        Throws:
        Exception - in case of invalid state or arguments
        See Also:
        ModelAndView
      • createEditViews

        protected void createEditViews()
        Description copied from class: BaseWebmanagerController
        Callback to add edit views. Sub classes should implement this method, call the super and invoke addEditViews to add its own edit views to the controller.
        Specified by:
        createEditViews in class BaseWebmanagerController
      • setSingleTab

        public PanelTab setSingleTab​(String viewFileName,
                                     DelegatedController controller,
                                     javax.servlet.http.HttpServletRequest request)
        Sets a single tab onto the panel. This will hide the tab control with which tabs are surrounded usually. Only use if you want to create a panel without tabs and just one view.
        Parameters:
        viewFileName -
        controller -
        request -
        Returns:
      • addTab

        public PanelTab addTab​(String tabId,
                               String titleKey,
                               String viewFileName,
                               DelegatedController controller,
                               javax.servlet.http.HttpServletRequest request)
        Adds a main tab to the panel navigation.
        Parameters:
        tabId - unique tabId within this panel
        titleKey - resourcebundle key for the tab title, not shown if empty
        viewFileName - view file form this tab, may be null in the tab holds only subtabs
        panelViewCommandClass - command class for this tab, may be null in the tab holds only subtabs if this is a maintab that holds only subtabs which operates as differant views on the same command, set this command here.
        Returns:
        PanelTab the added panelTab for adding Sub Tabs ( level 2) if required null in case of configuration exceptions
      • addTab

        public PanelTab addTab​(String tabId,
                               String titleKey,
                               String titleImage,
                               String viewFileName,
                               DelegatedController controller,
                               String presentationName,
                               javax.servlet.http.HttpServletRequest request)
        Adds a main tab to the panel navigation.
        Parameters:
        tabId - unique tabId within this panel
        titleKey - resourcebundle key for the tab title, not shown if empty
        titleImage - image shown as title, not shown if empty
        viewFileName - view file form this tab, may be null in the tab holds only subtabs
        panelViewCommandClass - command class for this tab, may be null in the tab holds only subtabs if this is a maintab that holds only subtabs which operates as differant views on the same command, set this command here.
        presentationName - may be either PanelTabset.LEVEL1_HORIZONTAL, PanelTabset.LEVEL1_VERTICAL, PanelTabset.LEVEL2_HORIZONTAL, PanelTabset.LEVEL2_VERTICAL or null if the presentationName should not changed or the default should be set in case none is set.
        Returns:
        PanelTab the added panelTab for adding Sub Tabs ( level 2) if required null in case of configuration exceptions
      • initializeTabSet

        protected abstract void initializeTabSet​(javax.servlet.http.HttpServletRequest request,
                                                 PanelBase panel)
        Override this method to define the tabset
      • getStatefulTabController

        protected DelegatedController getStatefulTabController​(Class clazz,
                                                               javax.servlet.http.HttpServletRequest request)
        This method is a helper class for caching controller instances per user session. This ensures that the next time a user opens the panel, the form backing object provided by the controller will have the same state. Usually controllers have a lifespan of the request and are thus stateless. An instance returned by this method is stateful within the users session.
        Parameters:
        clazz - Class of the controller to retrieve an instance from
        Returns:
        Instance of the controller of the specified class