# DKW00301SFBean

## Purpose

`DKW00301SFBean` is the central data model (screen bean) for the **DKW00301 family of search screens** in the X33V enterprise framework. It holds all input search criteria, UI state flags, and result data used by four related sub-screens (identified by XML game definitions `DKW003010` through `DKW003040`). Every field on these search-and-list screens — return item conditions, receiving party, dates, pagination, and search result rows — flows through this single object.

## Design

`DKW00301SFBean` extends the framework base class `X33VViewBaseBean` and implements `X33VListedBeanInterface` and `X31CBaseBean`. This makes it a **view-scoped data holder** that integrates into the X33V page lifecycle while also supporting list-manipulation operations (add, remove, clear).

Architecturally, it plays the role of a **data-binding facade**:

- It aggregates all screen state (simple `String`, `Boolean`, `Long` fields plus `X33VDataTypeList` containers).
- It normalizes how the X33V framework reads and writes every field through a single key-based path syntax, so the framework can perform serialization, validation, and type introspection without knowing each field name at compile time.
- It manages both scalar search criteria and repeatable (list) data structures, acting as the single point of truth for the entire screen.

There are **no outbound code references** to other classes in this source file — all interaction is mediated through the framework base class and through the generic `X33VDataTypeBeanInterface` calls into child beans (see "Data-Bean Sub-Structure" below).

## Class Declaration

```java
public class DKW00301SFBean
    extends X33VViewBaseBean
    implements X33VListedBeanInterface, X31CBaseBean, Serializable
```

| Aspect | Detail |
|---|---|
| **Source** | `source/koptWebB/src/eo/web/webview/DKW00301SF/DKW00301SFBean.java` |
| **Lines** | 42–3843 |
| **Base class** | `X33VViewBaseBean` (framework-provided) |
| **Interfaces** | `X33VListedBeanInterface`, `X31CBaseBean`, `Serializable` |
| **Inbound dependencies** | 4 XML game-definition files (see Relationships) |
| **Outbound dependencies** | None declared (delegates to framework base + child beans via interfaces) |

## Fields

The bean declares **~50+ protected fields**, each representing a screen input, UI state flag, or data container. They fall into five categories:

### 1. Data-Bean List Fields (repeatable groups)

These are `X33VDataTypeList` containers, each holding instances of a specific data-bean class:

| Field | Data Bean Class | Purpose |
|---|---|---|
| `i_hmpin_chsht_joken_list` | `DKW00301SF02DBean` | Return item search conditions |
| `i_ukeire_sk_list` | `DKW00301SF01DBean` | Receiving party |
| `i_hmpin_sbt_list` | `DKW00301SF02DBean` | Return item type |
| `i_mdl_no_list` | `DKW00301SF03DBean` | Model number |
| `i_search_ymd_choice_list` | `DKW00301SF02DBean` | Search date selection |
| `i_ymd_sta_list` | `DKW00301SF04DBean` | Date range start |
| `i_ymd_end_list` | `DKW00301SF04DBean` | Date range end |
| `i_shonin_ymd_sta_list` | `DKW00301SF04DBean` | Approved date range start |
| `i_shonin_ymd_end_list` | `DKW00301SF04DBean` | Approved date range end |
| `search_rslt_list_list` | `DKW00301SF05DBean` | Search result list |
| `l_kiki_kei_div_list` | `DKW00301SF02DBean` | Supply type list |
| `search_rslt_list_csv_list` | `DKW00301SF05DBean` | CSV-export search results |
| `kiki_kei_div_cd_list_list` | (String list) | Machine contract division code list |
| `kiki_kei_div_nm_list_list` | (String list) | Machine contract division name list |
| `SEARCH_RSLT_LIST_SELECTED_list` | `DKW00301SF05DBean` | Selected search result items |

Each of these lists is initialized in the constructor to hold a **single** instance (except `search_rslt_list_list`, `l_kiki_kei_div_list`, `search_rslt_list_csv_list`, `kiki_kei_div_cd_list_list`, `kiki_kei_div_nm_list_list`, and `SEARCH_RSLT_LIST_SELECTED_list`, which are initialized with zero elements and grow dynamically).

### 2. Scalar Input Fields (search criteria)

These `String` fields hold user-entered search values:

