Class SplibSearchForm
java.lang.Object
jp.ecuacion.splib.web.form.SplibGeneralForm
jp.ecuacion.splib.web.form.SplibSearchForm
Stores data for search.
-
Nested Class Summary
Nested classes/interfaces inherited from class SplibGeneralForm
SplibGeneralForm.PrepareSettings -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringstatic final Stringstatic final Stringprotected Integerpagerを作成するのに必要となるため、serviceから受け取りpager作成時に使用.protected Integerprotected Integerprotected StringFields inherited from class SplibGeneralForm
confirmedWarnings, dataKind -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Stringこちらはdefaultで設定をしておくが個別form毎に変更が可能.protected abstract StringGets getDefaultSortItem.org.springframework.data.domain.Sort.DirectionIs used for search result records display like "6-10 / 15".getNotEmptyItemPropertyPathList(HtmlItemContainer rootRecord, String loginState, SplibSecurityUtil.RolesAndAuthoritiesBean bean) Supplies NotEmpty fields in rootRecord.値のセットはsetNumberOfRecordsAndAdjustCurrentPageNumger()を使用する前提であり、 これでない方法でnumberOfRecordsを設定すると処理が正しく動かないためあえて通常のsetterは削除した.getPage()org.springframework.data.domain.PageRequestgetPagerInfoList(Locale locale) pagerを作成するためのPagerInfoのリストを生成.Gets SortItemWithDefault.booleanbooleannextDirection(String sortItem) Returns next direction.voidsetDirection(String direction) voidsetNumberOfRecordsAndAdjustCurrentPageNumger(Long numberOfRecords) Sets number of records and adjust current page number.voidvoidsetPrepared(boolean prepared) voidsetRecordsInScreen(Integer recordsInScreen) voidsetRequestFromSearchForm(boolean requestFromSearchForm) voidsetSortItem(String sortItem) Methods inherited from class SplibGeneralForm
containsConfirmedWarning, get, getConfirmedWarningMessageSet, getConfirmedWarnings, getControllerContext, getDataKind, getPrepareSettings, getRootRecord, getRootRecord, getRootRecordFields, hasNotEmptyError, noValidate, setConfirmedWarnings, setControllerContext, setDataKind, validate, validateNotEmpty, validateNotEmpty
-
Field Details
-
DIRECTION_ASC
- See Also:
-
DIRECTION_DESC
- See Also:
-
sortItem
-
direction
-
page
-
recordsInScreen
-
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
-
getDefaultDirection
こちらはdefaultで設定をしておくが個別form毎に変更が可能. -
isRequestFromSearchForm
public boolean isRequestFromSearchForm() -
setRequestFromSearchForm
public void setRequestFromSearchForm(boolean requestFromSearchForm) -
getSortItem
-
getSortItemWithDefault
-
setSortItem
-
getDirection
-
getDirectionEnum
public org.springframework.data.domain.Sort.Direction getDirectionEnum() -
setDirection
-
nextDirection
-
getPage
-
setPage
-
getRecordsInScreen
-
setRecordsInScreen
-
getNumberOfRecords
値のセットはsetNumberOfRecordsAndAdjustCurrentPageNumger()を使用する前提であり、 これでない方法でnumberOfRecordsを設定すると処理が正しく動かないためあえて通常のsetterは削除した. -
setNumberOfRecordsAndAdjustCurrentPageNumger
Sets number of records and adjust current page number.- Parameters:
numberOfRecords- numberOfRecords
-
getPageRequest
public org.springframework.data.domain.PageRequest getPageRequest() -
getPagerInfoList
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
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:SplibGeneralFormSupplies NotEmpty fields in rootRecord.This became a independent method because some form doesn't use "notEmpty()". For example, searchForm uses "notEmptyOnSearch()", not "notEmpty()".
- Overrides:
getNotEmptyItemPropertyPathListin classSplibGeneralForm
-