# FUW00927SFBean

## Purpose

`FUW00927SFBean` is the central view data bean for screen **FUW00927**, a Japanese home network alarm system contract application. It encapsulates all form data for a single-page JSF interface that collects customer information, displays itemized billing (monthly and initial fees), manages repeatable line-item lists, and handles UI state (enabled/disabled, display toggles) for the contract flow. With 2 inbound connections (`WEBGAMEN_FUW009270PJP.xml` and `FUW009270PJP.jsp`), this class is a key coordination point between the view layer and the broader X33V framework.

## Design

This class follows the **Model-View data bean** pattern (sometimes called a "screen bean" or "form bean") common in Japanese enterprise JSF applications built on the **X33V** framework. It is not a service, entity, or controller — it is a mutable data container that bridges JSF view components and the framework's data-binding infrastructure.

The class uses a repetitive field structure with three parallel naming conventions:
- **`_update`** flags — control whether a field should be re-rendered on the next view pass
- **`_value`** — holds the actual form data (mostly `String`, one `Boolean`)
- **`_state`** — manages UI state such as "enabled", "visible", or "readonly"

Each field triplet maps to a JSF component (input text, select one, etc.). Additionally, the bean declares a dozen `X33VDataTypeList` fields to hold dynamically-sized lists of repeating form rows (e.g., itemized billing lines). For each such list, there is a corresponding `getJsflist_*()` method that converts the internal list into a JSF `SelectItem` array for `<h:selectOneMenu>` rendering.

### Interfaces

| Interface | Role |
|---|---|
| `X33VListedBeanInterface` | Requires `addListDataInstance`, `removeElementFromListData`, `clearListDataInstance`, `listServiceFormIds`, `listKoumokuIds` — manages repeatable list rows |
| `X31CBaseBean` | Requires `loadModelData`, `storeModelData`, `typeModelData` — unified key/subkey data access |
| `Serializable` | Allows the bean to be serialized across session/scopes |

### Inheritance

```
extends X33VViewBaseBean
```

The base bean `X33VViewBaseBean` presumably provides common infrastructure (screen ID, view lifecycle hooks, common data binding). When a key starts with `//`, the bean delegates to `super` methods for shared/common info blocks (e.g., company code, session tokens).

### Field Categories

The bean's ~130 protected fields fall into these groups:

**1. Screen Control Fields** (simple value/state triplets)
- `fnc_mode_*` — functional mode flags
- `screen_mode_*` — screen display mode
- `dsp_close_btn_flg_*` — close button visibility
- `dsp_add_btn_flg_*` — add row button visibility
- `dsp_next_btn_flg_*` — next button visibility
- `dsp_pcd_flg_*` — postal code display flag
- `dsp_same_use_place_kkoku_flg_*` — same-location alarm display flag
- `twryo_stiam_ttu_tchi_stiam_*` — dual-station notification thresholds
- `kei_svc_area_dsp_flg_*` — service area display flag (Boolean)

**2. Single-Row Business Fields** (simple value/state triplets)
- `sex_*` — contract type / gender
- `hnin_cfm_aticle_*` — confirmation document flag
- `setplace_form_*`, `setplace_flr_*`, `setplace_bnchi_*` — installation address (form, floor, residence number)
- `use_net_ksn_*` — current network cable
- `kiki_place_chg_*` — device location change plan
- `tkc_koji_same_*` — same-day inspection and work
- `rrks_choice_*`, `fax_kibo_*` — contact preferences

**3. Monthly Fee Line-Item Lists** (X33VDataTypeList + triplets + SelectItem helpers)
- `getsu_ryokin_kmk_*` — monthly fee item rows
- `getsu_ryokin_*` — monthly fee amount rows
- `getsu_ryokin_kei_*` — monthly fee total rows
- `getsu_ryokin_kei_zei_*` — monthly fee total (tax excluded) rows
- `getsu_ryokin_mongon_*` — monthly fee message rows
- `getsu_ryokin_kei_title_*`, `getsu_ryokin_kei_gh_*` — title and GH-specific rows

**4. Initial Cost Line-Item Lists** (same pattern as monthly fees)
- `shoki_hiyo_kmk_*`, `shoki_hiyo_*` — initial cost item/amount rows
- `shoki_hiyo_kei_*`, `shoki_hiyo_kei_zei_*` — initial cost total rows
- `shoki_hiyo_mongon_*` — initial cost message rows

