Class SplibGeneralController<S extends SplibGeneralService>

java.lang.Object
jp.ecuacion.splib.web.controller.SplibBaseController
jp.ecuacion.splib.web.controller.SplibGeneralController<S>
Type Parameters:
S - SplibGeneralService
Direct Known Subclasses:
SplibGeneral1FormController, SplibGeneral2FormsController

public abstract class SplibGeneralController<S extends SplibGeneralService> extends SplibBaseController
Provides abstract general controller.
  • Field Details

    • context

      Stores ControllerContext.
    • rolesAndAuthoritiesBean

      protected SplibSecurityUtil.RolesAndAuthoritiesBean rolesAndAuthoritiesBean
    • serviceList

      @Autowired protected List<S extends SplibGeneralService> serviceList
      Stores a list of services.

      If you simply @Autowire the service, you will get an error that there are multiple injection targets when using ConfigController or LoginController.
      The service used is SplibGeneral1FormDoNothingService, but the error is that there are two injection targets: this and SplibGeneral2FormsDoNothingService.
      The above two DoNothingServices are different classes, so it seems that the right service can be selected but cannot.
      Generics parameters have been assigned to those services, so it seems that the judgment cannot be made correctly.
      It may be a problem with spring. As a workaround, we will first receive it as a List and select it on the getService() side.

    • redirectUrlOnAppExceptionBean

      protected ReturnUrlBean redirectUrlOnAppExceptionBean
      Is set If you want to redirect when AppException occurs.

      It may be null if you don't want to redirect.

      BizLogicRedirectAppException redirect settings is priotized over this settings.

    • paramListOnRedirectToSelf

      protected List<String[]> paramListOnRedirectToSelf
      Returns parameter list needed to add when the response is redirect to the original page.

      It can be used with the redirect by both normal end and abnormal end (= in the case that AppException is thrown).

  • Constructor Details

    • SplibGeneralController

      public SplibGeneralController(@Nonnull String function)
      Constructs a new instance with function.
      Parameters:
      function - function
    • SplibGeneralController

      protected SplibGeneralController(@Nonnull String function, @NonNull SplibGeneralController.ControllerContext context)
      Constructs a new instance with function and ControllerContext.
      Parameters:
      function - function
      context - context
  • Method Details

    • newContext

      public static SplibGeneralController.ControllerContext newContext()
      Constructs a new instance and returns it.
      Returns:
      ControllerContext
    • getService

      public S getService()
      Returns a service instance.

      See ControllerContext.serviceList.

      Returns:
      service
    • getFunctionKinds

      public String[] getFunctionKinds()
    • getFunction

      public String getFunction()
    • getSubFunction

      public String getSubFunction()
    • getRootRecordName

      public String getRootRecordName()
    • getRedirectUrlOnAppExceptionBean

      public ReturnUrlBean getRedirectUrlOnAppExceptionBean()
    • addParamToParamListOnRedirectToSelf

      protected void addParamToParamListOnRedirectToSelf(String key)
      Adds html parameter with no value when the request redirects to the same page.
      Parameters:
      key - key
    • addParamToParamListOnRedirectToSelf

      protected void addParamToParamListOnRedirectToSelf(String key, String value)
      Adds html parameter when the request redirects to the same page.
      Parameters:
      key - key
    • getParamListOnRedirectToSelf

      public List<String[]> getParamListOnRedirectToSelf()
    • getRedirectUrlOnSuccess

      protected String getRedirectUrlOnSuccess()
      Returns the redirect URL which redirects to the same page with success message.

      This is a utility method to use redirect easily without understanding ReturnUrlBean. It's also allowed to use ReturnUrlBean directly from apps.

      Returns:
      URL
    • redirectToSamePageTakingOverModel

      public String redirectToSamePageTakingOverModel(org.springframework.ui.Model model)
      Returns the redirect URL which redirects to the same page and takes over model to the transitioned page.

      This is a utility method to use redirect easily without understanding ReturnUrlBean. It's also allowed to use ReturnUrlBean directly from apps.

      Parameters:
      model - model
      Returns:
      URL
    • redirectToSamePageTakingOverModel

      public String redirectToSamePageTakingOverModel(org.springframework.ui.Model model, boolean showsSuccessMessage)
      Returns the redirect URL which redirects to the same page and takes over model to the transitioned page.

      This is a utility method to use redirect easily without understanding ReturnUrlBean. It's also allowed to use ReturnUrlBean directly from apps.

      Parameters:
      model - model
      showsSuccessMessage - showsSuccessMessage
      Returns:
      URL
    • getDefaultHtmlPageName

      public String getDefaultHtmlPageName()
      Returns default html filename corresponding to the controller.

      Basically <function>.html.
      If subFunction is set, it becomes <function> + capitalize(<subFuction>).html.
      If htmlFilenamePostfix is set, it becomes <function> + capitalize(<htmlFilenamePostfix>).html.
      (not <function> + capitalize(<subFunction>) + capitalize(<htmlFilenamePostfix>).html)

      Returns:
      html filename
    • getDefaultDestSubFunctionOnNormalEnd

      public String getDefaultDestSubFunctionOnNormalEnd()
      Provides the default subFunction value as the part of the redirecting URL after the server procedure finished successfully.

      In this class context.subFunction() is set as the default return value, but for instance in "edit" controller class, "searchList" is set because after insert or update a record, going back to the list screen seems to be normal.

      Returns:
      default subFunction value
    • getDefaultDestSubFunctionOnAbnormalEnd

      public String getDefaultDestSubFunctionOnAbnormalEnd()
      Provides the default subFunction value as the part of the redirecting URL after the server procedure finished with error.

      In this class context.subFunction() is set as the default return value, but for instance in "edit" controller class, "searchList" is set because after insert or update a record, going back to the list screen seems to be normal.

      Returns:
      default subFunction value
    • getDefaultDestPageOnNormalEnd

      public String getDefaultDestPageOnNormalEnd()
      Provides the default subFunction value as the part of the redirecting URL after the server procedure finished successfully.

      In this class "page" is set as the default return value.

      Returns:
      default subFunction value
    • getDefaultDestPageOnAbnormalEnd

      public String getDefaultDestPageOnAbnormalEnd()
      Provides the default page value as the part of the redirecting URL after the server procedure finished with error.

      In this class "page" is set as the default return value.

      Returns:
      default subFunction value
    • prepare

      public void prepare(org.springframework.ui.Model model, SplibGeneralForm... forms) throws jp.ecuacion.lib.core.exception.checked.AppException
      Carries out the procedure that is needed after the service procedure ended or the service throws exceptions.

      All the method with @XxxMapping needs to call this method at the first line of the method.
      validation・BLチェック含めエラー発生なし、かつredirect、かつtransactionTokenCheck不要、の場合は厳密にはチェックは不要となる。 が、最低でも引数なしのメソッドは呼ぶ(=transactionTokenCheckは実施)ルールとし、transactionTokenCheckが不要の場合は別途それを設定することとする

      Parameters:
      model - model
      forms - forms
      Throws:
      jp.ecuacion.lib.core.exception.checked.AppException - AppException
    • prepare

      public void prepare(org.springframework.ui.Model model, org.springframework.security.core.userdetails.UserDetails loginUser, SplibGeneralForm... forms) throws jp.ecuacion.lib.core.exception.checked.AppException
      Carries out the procedure that is needed after the service procedure ended or the service throws exceptions. エラー処理などに必要な処理を行う。 本処理は、@XxxMappingにより呼び出されるメソッド全てで呼び出す必要あり。
      Parameters:
      model - model
      loginUser - loginUser
      forms - forms
      Throws:
      jp.ecuacion.lib.core.exception.checked.AppException - AppException