| Field | Prefix | Meaning |
|---|---|---|
| `i_svkei_no_value` | `i_` | Service contract number |
| `i_anken_no_value` | `i_` | Case number |
| `i_seizo_no_value` | `i_` | Manufacturing number |
| `search_hmpin_chsht_joken_value` | `search_` | Search condition: return item condition |
| `search_ukeire_sk_value` | `search_` | Search condition: receiving party |
| `search_hmpin_sbt_value` | `search_` | Search condition: return item type |
| `search_svkei_no_value` | `search_` | Search condition: service contract number |
| `search_anken_no_value` | `search_` | Search condition: case number |
| `search_mdl_no_value` | `search_` | Search condition: model number |
| `search_seizo_no_value` | `search_` | Search condition: manufacturing number |
| `search_search_ymd_choice_value` | `search_` | Search condition: date selection |
| `search_ymd_sta_value` | `search_` | Search condition: date range start |
| `search_ymd_end_value` | `search_` | Search condition: date range end |
| `search_shonin_ymd_sta_value` | `search_` | Search condition: approved date start |
| `search_shonin_ymd_end_value` | `search_` | Search condition: approved date end |
| `search_hmpin_kiki_no_value` | `search_` | Search condition: return machine number |
| `page_num_value` | `page_` | Current page number (initialized to `"0"`) |

### 3. UI State / Enable Flags

| Field | Type | Purpose |
|---|---|---|
| `i_svkei_no_enabled` | `Boolean` | Whether the service contract number input is enabled |
| `i_anken_no_enabled` | `Boolean` | Whether the case number input is enabled |
| `i_seizo_no_enabled` | `Boolean` | Whether the manufacturing number input is enabled |
| `style_enabled` | `Boolean` | Whether the style input is enabled (default `true`) |

### 4. UI State / Screen Controls

| Field | Purpose |
|---|---|
| `screen_mode_value` | Screen mode (initialized to `"0"`) |
| `style_value` | Display style identifier |
| `page_num_value` | Pagination page number |

### 5. "Update" / "State" Flag Pairs

For virtually every input field, there are corresponding `*_update` and `*_state` String fields. These are framework conventions:

- `*_update` — Indicates whether the value was modified on the current request (used by the framework to detect dirty state).
- `*_state` — Stores the rendered CSS/state class of the UI component (e.g., `"error"`, `"disabled"`).

### 6. Getter/Setter and SelectItem Lists

Every `X33VDataTypeList` field has a corresponding `getJsflist_typelist_*` method that converts the list into an `ArrayList<SelectItem>` for rendering as `<select>` dropdowns in JSF/X33V views.

## Constructor

The no-argument constructor initializes every `X33VDataTypeList` field to an appropriate size (usually 1 element) and populates it with a new instance of the appropriate data-bean type. This ensures that when the framework first reads the bean, the lists are non-null and contain at least one row slot.

## Data-Bean Sub-Structure

The bean does not declare fields directly on itself for all properties. Instead, search-condition data is nested inside child beans that are stored in the `X33VDataTypeList` containers. The child bean types are:

| Child Bean | List Field |
|---|---|
| `DKW00301SF01DBean` | `i_ukeire_sk_list` |
| `DKW00301SF02DBean` | `i_hmpin_chsht_joken_list`, `i_hmpin_sbt_list`, `i_search_ymd_choice_list`, `l_kiki_kei_div_list` |
| `DKW00301SF03DBean` | `i_mdl_no_list` |
| `DKW00301SF04DBean` | `i_ymd_sta_list`, `i_ymd_end_list`, `i_shonin_ymd_sta_list`, `i_shonin_ymd_end_list` |
| `DKW00301SF05DBean` | `search_rslt_list_list`, `search_rslt_list_csv_list`, `SEARCH_RSLT_LIST_SELECTED_list` |

The parent bean delegates data storage and retrieval for these nested structures by dispatching key paths through `X33VDataTypeBeanInterface` to the correct child bean at the correct index.

## Key Methods

### Data Loading and Storage

#### `loadModelData(String key, String subkey)`

The primary entry point for reading any field value from the bean. It parses a **hierarchical key path** to locate and return the correct value.

- **Parameters:**
  - `key` — A slash-delimited path string, such as `"i_svkei_no/value"` for a scalar field, or `"i_hmpin_chsht_joken/0/field_name"` for a field within a repeated list. Keys prefixed with `//` refer to shared/common-info beans and are delegated to the framework base.
  - `subkey` — A qualifier like `"value"`, `"enable"`, or `"state"` that selects which aspect of the field to return.