**5. Total Calculation Fields**
- `gtgk_prc_gokei_*` — total price grand total rows
- `gtgk_prc_gokei_mongon_*` — total price message rows
- `shkh_gokei_*` — shipment total rows
- `shkh_gokei_mongon_*` — shipment total message rows

**6. Discount Application Period Lists**
- `gtgk_wrib_mngn_tk_kikan_*` — discount application period rows
- `gtgk_wrib_mngn_wrib_nm_*` — discount name rows
- `gtgk_wrib_mngn_wrib_amnt_*` — discount amount rows
- `gtgk_wrib_mngn_biko_*` — discount remarks rows

**7. Smart Remote / GH-specific Line-Item Lists** (sml = smart remote, gh = GH)
- `getsu_ryokin_kmk_sml_*`, `getsu_ryokin_sml_*` — monthly fee item/amount (smart remote)
- `shoki_hiyo_kmk_sml_*`, `shoki_hiyo_sml_*` — initial cost item/amount (smart remote)
- `getsu_ryokin_kei_sml_*`, `shoki_hiyo_kei_sml_*` — totals (smart remote)
- `getsu_ryokin_kmk_gh_*`, `getsu_ryokin_gh_*` — monthly fee item/amount (GH)
- `shoki_hiyo_kmk_gh_*`, `shoki_hiyo_gh_*` — initial cost item/amount (GH)
- `getsu_ryokin_kei_gh_*`, `shoki_hiyo_kei_gh_*` — totals (GH)

**8. Mobile Fields**
- `mobile_month_*`, `mobile_init_*` — mobile monthly/init fee calculations
- `mobile_month_mongon_*`, `mobile_init_mongon_*` — mobile messages

**9. Metadata Fields**
- `cx_start_flg_*` — GP case start flag
- `takcho_apo_kaden_kibo_um_*` — home inspection appointment desired display flag/screen

## Key Methods

### Constructor

```java
public FUW00927SFBean()
```

**Lines 255–278**

Initializes all 21 `X33VDataTypeList` fields to new empty `X33VDataTypeList` instances via the "constant block generation" (定数ブロックの宣言生成) section. String fields default to `""` via their field declarations. Boolean fields default to `false` or `true`.

> **Note:** Because the constructor only initializes the Lists (not individual `X33VDataTypeStringBean` entries inside them), calling `addListDataInstance` is the standard way to add rows.

### loadModelData

```java
public Object loadModelData(String key, String subkey)
```

**Lines 2173–3391**

Retrieves a field value by its Japanese display name and a subkey ("value", "state", or an index). This is the framework's unified data accessor — the framework calls this method when binding JSF components to bean properties.

**Key parsing logic:**

| Key Pattern | Behavior |
|---|---|
| `//index/key` | Delegated to common info handler (`super.loadCommonInfoData`) |
| `フィールド名` (e.g., `機能コード`) | Simple field: returns `getValue()` or `getState()` based on subkey |
| `フィールド名/インデックス` (e.g., `項目コード/0`) | Repeatable list: retrieves the bean at the given index |
| `フィールド名/*` | Returns list size as `Integer` |

The method contains a massive `if-else` chain covering all field groups. For each field type it:
1. Extracts the primary field name by splitting on `/`
2. If subkey is `"value"`, calls the appropriate `getXxx_value()`
3. If subkey is `"state"`, calls `getXxx_state()`
4. If the field is a repeatable list and an index is provided, casts the list element to `X33VDataTypeStringBean` and calls `loadModelData(subkey)` on it
5. If subkey is `"*"`, returns the list size as `Integer`

**Return value:** `Object` — the field's current value, or `null` if the key is unrecognized or the index is out of bounds.

### storeModelData

```java
public void storeModelData(String key, String subkey, Object in_value)
public void storeModelData(String key, String subkey, Object in_value, boolean isSetAsString)
```

**Lines 3401–4550**

Sets a field value by its Japanese display name and subkey. Mirror of `loadModelData` with write semantics.

**Behavior:**
- If key starts with `//`, delegates to `super.storeCommonInfoData`
- Parses the key to determine which field group it belongs to
- Routes to the appropriate setter: `setXxx_value(in_value)` or `setXxx_state(in_value)`
- For repeatable lists, casts the target element to the correct `X33VDataType*Bean` type and calls `storeModelData(subkey, in_value)` on it
- The `isSetAsString` flag is used when setting `Long`-typed value properties from string values

