Class ModelAndViewServiceImpl

java.lang.Object
org.kuali.rice.krad.web.service.impl.ModelAndViewServiceImpl
All Implemented Interfaces:
ModelAndViewService

public class ModelAndViewServiceImpl extends Object implements ModelAndViewService
Default implementation of the model and view service.
Author:
Kuali Rice Team (rice.collab@kuali.org)
  • Constructor Details

    • ModelAndViewServiceImpl

      public ModelAndViewServiceImpl()
  • Method Details

    • checkForm

      public org.springframework.web.servlet.ModelAndView checkForm(UifFormBase form)
      Invokes ViewValidationService to validate the contents of the given form instance. Handles the check form action to validate the given form data.
      Specified by:
      checkForm in interface ModelAndViewService
      Parameters:
      form - instance containing the model data
      Returns:
      ModelAndView instance for rendering the view
    • showDialog

      public org.springframework.web.servlet.ModelAndView showDialog(String dialogId, boolean confirmation, UifFormBase form)
      Builds the dialog group with the given id then creates the script for showing the dialog once the page reloads. Invoked by controller methods to show a dialog to the user.

      This will return back to the view and display the dialog to the user. When the users chooses a response, the initial action that triggered the controller method (which called showDialog) will be triggered again. The response will be captured in the form property UifFormBase.getDialogResponses(). In the case of a confirmation, if 'false' (typically labeled cancel) is choosen the initial action will simply not be triggered again.

      Specified by:
      showDialog in interface ModelAndViewService
      Parameters:
      dialogId - id for the dialog group to show
      confirmation - whether the dialog should be shown as a confirmation, in this case it is expected the options are true (continue) or false (stop). In addition, if the user selects the false option, the dialog answer will not be resubmitted to the server, instead the user will remain on the view
      form - instance containing the model data
      Returns:
      ModelAndView instance for rendering the view
    • buildShowDialogScript

      protected String buildShowDialogScript(String dialogId, boolean confirmation, UifFormBase form)
      Builds a JavaScript string for invoking the showDialog method with the given dialog parameters.
      Parameters:
      dialogId - id for the dialog group to show
      confirmation - whether the dialog should be shown as a confirmation
      form - instance containing the model data
      Returns:
      String containing script
    • performRedirect

      public org.springframework.web.servlet.ModelAndView performRedirect(UifFormBase form, String baseUrl, Properties urlParameters)
      Builds an URL from the given base URL and parameters, then builds a model and view instance configured to redirect to the built URL.
      Specified by:
      performRedirect in interface ModelAndViewService
      Parameters:
      form - form instance containing the model data
      baseUrl - base URL to redirect to
      urlParameters - parameters to add to the base URL
      Returns:
      ModelAndView instance configured to redirect to the built URL
    • performRedirect

      public org.springframework.web.servlet.ModelAndView performRedirect(UifFormBase form, String redirectUrl)
      Builds a model and view instance configured to redirect to the given URL.
      Specified by:
      performRedirect in interface ModelAndViewService
      Parameters:
      form - instance containing the model data
      redirectUrl - URL to redirect to
      Returns:
      ModelAndView instance configured to redirect to the given URL
    • getMessageView

      public org.springframework.web.servlet.ModelAndView getMessageView(UifFormBase form, String headerText, String messageText)
      Retrieves an instance of the view with id UifConstants.MESSAGE_VIEW_ID and sets the header and message from the given parameters. Builds a message view from the given header and message text then forwards the UIF model and view.

      If an error or other type of interruption occurs during the request processing the controller can invoke this message to display the message to the user. This will abandon the view that was requested and display a view with just the message

      Specified by:
      getMessageView in interface ModelAndViewService
      Parameters:
      form - instance containing the model data
      headerText - header text for the message view (can be blank)
      messageText - text for the message to display
      Returns:
      instance for rendering the view
    • getModelAndView

      public org.springframework.web.servlet.ModelAndView getModelAndView(UifFormBase form)
      Configures the Spring model and view instance containing the form data and pointing to the generic Uif view.

      The view and page to render is assumed to be set in the given form object.

      Specified by:
      getModelAndView in interface ModelAndViewService
      Parameters:
      form - form instance containing the model data
      Returns:
      ModelAndView instance for rendering the view
    • getModelAndView

      public org.springframework.web.servlet.ModelAndView getModelAndView(UifFormBase form, String pageId)
      Configures the Spring model and view instance containing the form data and pointing to the generic Uif view, and also changes the current page to the given page id.

      The view to render is assumed to be set in the given form object.

      Specified by:
      getModelAndView in interface ModelAndViewService
      Parameters:
      form - form instance containing the model data
      pageId - page id within the view to render
      Returns:
      ModelAndView instance for rendering the view
    • getModelAndView

      public org.springframework.web.servlet.ModelAndView getModelAndView(UifFormBase form, Map<String,Object> additionalViewAttributes)
      Configures the Spring model and view instance containing the form data and pointing to the generic Uif view, and also adds the given attributes (which can be referenced in the view templates).

      The view and page to render is assumed to be set in the given form object.

      Specified by:
      getModelAndView in interface ModelAndViewService
      Parameters:
      form - form instance containing the model data
      additionalViewAttributes - additional attributes to add to the returned model and view
      Returns:
      ModelAndView instance for rendering the view
    • getModelAndViewWithInit

      public org.springframework.web.servlet.ModelAndView getModelAndViewWithInit(UifFormBase form, String viewId)
      Initialize a new view instance for the given view id, then configures the Spring model and view instance containing the form data and pointing to the generic Uif view.

      This can be used by controllers to render a different view from the one initially requested (if any)

      Specified by:
      getModelAndViewWithInit in interface ModelAndViewService
      Parameters:
      form - form instance containing the model data
      viewId - id for the view to initialize
      Returns:
      ModelAndView instance for rendering the view
    • getModelAndViewWithInit

      public org.springframework.web.servlet.ModelAndView getModelAndViewWithInit(UifFormBase form, String viewId, String pageId)
      Initialize a new view instance for the given view id, then configures the Spring model and view instance containing the form data and pointing to the generic Uif view.

      This can be used by controllers to render a different view from the one initially requested (if any)

      Specified by:
      getModelAndViewWithInit in interface ModelAndViewService
      Parameters:
      form - form instance containing the model data
      viewId - id for the view to initialize
      pageId - page id within the view to render
      Returns:
      ModelAndView instance for rendering the view
    • prepareView

      public void prepareView(javax.servlet.http.HttpServletRequest request, org.springframework.web.servlet.ModelAndView modelAndView)
      After the controller logic is executed, the form is placed into session and the corresponding view is prepared for rendering.
      Specified by:
      prepareView in interface ModelAndViewService
      Parameters:
      request - servlet request
      modelAndView - model and view
    • invokeViewLifecycle

      protected void invokeViewLifecycle(javax.servlet.http.HttpServletRequest request, UifFormBase form)
      Prepares the View instance contained on the form for rendering.
      Parameters:
      request - servlet request
      form - form instance containing the data and view instance
    • getViewService

      protected ViewService getViewService()
    • setViewService

      public void setViewService(ViewService viewService)
    • getViewValidationService

      public ViewValidationService getViewValidationService()
    • setViewValidationService

      public void setViewValidationService(ViewValidationService viewValidationService)