- **Returns:** `Object` — The value, cast to the appropriate type.
- **Behavior:**
  - If `key` is `null`, returns `null`.
  - If `subkey` is `null`, normalizes it to `""`.
  - Detects the `//` prefix for common-info bean access and delegates.
  - Splits the key on `/` to identify the target field and dispatches to the appropriate getter (e.g., `getI_svkei_no_value()`, `getSearch_ymd_sta_value()`, or `getXxx_list.get(index).storeModelData(...)` for list items).
  - The file comments describe four path patterns the framework supports:
    1. `fieldName` — simple scalar access.
    2. `fieldName/index` — list element access.
    3. `fieldName/index/dataBeanFieldName` — nested property access.
    4. `fieldName/*` — returns the list size.

#### `storeModelData(String key, String subkey, Object in_value)`

The inverse of `loadModelData`. Writes a value into the bean at the location specified by the key path.

- **Parameters:**
  - `key` — Hierarchical path (same format as `loadModelData`).
  - `subkey` — `"value"`, `"enable"`, or `"state"`.
  - `in_value` — The value to set.
- **Behavior:** Mirrors `loadModelData`'s dispatch logic, calling the appropriate setter (e.g., `setI_svkei_no_value()`, `setSearch_ymd_sta_state()`, or delegating to child bean's `storeModelData`).
- **Side effect:** Modifies the bean's internal state.

#### `storeModelData(String key, String subkey, Object in_value, boolean isSetAsString)`

Overload that adds a flag controlling whether `Long` values should be stored as `String`. Used when the framework needs to preserve string representations of numeric fields.

#### `loadModelData(String gamenId, String key, String subkey)`

Three-parameter entry point that delegates to the two-parameter version. The `gamenId` parameter is accepted for framework compatibility but is not used in the current implementation (returns `null` if `key` is `null`).

### Type Introspection

#### `typeModelData(String key, String subkey)`

Returns the Java `Class<?>` of a field, used by the framework for type checking during serialization and validation. Follows the same key-path parsing logic as `loadModelData`, but instead of reading/writing values, it returns type information.

- Returns `Integer.class` when the path ends with `/*` (indicating a list element count request).
- Delegates to child bean's `typeModelData()` for nested properties.

### List Management

#### `addListDataInstance(String key)`

Dynamically adds a new row to the list identified by `key`. Returns the index of the newly added element, or `-1` if the key is `null`.

- For common-info beans (keys starting with `//`), delegates to the framework base.
- For each repeatable field, it instantiates the appropriate data-bean type (`DKW00301SF01DBean`, etc.) and appends it.
- Enforces a maximum element count: throws a framework exception (`ERRS_CANNOT_ADD_REPEATITEM`) when the limit is reached.
- Fields with fixed size 1 (e.g., `i_hmpin_chsht_joken_list`) allow only a single initial element; new elements cannot be added beyond the configured max.
- Dynamic-size fields (e.g., `search_rslt_list_list`) have no hard limit.

#### `removeElementFromListData(String key, int index)`

Removes the element at `index` from the list identified by `key`. Validates bounds (ignores out-of-range indices). Delegates common-info removal to the framework base.

#### `clearListDataInstance(String key)`

Clears all elements from the list identified by `key`. Called typically on "reset search" or "clear results" actions.

### Metadata

#### `listServiceFormIds()`

Returns a `String[]` of all service form IDs registered on this bean. Used by the framework to enumerate available fields for serialization, validation, and rendering.

#### `listKoumokuIds(String key)`

Returns an `ArrayList<String>` of all field names (items/keys) registered on the bean. If `key` is `null`, returns the full list of all field names for the screen. Each entry is a Japanese domain label such as `"返品抽出条件"` (return item search condition), `"受入先"` (receiving party), etc.

## Usage Patterns

### Typical Framework Flow

1. The X33V framework creates an instance of `DKW00301SFBean` when the screen loads.
2. The framework calls `storeModelData("search_hmpin_chsht_joken_value", "value", userInput)` to capture user input.
3. The business logic reads search criteria using `loadModelData("i_svkei_no_value", "value")`.
4. Result rows are loaded into `search_rslt_list_list` by calling `addListDataInstance("検索結果リスト")`.
5. The framework serializes the bean to the HTTP session (it implements `Serializable`).
6. On postback, the framework restores the bean from the session and calls `loadModelData` to repopulate the view.
7. The view templates use `getJsflist_typelist_search_rslt_list()` to render dropdown selectors for search results.