### typeModelData

```java
public Class<?> typeModelData(String key, String subkey)
```

**Lines 5200–6420**

Returns the Java type of a field's value, used by the framework for type-safe data binding and validation.

**Behavior:**
- Returns `String.class` for simple value/state fields
- Returns `Integer.class` when subkey is `"*"` (list size)
- Returns `Boolean.class` for boolean fields (e.g., `kei_svc_area_dsp_flg_value`)
- For repeatable lists, delegates to the element's `typeModelData` method
- Returns `null` for unrecognized keys

> **Important:** Every list element is typed as `X33VDataTypeStringBean` — the `typeModelData` method always casts to this type regardless of the list's intended business type. This means the actual data type is stored as `String` at runtime.

### listKoumokuIds

```java
public ArrayList<String> listKoumokuIds(String key)
```

**Lines 4565–4662**

Returns the list of field display names (Japanese labels) used by this screen. When `key == null`, returns all ~50 field labels. When `key` starts with `/` and has length > 2, delegates to `super.listKoumokuIds`. Otherwise returns an empty list.

This is used by the framework's field introspection / form rendering engine to know which fields exist on the screen.

### addListDataInstance

```java
public int addListDataInstance(String key) throws X33SException
```

**Lines 4669–4894**

Appends a new row to a repeatable list. Returns the index of the newly added row, or `-1` if the key is `null` or unrecognized.

**Behavior for each field type:**
- If key starts with `//`, delegates to `super.addListDataInstance(key)`
- Otherwise, ensures the corresponding `X33VDataTypeList` is not null, creates a new `X33VDataTypeStringBean`, adds it to the list, and returns `list.size() - 1`

**Supported keys (Japanese labels):** All 21 list fields, e.g., `月額料金項目`, `月額料金`, `初期費用項目`, `月額料金（スマートリンク）`, etc.

### removeElementFromListData

```java
public void removeElementFromListData(String key, int index) throws X33SException
```

**Lines 4901–5058**

Removes a row from a repeatable list at the given index. If the index is out of bounds, no-op (silent). Delegates to `super` for common info blocks (`//` keys).

### clearListDataInstance

```java
public void clearListDataInstance(String key)
```

**Lines 5064–5179**

Clears all rows from a repeatable list by calling `list.clear()`. Does NOT null the list — it preserves the list reference (the constructor initialized them). Delegates to `super` for common info blocks.

### getJsflist_* Methods

```java
public ArrayList<SelectItem> getJsflist_koumoku_code()
public ArrayList<SelectItem> getJsflist_getsu_ryokin_kmk()
// ... (21 such methods)
```

**Example (lines 340–348):**

```java
public ArrayList<SelectItem> getJsflist_koumoku_code() {
    ArrayList ary = new ArrayList<SelectItem>();
    for (int i = 0; i < koumoku_code_list.size(); i++) {
        String itemValue = (String) ((X33VDataTypeStringBean) koumoku_code_list.get(i)).getValue();
        SelectItem item = new SelectItem(new Integer(i).toString(), itemValue);
        ary.add(item);
    }
    return ary;
}
```

Each `getJsflist_*` method iterates over its corresponding `X33VDataTypeList`, extracts the `value` from each `X33VDataTypeStringBean`, and converts them into a `List<SelectItem>` for JSF dropdown rendering. The dropdown value is the zero-based row index; the display text is the bean's `value`. This enables the JSF view to bind a `<h:selectOneMenu>` to any repeatable list.

### listServiceFormIds

```java
public String[] listServiceFormIds()
```

**Lines 4556–4558**

Returns `null`. This is a framework-required method; this screen does not participate in the multi-form service grouping mechanism.

### Simple Getters/Setters

Every protected field has a public getter and setter (except where the `getJsflist_*` methods serve as the getter). For example:

```java
public String getFnc_mode_update() { return this.fnc_mode_update; }
public void setFnc_mode_update(String param) { this.fnc_mode_update = param; }
public String getFnc_mode_value() { return this.fnc_mode_value; }
public void setFnc_mode_value(String param) { this.fnc_mode_value = param; }
public String getFnc_mode_state() { return this.fnc_mode_state; }
public void setFnc_mode_state(String param) { this.fnc_mode_state = param; }
```

