# Business Logic — CRW03407SF01DBean.addListDataInstance() [43 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.CRW03407SF.CRW03407SF01DBean` |
| Layer | Controller (Front-end data binding / View Bean — `eo.web.webview` package) |
| Module | `CRW03407SF` (Package: `eo.web.webview.CRW03407SF`) |

## 1. Role

### CRW03407SF01DBean.addListDataInstance()

This method is a **data binding utility** that dynamically creates and appends new list item instances for the "Response History External Connection" feature of screen `CRW03407SF`. In business terms, the `CRW03407SF` screen allows users to manage and display the history of external system connections — specifically URLs, URL numbers, and connection names associated with past operations. When the UI needs to add a new row to one of these repeating list grids, it calls `addListDataInstance` with the appropriate item identifier string.

The method implements the **template method pattern** inherited from `X33VViewBaseBean` (the X33 framework's base view bean). It acts as a **dispatcher/router**: based on the `key` parameter (the business item name), it routes to the correct internal list and creates the appropriate data type bean (`X33VDataTypeStringBean`) for that list. This pattern is a common UI framework convention — the framework iterates over list items and invokes this method to expand the grid with new rows.

The three supported list types are:
- **URL Number List** — `対応履歴外部接続URL番号リスト` (`l0_taiorrk_out_url_no_list`): Tracks the sequential numbering of external connection URLs in the response history.
- **URL List** — `対応履歴外部接続URLリスト` (`l0_taiorrk_out_url_list`): Holds the actual URL strings for external connections.
- **Connection Name List** — `対応履歴外部接続名リスト` (`l0_taiorrk_out_url_nm_list`): Stores human-readable connection names.

The method returns the **0-based index** of the newly appended element, enabling the caller to immediately reference or manipulate the new row. If the key is null or unrecognized, it returns `-1` to signal failure.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["addListDataInstance(key)"])
    CHECK_NULL{key == null?}
    KEY_NULL(["Return -1"])
    CHECK_URL_NO{key equals<br/>'対応履歴外部接続URL番号リスト'}
    INIT_URL_NO{l0_taiorrk_out_url_no_list is null?}
    CREATE_URL_NO_LIST["l0_taiorrk_out_url_no_list = new X33VDataTypeList()"]
    CREATE_URL_NO_BEAN["tmpBean = new X33VDataTypeStringBean()"]
    ADD_URL_NO["l0_taiorrk_out_url_no_list.add(tmpBean)"]
    RETURN_URL_NO["Return l0_taiorrk_out_url_no_list.size() - 1"]
    CHECK_URL{key equals<br/>'対応履歴外部接続URLリスト'}
    INIT_URL{l0_taiorrk_out_url_list is null?}
    CREATE_URL_LIST["l0_taiorrk_out_url_list = new X33VDataTypeList()"]
    CREATE_URL_BEAN["tmpBean = new X33VDataTypeStringBean()"]
    ADD_URL["l0_taiorrk_out_url_list.add(tmpBean)"]
    RETURN_URL["Return l0_taiorrk_out_url_list.size() - 1"]
    CHECK_NM{key equals<br/>'対応履歴外部接続名リスト'}
    INIT_NM{l0_taiorrk_out_url_nm_list is null?}
    CREATE_NM_LIST["l0_taiorrk_out_url_nm_list = new X33VDataTypeList()"]
    CREATE_NM_BEAN["tmpBean = new X33VDataTypeStringBean()"]
    ADD_NM["l0_taiorrk_out_url_nm_list.add(tmpBean)"]
    RETURN_NM["Return l0_taiorrk_out_url_nm_list.size() - 1"]
    NO_MATCH(["Return -1"])

    START --> CHECK_NULL
    CHECK_NULL -->|true| KEY_NULL
    CHECK_NULL -->|false| CHECK_URL_NO
    CHECK_URL_NO -->|true| INIT_URL_NO
    CHECK_URL_NO -->|false| CHECK_URL
    INIT_URL_NO -->|true| CREATE_URL_NO_LIST
    INIT_URL_NO -->|false| CREATE_URL_NO_BEAN
    CREATE_URL_NO_LIST --> CREATE_URL_NO_BEAN
    CREATE_URL_NO_BEAN --> ADD_URL_NO
    ADD_URL_NO --> RETURN_URL_NO
    RETURN_URL_NO --> END_NODE(["End"])
    CHECK_URL -->|true| INIT_URL
    CHECK_URL -->|false| CHECK_NM
    INIT_URL -->|true| CREATE_URL_LIST
    INIT_URL -->|false| CREATE_URL_BEAN
    CREATE_URL_LIST --> CREATE_URL_BEAN
    CREATE_URL_BEAN --> ADD_URL
    ADD_URL --> RETURN_URL
    RETURN_URL --> END_NODE
    CHECK_NM -->|true| INIT_NM
    CHECK_NM -->|false| NO_MATCH
    INIT_NM -->|true| CREATE_NM_LIST
    INIT_NM -->|false| CREATE_NM_BEAN
    CREATE_NM_LIST --> CREATE_NM_BEAN
    CREATE_NM_BEAN --> ADD_NM
    ADD_NM --> RETURN_NM
    RETURN_NM --> END_NODE
    NO_MATCH --> END_NODE
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `key` | `String` | The item identifier (item name) that specifies which list to add a new row to. Must be one of three exact Japanese string literals matching the three supported "Response History External Connection" list types: URL number list, URL list, or connection name list. If null, the method returns -1 immediately. If an unrecognized value is passed, it falls through to the default case and also returns -1. |