### Screen State Management

Each screen field has a consistent triple of properties:

- `*_value` — The actual data.
- `*_update` — Whether the value changed on the current request (used for detecting modifications).
- `*_state` — The visual state class applied to the UI element.

This pattern allows the X33V framework to manage form state declaratively without custom controller logic.

## Relationships

### Who uses this class

Four XML game-definition files reference `DKW00301SFBean`, indicating it serves four related sub-screens within the same functional domain:

```mermaid
flowchart LR
    SubA["WEBGAMEN_DKW003010PJP.xml"]
    SubB["WEBGAMEN_DKW003020PJP.xml"]
    SubC["WEBGAMEN_DKW003030PJP.xml"]
    SubD["WEBGAMEN_DKW003040PJP.xml"]
    Bean["DKW00301SFBean<br/>Search Screen Data Model"]
    Base["X33VViewBaseBean<br/>Framework Base"]
    Interface1["X33VListedBeanInterface"]
    Interface2["X31CBaseBean"]

    SubA --> Bean
    SubB --> Bean
    SubC --> Bean
    SubD --> Bean
    Bean --> Base
    Bean --> Interface1
    Bean --> Interface2
```

### What this class depends on

- **`X33VViewBaseBean`** — Provides common functionality for screen beans including session management, common-info data handling, and exception creation.
- **`X33VListedBeanInterface`** — Contract for beans that manage repeatable (list) data structures.
- **`X31CBaseBean`** — Framework base interface for component beans.
- **Child data beans** (`DKW00301SF01DBean` through `DKW00301SF05DBean`) — Instantiated and managed within `X33VDataTypeList` containers. These are not direct code dependencies; access is through the `X33VDataTypeBeanInterface` interface.
- **`X33VDataTypeList`** — Framework collection type for typed data containers.

## Notes for Developers

### Key-Path Syntax is Critical

All data access goes through `loadModelData` / `storeModelData` using slash-delimited paths. The exact format matters:

- Scalar fields: `"fieldName/value"`, `"fieldName/state"`, `"fieldName/enable"`.
- List elements: `"listName/index/fieldPath"`.
- List size: `"listName/*"`.
- Common-info beans: `"//index/fieldPath"`.

Getting the path wrong will cause `null` to be returned or silently fail.

### List Fields Are Pre-Initialized

The constructor initializes all list fields to contain exactly **one** element (or zero for dynamic lists). This is important: if you access `i_hmpin_chsht_joken_list.get(0)` without first calling `addListDataInstance`, you will get a valid (default-constructed) `DKW00301SF02DBean`.

### Max Element Count

Fixed-size lists (initialized with `new X33VDataTypeList(1)`) enforce a maximum element count. If `addListDataInstance` is called and the list is full, it throws `ERRS_CANNOT_ADD_REPEATITEM`. Dynamic-size lists (initialized with `new X33VDataTypeList()`) have no fixed limit.

### Thread Safety

This bean is **not thread-safe**. In the X33V framework, screen beans are typically scoped to a single HTTP request or session, so concurrent access is not expected. Do not share instances across threads.

### Serializable

The class implements `Serializable`, meaning the entire bean (including all nested `X33VDataTypeList` containers and child beans) is serialized to the HTTP session on each request. Large result sets in `search_rslt_list_list` or `SEARCH_RSLT_LIST_SELECTED_list` will consume significant session memory.

### Japanese Field Names

All key paths use Japanese labels (e.g., `"返品抽出条件"`, `"受入先"`, `"検索結果リスト"`). This is a framework convention where the key is the **human-readable field name**, not the Java field ID. Be careful not to confuse `"返品抽出条件"` (the key used in `loadModelData`) with `i_hmpin_chsht_joken_list` (the internal Java field).

### SelectItem Conversion

The `getJsflist_typelist_*` methods convert `X33VDataTypeList` containers into `ArrayList<SelectItem>` for dropdown rendering. These are called by view templates to build `<select>` options.

### No Outbound Code References

Despite the 3800+ lines, the bean has no direct code-level outbound dependencies. All interaction with child beans goes through the generic `X33VDataTypeBeanInterface`, and all framework services come through `X33VViewBaseBean`. This makes the bean self-contained and easy to reason about in isolation.
