Class SplibGeneralController<S extends SplibGeneralService>

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

public abstract class SplibGeneralController<S extends SplibGeneralService> extends SplibBaseController
  • Field Details

    • context

    • prepareSettings

      protected SplibGeneralController.PrepareSettings prepareSettings
    • redirectUrlOnAppExceptionBean

      protected RedirectUrlBean redirectUrlOnAppExceptionBean
    • rolesAndAuthoritiesBean

      protected SplibSecurityUtil.RolesAndAuthoritiesBean rolesAndAuthoritiesBean
    • serviceList

      @Autowired protected List<S extends SplibGeneralService> serviceList
      単純にserviceを@Autowiredすると、ConfigController、LoginControllerの使用時に、injection対象が複数存在する、というエラーになる。 使用するserviceがSplibGeneral1FormDoNothingService なのだが、injection対象がこれとSplibGeneral2FormsDoNothingServiceの 2つ存在する、というエラーなのだ。 上記2つのDoNothingServiceは別クラスなので判断ついてもよさそうなのだが、状況的にはそれらのserviceではGenericsのparameterが付与されており、 それによって正しく判断ができていないようだ。pringの不具合かもしれない。 workaroundとして、一旦Listで受け取りgetService()側で選別する形とする。
  • Constructor Details

    • SplibGeneralController

      public SplibGeneralController(@Nonnull String function)
      functionを指定したconstructor。
    • SplibGeneralController

      protected SplibGeneralController(@Nonnull String function, @NonNull SplibGeneralController.ControllerContext context)
      functionを指定したconstructor。functionだけは必須なのでconstructorの引数としている。
  • Method Details

    • newContext

      public static SplibGeneralController.ControllerContext newContext()
    • getPrepareSettings

      public SplibGeneralController.PrepareSettings getPrepareSettings()
    • getService

      public S getService()
    • getFunction

      public String getFunction()
    • getSubFunction

      public String getSubFunction()
    • getRootRecordName

      public String getRootRecordName()
    • getRedirectUrlOnAppExceptionBean

      public RedirectUrlBean getRedirectUrlOnAppExceptionBean()
    • getReturnStringToShowPage

      protected String getReturnStringToShowPage()
      メニューなどからURLを指定された際に表示する処理のreturnとして使用。htmlページのファイル名ルールを統一化する目的で使用。
    • getReturnStringToShowPage

      protected String getReturnStringToShowPage(String page)
      メニューなどからURLを指定された際に表示する処理のreturnとして使用。 現時点では指定されたpageをそのまま返すだけなので意味はないのだが、今後の追加処理を見込んでmethod化しておく。 現時点では、これは1 htmlファイルに対しcontroller、formが複数ある場合で、 かつcontrollerにはsubFunctionがあるがhtmlファイル名にはsubFunctionがつかない、 という場合にやむなく使用するのみで、それ以外では使用想定はなし。
    • getReturnStringOnSuccess

      protected String getReturnStringOnSuccess(RedirectUrlBean redirectUrlBean)
      処理が終わり、最終的にredirectする場合に使用。
    • getReturnStringOnSuccess

      protected String getReturnStringOnSuccess()
      処理が終わり、最終的にredirectする場合に使用。 defaultPageへのredirectを簡便にするためのメソッド。
    • prepareForSuccessRedirectAndGetPath

      public String prepareForSuccessRedirectAndGetPath(org.springframework.ui.Model model)
      個々のsplibUtilを直接呼び出しても良いのだが、記載を簡便化するため本クラスでメソッド化しておく。 modelは指定すれば引き継ぐ対象となる。引き継ぐ必要がない場合はnullを設定。
    • prepareForSuccessRedirectAndGetPath

      public String prepareForSuccessRedirectAndGetPath(org.springframework.ui.Model model, String subFunction, String page)
      個々のsplibUtilを直接呼び出しても良いのだが、記載を簡便化するため本クラスでメソッド化しておく。 modelは指定すれば引き継ぐ対象となる。引き継ぐ必要がない場合はnullを設定。
    • prepareForForwardAndGetPath

      public String prepareForForwardAndGetPath(org.springframework.ui.Model model)
      個々のsplibUtilを直接呼び出しても良いのだが、記載を簡便化するため本クラスでメソッド化しておく。 modelは指定すれば引き継ぐ対象となる。引き継ぐ必要がない場合はnullを設定。
    • prepareForForwardAndGetPath

      public String prepareForForwardAndGetPath(org.springframework.ui.Model model, String subFunction, String page)
      個々のsplibUtilを直接呼び出しても良いのだが、記載を簡便化するため本クラスでメソッド化しておく。 modelは指定すれば引き継ぐ対象となる。引き継ぐ必要がない場合はnullを設定。
    • prepareForRedirectOrForwardAndGetPath

      public String prepareForRedirectOrForwardAndGetPath(RedirectUrlPageBean redirectBean, org.springframework.ui.Model model)
    • throw404

      @GetMapping("action") public void throw404() throws org.springframework.web.servlet.resource.NoResourceFoundException
      validation errorなどが発生した際はredirectを通常しないので、ボタンを押した際の/.../action のパスがurlに残る。 その画面のactionはpostで受けているのに、そのurlをbrowserのurlバーを指定してenterしてしまう(つまりgetで送信してしまう)ことがままある。 システムエラーになるのはよくないので、その場合は404と同様の処理としてしまう。actionにparameterをつけないと全てここに来てしまうので注意。
      Throws:
      org.springframework.web.servlet.resource.NoResourceFoundException
    • getDefaultHtmlFileName

      public String getDefaultHtmlFileName()
      本controllerとペアになる画面htmlの文字列。基本は<function>.html。
    • getDefaultSubFunctionOnSuccess

      public String getDefaultSubFunctionOnSuccess()
      処理成功時redirectをする場合のredirect先subFunctionのdefault。
    • getDefaultSubFunctionOnAppException

      public String getDefaultSubFunctionOnAppException()
      処理成功時redirectをする場合のredirect先subFunctionのdefault。
    • getDefaultPageOnSuccess

      public String getDefaultPageOnSuccess()
      処理成功時redirectをする場合のredirect先pageのdefault。
    • getDefaultPageOnAppException

      public String getDefaultPageOnAppException()
      処理成功時redirectをする場合のredirect先pageのdefault。
    • prepare

      public void prepare(org.springframework.ui.Model model, SplibGeneralForm... forms) throws InputValidationException, jp.ecuacion.lib.core.exception.checked.AppException
      Throws:
      InputValidationException
      jp.ecuacion.lib.core.exception.checked.AppException
    • prepare

      public void prepare(org.springframework.ui.Model model, SplibGeneralController.PrepareSettings settings, SplibGeneralForm... forms) throws InputValidationException, jp.ecuacion.lib.core.exception.checked.AppException
      Throws:
      InputValidationException
      jp.ecuacion.lib.core.exception.checked.AppException
    • prepare

      public void prepare(org.springframework.ui.Model model, org.springframework.security.core.userdetails.UserDetails loginUser, SplibGeneralForm... forms) throws InputValidationException, jp.ecuacion.lib.core.exception.checked.AppException
      現時点でloginUserを具体的に使用しているわけではないので、loginUserの引数がないmethodを呼んでも問題ないが、 未来のため一応実装しておく。
      Throws:
      InputValidationException
      jp.ecuacion.lib.core.exception.checked.AppException
    • prepare

      public void prepare(org.springframework.ui.Model model, org.springframework.security.core.userdetails.UserDetails loginUser, SplibGeneralController.PrepareSettings settings, SplibGeneralForm... forms) throws InputValidationException, jp.ecuacion.lib.core.exception.checked.AppException
      エラー処理などに必要な処理を行う。 本処理は、@XxxMappingにより呼び出されるメソッド全てで呼び出す必要あり。 validation・BLチェック含めエラー発生なし、かつredirect、かつtransactionTokenCheck不要、の場合は厳密にはチェックは不要となる。 が、最低でも引数なしのメソッドは呼ぶ(=transactionTokenCheckは実施)ルールとし、transactionTokenCheckが不要の場合は別途それを設定することとする
      Throws:
      InputValidationException
      jp.ecuacion.lib.core.exception.checked.AppException
    • transactionTokenCheck

      protected void transactionTokenCheck() throws jp.ecuacion.lib.core.exception.checked.BizLogicAppException
      以下を実施。 設定項目の値に従ってpulldownの選択肢を動的に変更したい場合など、敢えてvalidation checkをしたくない場面もあるので、 validation checkの要否を持たせている。
      • transactionToken check
      • validation check
      Throws:
      jp.ecuacion.lib.core.exception.checked.BizLogicAppException