**Instance fields read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `l0_taiorrk_out_url_no_list` | `X33VDataTypeList` | Internal list holding URL number beans for the response history external connection records. Initialized to a new empty `X33VDataTypeList` in the constructor. |
| `l0_taiorrk_out_url_list` | `X33VDataTypeList` | Internal list holding URL string beans for the response history external connection records. Initialized to a new empty `X33VDataTypeList` in the constructor. |
| `l0_taiorrk_out_url_nm_list` | `X33VDataTypeList` | Internal list holding connection name beans for the response history external connection records. Initialized to a new empty `X33VDataTypeList` in the constructor. |

## 4. CRUD Operations / Called Services

This method is a **pure view-bean data binding** method — it does not invoke any service components (SC), data access beans (CBS), or database operations. All operations are in-memory list manipulations on the X33 framework's view bean data structures.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| — | *(none)* | — | — | No SC/CBS calls. This method only manipulates local view bean lists in the controller layer. |

**Internal operations (non-CRUD):**

| Operation | Class/Method | Description |
|-----------|-------------|-------------|
| Object creation | `X33VDataTypeList` constructor | Creates a new empty typed list container when the target list field is `null` |
| Object creation | `X33VDataTypeStringBean` constructor | Creates a new string data type bean instance with default (empty) initial value |
| List mutation | `X33VDataTypeList.add()` | Appends a new bean instance to the end of the list |
| List read | `X33VDataTypeList.size()` | Returns the current number of elements for computing the 0-based index |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:CRW03407SF (indirect) | `CRW03407SFBean.addListDataInstance(key)` → `super.addListDataInstance(key)` → falls through to framework routing (not directly to `CRW03407SF01DBean.addListDataInstance` for all keys) | *(none — view bean only)* |

**Notes:**
- `CRW03407SF01DBean.addListDataInstance(String key)` is the **subclass override** that handles the three specific "Response History External Connection" list types directly (lines 536–578).
- `CRW03407SFBean.addListDataInstance(String key)` (the parent bean, line ~14356) has its own extensive `addListDataInstance` method that handles many different list types (including delegating to `super.addListDataInstance(key)` as a fallback at the end).
- This method is part of the X33 framework's view bean lifecycle and is called by the framework's list data binding mechanism when rendering dynamic grid rows on the `CRW03407SF` screen.

## 6. Per-Branch Detail Blocks

**Block 1** — [IF] `(key == null)` (L540)

> Null guard: if the key parameter is null, the method cannot determine which list to operate on. Return -1 to signal failure.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return -1;` // null case — cannot determine target list |

**Block 2** — [ELSE-IF] `(key.equals("対応履歴外部接続URL番号リスト"))` — `ODR_URL_NO_LIST = "対応履歴外部接続URL番号リスト"` (L544)

> Branch for the "Response History External Connection URL Number List" item. Adds a new string bean to the URL number list. If the list hasn't been initialized yet, creates a new empty `X33VDataTypeList` first. The business purpose is to add a new row to the URL number grid on the screen.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (l0_taiorrk_out_url_no_list == null)` // list is null, generate a new empty instance |
| 1.1 | SET | `l0_taiorrk_out_url_no_list = new X33VDataTypeList();` // initialize with new empty list |
| 2 | EXEC | `X33VDataTypeStringBean tmpBean = new X33VDataTypeStringBean();` // create a new instance of the specified data type bean via the data type bean type (see comments) // データ型ビーン型で指定したデータ型ビーンのインスタンスを生成する。なお、データ型ビーンの項目初期値設定は、各データビーン内部で定義 |
| 3 | CALL | `l0_taiorrk_out_url_no_list.add(tmpBean);` // add the new bean to the list |
| 4 | RETURN | `return l0_taiorrk_out_url_no_list.size() - 1;` // return the 0-based index of the newly added element |

