Class SplibSearchForm

java.lang.Object
jp.ecuacion.splib.web.form.SplibGeneralForm
jp.ecuacion.splib.web.form.SplibSearchForm

public abstract class SplibSearchForm extends SplibGeneralForm
Stores data for search.
  • Field Details

    • DIRECTION_ASC

      public static final String DIRECTION_ASC
      See Also:
    • DIRECTION_DESC

      public static final String DIRECTION_DESC
      See Also:
    • sortItem

      protected String sortItem
    • direction

      protected String direction
    • page

      protected Integer page
    • recordsInScreen

      protected Integer recordsInScreen
    • numberOfRecords

      protected Integer numberOfRecords
      pagerを作成するのに必要となるため、serviceから受け取りpager作成時に使用.
  • Constructor Details

    • SplibSearchForm

      public SplibSearchForm()
      Constructs a new instance.
  • Method Details

    • isPrepared

      public boolean isPrepared()
    • setPrepared

      public void setPrepared(boolean prepared)
    • getDefaultSortItem

      @Nonnull protected abstract String getDefaultSortItem()
      Gets getDefaultSortItem.
      Returns:
      String
    • getDefaultDirection

      protected String getDefaultDirection()
      こちらはdefaultで設定をしておくが個別form毎に変更が可能.
    • isRequestFromSearchForm

      public boolean isRequestFromSearchForm()
    • setRequestFromSearchForm

      public void setRequestFromSearchForm(boolean requestFromSearchForm)
    • getNewlyCreated

      public boolean getNewlyCreated()
      Returns true when the search conditions in the form is newly created and it's the right time to set initial conditions at searchListService#page().
    • getNewlyCreatedRawValue

      public Boolean getNewlyCreatedRawValue()
      "getNewlyCreated()" does not return null to simplify its usage from general users. Otherwise the code inside want to know if the value is null, so the method obtaining raw value (means it may return null) prepared.
    • setNewlyCreated

      public void setNewlyCreated(Boolean newlyCreated)
    • getSortItem

      public String getSortItem()
    • getSortItemWithDefault

      @Nonnull public String getSortItemWithDefault()
      Gets SortItemWithDefault.
      Returns:
      String
    • setSortItem

      public void setSortItem(String sortItem)
    • getDirection

      public String getDirection()
    • getDirectionEnum

      public org.springframework.data.domain.Sort.Direction getDirectionEnum()
    • setDirection

      public void setDirection(String direction)
    • nextDirection

      public String nextDirection(String sortItem)
      Returns next direction.
      Parameters:
      sortItem - sortItem
      Returns:
      String
    • getPage

      public Integer getPage()
    • setPage

      public void setPage(Integer page)
    • getRecordsInScreen

      public Integer getRecordsInScreen()
    • setRecordsInScreen

      public void setRecordsInScreen(Integer recordsInScreen)
    • getNumberOfRecords

      public Integer getNumberOfRecords()
      値のセットはsetNumberOfRecordsAndAdjustCurrentPageNumger()を使用する前提であり、 これでない方法でnumberOfRecordsを設定すると処理が正しく動かないためあえて通常のsetterは削除した.
    • setNumberOfRecordsAndAdjustCurrentPageNumger

      public void setNumberOfRecordsAndAdjustCurrentPageNumger(Long numberOfRecords)
      Sets number of records and adjust current page number.
      Parameters:
      numberOfRecords - numberOfRecords
    • getPageRequest

      public org.springframework.data.domain.PageRequest getPageRequest()
    • getPagerInfoList

      public List<PagerInfo> getPagerInfoList(Locale locale)
      pagerを作成するためのPagerInfoのリストを生成.

      Pager作成のルールは以下。

      • レコード件数が0件及び、現在のrecordsInScreen以下の場合はpagerを表示しない
      • 上記条件より、pagerが存在する際は常に2ページ以上存在することとなる。
      • 次ページ・全ページへ移動する「Previous」「Next」は(Pagerが存在する限り)常に存在するものとし、 現在の表示が1ページ目の場合はPreviousは押せない、現ページが最終ページ(以降)の場合はNextは押せない、という制御とする (「現ページが最終ページ(以降)」と「以降」をつけているのは、
      • 元々50レコードあり、5件表示で10ページまで表示していたが、画面表示後にレコードを30件削除、 その後画面から10ページ目のボタンを押した場合、素直にPageRequestすると、10ページ目を取得しようとし0件取得になるのだが、 エラーになるわけではないし頻繁にあることではないのでそれでよしとする、つまりpager上も10ページを最終ページとし表示する。 その状態でPreviousを押すと、これまたデータが存在しない9ページ目を表示しようとするがそれもOKとする。 (そもそも一気にデータが消されるのは通常オペレーションでは考えにくいと思われるし、一旦1ページ目に戻りpagerを見れば件数が減ったとわかるので)
        →表示件数や検索条件を同時に変更すると、割と頻発する状態になったため、最終ページより後に現在ページがある場合は最終ページに変更する処理を追加。 (setNumberOfRecordsAndAdjustCurrentPageNumger() -> changePageIfThePageNumberExceedsTheLast() のところ) 本処理のロジックは現時点ではそのままとしておく。間違いなく不要であることを確認後必要ならその部分のロジックを削除可。
      • 前ページ・次ページに移動する手段は「Previous」「Next」を使用し、ページ番号で表示されるセルは、現ページ、1ページ、最終ページのみとする。 (次のページの番号のリンクとNextを両方出すのは冗長なので)
      • 現ページの隣のページが1ページ目ないし最終ページでない場合は、間に押下不可な「...」のセルを入れる
      • つまり、押下不可を(*)で表すと、pagerでは以下のように表示される。
        • 全2ページ・現在1ページの場合:Previous(*)|1|2|Next(*)
        • 全3ページ・現在1ページの場合:Previous(*)|1|...(*)|3|Next
        • 全3ページ・現在2ページの場合:Previous|1|2|3|Next
        • 全4ページ・現在1ページの場合:Previous(*)|1|...(*)|4|Next
        • 全4ページ・現在2ページの場合:Previous|1|2|...(*)|4|Next
        • 全5ページ・現在3ページの場合:Previous|1|...(*)|3|...(*)|5|Next
    • getLinesInScreen

      public String getLinesInScreen()
      Is used for search result records display like "6-10 / 15".
    • getNotEmptyItemPropertyPathList

      protected List<String> getNotEmptyItemPropertyPathList(HtmlItemContainer rootRecord, String loginState, SplibSecurityUtil.RolesAndAuthoritiesBean bean)
      Description copied from class: SplibGeneralForm
      Supplies NotEmpty fields in rootRecord.

      This became a independent method because some form doesn't use "notEmpty()". For example, searchForm uses "notEmptyOnSearch()", not "notEmpty()".

      Overrides:
      getNotEmptyItemPropertyPathList in class SplibGeneralForm