項目制御情報はsetItemAttributeメソッドを利用して設定します。setItemAttributeメソッドの引数には、項目のXPath、項目属性の名前、項目属性の値を指定します。
import com.fujitsu.form.ItemAttributeAccess; import com.fujitsu.uji.formc.ItemAttributes; ... FormDataBean formBean = new FormDataBean("SampleForm"); formBean.setItemAttribute("group/name", ItemAttributes.COLOR, ItemAttributeAccess.RED); formBean.setItemAttribute("group/list", ItemAttributes.LISTBOXVALUE, "東京¥¥n大阪");
ポイント
ドロップダウンリストの選択リストは、改行("¥¥n")で分割した文字列を記述します。
ItemAttributesクラスを利用して一括して設定することもできます。
import com.fujitsu.form.ItemAttributeAccess; import com.fujitsu.uji.formc.ItemAttributes; ... FormDataBean formBean = new FormDataBean("SampleForm"); ItemAttributes attributes = new ItemAttributes(); attributes.putAttribute(ItemAttributes.COLOR, ItemAttributeAccess.RED); attributes.putAttribute(ItemAttributes.FONTSTYLE, ItemAttributeAccess.ITALIC); formBean.setItemAttribute("group/name", attributes);
項目属性の名前はItemAttributesクラス、項目属性の値はItemAttributeAccessクラスで定義されています。それぞれのフィールドの意味は、“APIリファレンス”を参照してください。
入力時にビジネスクラスに渡されるFormデータBeanでは、直前の表示で利用した項目制御情報を保持しています。複数の画面を同時に表示する場合など、直前の表示とは異なる画面を利用する場合は、項目制御情報がクリアされます。このような場合に設定した項目情報を何度も利用するためには、FormデータBeanをセションクラス等に保存する必要があります。