**Block 3** — [ELSE-IF] `(key.equals("対応履歴外部接続URLリスト"))` — `ODR_URL_LIST = "対応履歴外部接続URLリスト"` (L555)

> Branch for the "Response History External Connection URL List" item. Adds a new string bean to the URL list. This holds the actual URL strings for external connections in the response history. If the list hasn't been initialized yet, creates a new empty `X33VDataTypeList` first.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (l0_taiorrk_out_url_list == null)` // list is null, generate a new empty instance |
| 1.1 | SET | `l0_taiorrk_out_url_list = new X33VDataTypeList();` // initialize with new empty list |
| 2 | EXEC | `X33VDataTypeStringBean tmpBean = new X33VDataTypeStringBean();` // create a new instance of the specified data type bean (same as Block 2) |
| 3 | CALL | `l0_taiorrk_out_url_list.add(tmpBean);` // add the new bean to the list |
| 4 | RETURN | `return l0_taiorrk_out_url_list.size() - 1;` // return the 0-based index of the newly added element |

**Block 4** — [ELSE-IF] `(key.equals("対応履歴外部接続名リスト"))` — `ODR_NM_LIST = "対応履歴外部接続名リスト"` (L566)

> Branch for the "Response History External Connection Name List" item. Adds a new string bean to the connection name list. This holds human-readable names for the external connections. If the list hasn't been initialized yet, creates a new empty `X33VDataTypeList` first.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (l0_taiorrk_out_url_nm_list == null)` // list is null, generate a new empty instance |
| 1.1 | SET | `l0_taiorrk_out_url_nm_list = new X33VDataTypeList();` // initialize with new empty list |
| 2 | EXEC | `X33VDataTypeStringBean tmpBean = new X33VDataTypeStringBean();` // create a new instance of the specified data type bean (same as previous blocks) |
| 3 | CALL | `l0_taiorrk_out_url_nm_list.add(tmpBean);` // add the new bean to the list |
| 4 | RETURN | `return l0_taiorrk_out_url_nm_list.size() - 1;` // return the 0-based index of the newly added element |

**Block 5** — [ELSE] `(no match)` (L576)

> Default case: no branch matched the key. The key is not null but also doesn't correspond to any of the three supported list types. Return -1 to signal that the item is not recognized.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return -1;` // no matching item found — return -1 |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `l0_taiorrk_out_url_no_list` | Field | URL Number List — internal tracking list for the sequential numbers of external connection URLs in the response history. The `l0_` prefix indicates a local field in this data bean. |
| `l0_taiorrk_out_url_list` | Field | URL List — internal list holding the actual URL string values for external connections in the response history. |
| `l0_taiorrk_out_url_nm_list` | Field | Connection Name List — internal list holding human-readable connection names for the response history. |
| `taiorrk` | Domain acronym | 対応履歴 (Taiou Rireki) — Response History / Correspondence History. Refers to the historical record of external system connection activities. |
| `out_url` | Field prefix | 外部接続URL (Gaisetsuzoku URL) — External Connection URL. A URL used to connect to an external system. |
| 対応履歴外部接続URL番号リスト | Field key | Response History External Connection URL Number List — the complete Japanese item name string that identifies the URL number list in this method's dispatch logic. |
| 対応履歴外部接続URLリスト | Field key | Response History External Connection URL List — the complete Japanese item name string that identifies the URL list. |
| 対応履歴外部接続名リスト | Field key | Response History External Connection Name List — the complete Japanese item name string that identifies the connection name list. |
| `X33VDataTypeStringBean` | Framework class | A data type bean from the X33 framework representing a single string-typed UI field. Used here as the element type for each list. |
| `X33VDataTypeList` | Framework class | A typed list container from the X33 framework that holds beans of a specific type. Provides `add()`, `size()`, and list management operations. |
| `X33VListedBeanInterface` | Interface | X33 framework interface that enables a bean to be used within listed (repeating) grid components on the UI. |
| `X33SException` | Framework class | Exception class from the X33 framework for screen-level business exceptions. |
| CRW03407SF | Screen module | A web screen module in the K-Opticom system for managing response history external connections. Part of the Fujitsu X33 web client framework. |
| DBean | Naming convention | "Data Bean" — a subclass of the main screen bean that holds typed data structures for UI binding. The `01` suffix typically indicates the primary detail-level data bean. |
| X33 Framework | Technical | Fujitsu Futurity X33 — an enterprise web client framework for building JSF-based applications. Provides base bean classes, data type beans, and list handling utilities. |