These follow a consistent `XXX_update`, `XXX_value`, `XXX_state` naming pattern. The framework or the JSP uses these names to bind JSF components.

## Relationships

```mermaid
flowchart TD
    A["FUW00927SFBean<br/>View Data Bean"] --> B["X33VViewBaseBean<br/>Base View Bean"]
    A --> C["X31CBaseBean<br/>Data Binding Interface"]
    A --> D["X33VListedBeanInterface<br/>List Management Interface"]
    A --> E["java.io.Serializable"]
    A --> F["Simple Fields<br/>_update/_value/_state triplets<br/>e.g., fnc_mode, screen_mode"]
    A --> G["Repeatable Lists<br/>X33VDataTypeList<br/>e.g., getsu_ryokin_kmk, shoki_hiyo, tt"]
    A --> H["Display List Helpers<br/>getJsflist_*<br/>Converts to SelectItem"]
    A --> I["Core Methods<br/>loadModelData<br/>storeModelData<br/>typeModelData"]
    A --> J["List Ops<br/>addListDataInstance<br/>removeElementFromListData<br/>clearListDataInstance"]
    A --> K["Metadata<br/>listServiceFormIds<br/>listKoumokuIds"]
```

### Inbound (Consumers)

| Consumer | Role |
|---|---|
| `WEBGAMEN_FUW009270PJP.xml` | JSF page configuration / navigation rules — references the bean to bind form components |
| `FUW009270PJP.jsp` | JSF page (JSP view) — directly references bean properties for data binding |

### Outbound (Dependencies)

No outbound class-level references are declared. The bean depends on:
- **`X33VViewBaseBean`** — base class with common view infrastructure
- **`X33VListedBeanInterface`** — interface for list management
- **`X31CBaseBean`** — interface for unified data access
- **`X33VDataTypeList`** — framework list container
- **`X33VDataTypeStringBean`** — typed string value wrapper for list rows
- **`X33SException`** — checked exception for list operations
- **`java.util.ArrayList`**, **`javax.faces.model.SelectItem`**, **`java.io.Serializable`** — standard Java/JSF types

```mermaid
flowchart LR
    WEB["WEBGAMEN_FUW009270PJP.xml"] --> BEAN["FUW00927SFBean"]
    JSP["FUW009270PJP.jsp"] --> BEAN
    BEAN --> BASE["X33VViewBaseBean"]
    BEAN --> IF1["X31CBaseBean"]
    BEAN --> IF2["X33VListedBeanInterface"]
    BEAN --> LIST["X33VDataTypeList"]
    BEAN --> SBEAN["X33VDataTypeStringBean"]
```

## Usage Example

### Typical Life Cycle in an X33V Application

```
1. Framework instantiates the bean
   FUW00927SFBean bean = new FUW00927SFBean();
   // Constructor initializes all 21 X33VDataTypeList instances

2. Framework loads initial data via loadModelData()
   Object code = bean.loadModelData("機能コード", "value");

3. JSF renders the page, binding to bean properties
   // JSP accesses: #{bean.fnc_mode_value}, #{bean.getsusuRyokinKmkList}

4. User adds a billing line item
   int idx = bean.addListDataInstance("月額料金項目");
   // Returns 0 for first row; framework populates via storeModelData

5. User edits a field in a row
   bean.storeModelData("項目コード/0/value", "value", "NEW_VALUE");

6. User removes a row
   bean.removeElementFromListData("月額料金項目", idx);

7. JSF renders dropdowns using SelectItem lists
   List<SelectItem> items = bean.getJsflist_getsu_ryokin_kmk();

8. User submits; framework stores via storeModelData()
   bean.storeModelData("月額料金/0/value", "value", "1000");

9. Navigation — framework may call listServiceFormIds() to determine scope
```

### Key Binding Pattern

The X33V framework uses Japanese display names (フィールド名) as the primary key for data binding. The mapping between a Japanese label and a bean property is one-directional:

```
Japanese Display Name  →  Bean Fields
機能コード             →  fnc_mode_update, fnc_mode_value, fnc_mode_state
画面モード             →  screen_mode_update, screen_mode_value, screen_mode_state
項目コード             →  koumoku_code_list (X33VDataTypeList)
値                     →  koumoku_value_list (X33VDataTypeList)
月額料金項目           →  getsu_ryokin_kmk_list
月額料金               →  getsu_ryokin_list
月額料金計             →  getsu_ryokin_kei_list
初期費用項目           →  shoki_hiyo_kmk_list
初期費用               →  shoki_hiyo_list
```

The JSF page (`FUW009270PJP.jsp`) binds directly to these property names. The framework's XML configuration (`WEBGAMEN_FUW009270PJP.xml`) likely maps the Japanese labels to the bean properties.

## Notes for Developers

### Field Naming Convention

Every simple field follows a **triplet pattern** with three parallel fields:
- `xxx_update` — set by the view layer to signal that this field needs re-rendering
- `xxx_value` — holds the actual business data
- `xxx_state` — manages UI state (enabled, visible, readonly)

When adding a new field, all three must be declared together with matching naming.

### Repeatable List Management

Repeatable lists use **zero-based integer indices** in the key scheme (e.g., `月額料金項目/0/value`). The framework manages row lifecycle:
1. `addListDataInstance` creates a new `X33VDataTypeStringBean` and appends it
2. `storeModelData` writes to a specific index
3. `removeElementFromListData` removes at a specific index (shifts remaining rows)
4. `clearListDataInstance` empties the list but preserves the reference

> **Gotcha:** After `removeElementFromListData`, indices of remaining rows shift. The JSF view must re-render to reflect the new indices.

### All List Elements Are X33VDataTypeStringBean

Despite the list names suggesting numeric or typed data, every list element is cast to `X33VDataTypeStringBean` throughout `loadModelData`, `storeModelData`, and `typeModelData`. The actual business values (amounts, indices) are stored as strings and presumably parsed by the presentation layer. Do not assume numeric precision at the bean level.

### Thread Safety

This bean is **not thread-safe**. It is designed to be instantiated once per request/session and accessed by a single thread. The X33V framework typically scopes such beans to the HTTP session or request scope.

### Key Format Quirks

1. **Common info keys** start with `//` followed by an index and key (e.g., `//0/会社コード`). The `//` is the delimiter, not an escape.
2. **Wildcard key** uses `*` to request list size (e.g., `項目コード/*` returns `Integer` of the list size).
3. **Numeric subkeys** are parsed with `Integer.valueOf()` and silently return `null` on `NumberFormatException`.

### No Outbound Class Dependencies

The bean declares no `import` statements beyond the standard Java/JSF types it uses. All other dependencies are through the framework base class and interfaces. This makes the bean self-contained but also means any changes to the framework's data types (e.g., `X33VDataTypeList`) may have cascading effects.

### listServiceFormIds Returns null

The method always returns `null`. If the X33V framework uses this for multi-screen form grouping, this screen operates as a standalone form. Do not change this method without understanding the framework's grouping semantics.

### Large Methods

The three core methods — `loadModelData` (lines 2173–3391), `storeModelData` (lines 3424–4550), and `typeModelData` (lines 5200–6420) — are each 1200+ lines of repetitive if-else chains. They are auto-generated by the framework's code generator and follow a mechanically identical pattern for each field. Any changes to field definitions should be made in the X33V design tool/code generator, not by manually editing this file.

### Boolean Field Exception

`kei_svc_area_dsp_flg_value` and `kei_svc_area_dsp_flg_update` are `Boolean` type, not `String`. The getter/setter for `kei_svc_area_dsp_flg_value` uses `Boolean`, and `typeModelData` returns `Boolean.class` for this field specifically.

### Mobile Init Value Setter

There is an asymmetry in the mobile init field setters: `setMobile_init_value` does not exist; instead, `setMobile_init_value(String param)` at lines 567–569 exists but the getter `getMobile_init_value()` appears at lines 563–565. The setter method name `setMobile_init_value` maps to the `_value` field but is defined between `setMobile_init_update` (line 559) and `getMobile_init_state()` (line 571), which is slightly out of the expected triplet order. This is likely intentional to match the framework's expected property binding order.

### Common Info Block Handling

When a key starts with `//`, the bean delegates to `super` methods for common/shared info blocks (e.g., company code, user ID). These are typically managed by the framework's session or context infrastructure. Never modify `//`-prefixed keys in the bean — they are handled entirely by `X33VViewBaseBean`.
