🌟
WebFOCUSのRESTful APIでカスタム変数入力フォームを作成する
RESTful APIを使ってカスタム変数入力フォームを作成する
はじめに
WebFOCUSのRESTful APIのibfsサービスで利用できるdescribeFexを使って独自の変数入力フォームを作成します。
これが出来れば、レポート毎に変数入力用のHTMLを作成する必要が無くなります。
- 標準のオートプロンプトを使いたくない
- 同じような項目を入力する画面をレポート毎に作りたくない
- 自由に入力欄を配置して、CSSでデザインしたい
そんな方に勧める方法です。
標準のオートプロンプト画面
標準で選べるパラメータのプロンプト画面デザイン
標準でもいくつかのパターンでパラメータのプロンプトのデザインを変更できます。
変更方法
変更後のデザイン
HTML_TOP
HTML_TOP_CHECKED 新規ウィンドウで実行に✅がデフォルト
レスポンシブ
カスタム変数入力フォームで出来る事
- 自由に入力フォームをデザインする
- 特定の変数名に対応する入力方法を作成しておける
- フォーマットに対応したバリデーションを設定できる
- 変数名に規則を持たせて自在にフォームを配置できる
RESTful APIコール
- エンドポイント: http[s]://hostname:port/ibi_apps/rs
- パラメータ
-
IBIRS_path=
fexのフルパス
-
IBIRS_action=
describeFex
-
IBIRS_args=
__null
-
IBIRS_random=
乱数
-
IBIRS_service=
ibfs
-
IBIRS_path=
レスポンスXML
対象のfex
-DEFAULTS DEF_1='AAA',DEF_2='BBB'
-DEFAULTH DEFH_1='ABC',DEFH_2='DEF'
-TYPE &DEF_2
-TYPE &DEFH_2
-TYPE &UND_1
-TYPE &UND_2.A8.
-TYPE &UND_3.A8.テキスト.
-TYPE &UND_4.(SEL1,SEL2.SEL3).
レスポンスXMLの全文
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<ibfsrpc _jt="IBFSResponseObject" language="ja_JP" name="describeFex" returncode="10000" returndesc="SUCCESS" subreturncode="0" type="simple">
<ibfsparams size="2">
<entry key="IBIRS_args" value="__null"/>
<entry key="IBIRS_path" value="IBFS%3A%2FWFC%2FRepository%2Ftest%2Famptest.fex"/>
</ibfsparams>
<rootObject class="com.ibi.wfrs.IBFSWFDescribe" formAction="/ibi_apps/rs" isSavedParam="false" nrOfDefaultVars="2" nrOfPromptVars="6">
<describeLevel class="com.ibi.wfrs.WFDescribeFlag" name="XMLRUN"/>
<bindingInfo _jt="HashMap">
<entry>
<key _jt="string" value="IBIF_describe_null"/>
<value class="com.ibi.wfrs.IBFSWFDescribe$BindingVar" isReqParm="false" value="_FOC_NULL"/>
</entry>
<entry>
<key _jt="string" value="IBIC_server"/>
<value class="com.ibi.wfrs.IBFSWFDescribe$BindingVar" isReqParm="false" value="EDASERVE"/>
</entry>
<entry>
<key _jt="string" value="IBFS_description"/>
<value class="com.ibi.wfrs.IBFSWFDescribe$BindingVar" isReqParm="false" value="AMPTEST"/>
</entry>
<entry>
<key _jt="string" value="IBIRS_path"/>
<value class="com.ibi.wfrs.IBFSWFDescribe$BindingVar" isReqParm="true" value="IBFS%3A%2FWFC%2FRepository%2Ftest%2Famptest.fex"/>
</entry>
<entry>
<key _jt="string" value="FOCEXURL"/>
<value class="com.ibi.wfrs.IBFSWFDescribe$BindingVar" isReqParm="false" value="/ibi_apps/rs?IBIF_webapp=/ibi_apps&IBIC_server=EDASERVEtest=test&"/>
</entry>
<entry>
<key _jt="string" value="IBIAPP_app"/>
<value class="com.ibi.wfrs.IBFSWFDescribe$BindingVar" isReqParm="false" value="test"/>
</entry>
<entry>
<key _jt="string" value="IBI_PostMsgsToParent"/>
<value class="com.ibi.wfrs.IBFSWFDescribe$BindingVar" isReqParm="true" value="ON"/>
</entry>
<entry>
<key _jt="string" value="IBIRS_random"/>
<value class="com.ibi.wfrs.IBFSWFDescribe$BindingVar" isReqParm="true" value="6077"/>
</entry>
<entry>
<key _jt="string" value="IBFS_name"/>
<value class="com.ibi.wfrs.IBFSWFDescribe$BindingVar" isReqParm="false" value="amptest.fex"/>
</entry>
<entry>
<key _jt="string" value="SAVE_PARMS_PATH"/>
<value class="com.ibi.wfrs.IBFSWFDescribe$BindingVar" isReqParm="false" value="IBFS:/WFC/Repository/test"/>
</entry>
<entry>
<key _jt="string" value="IBI_CSRF_Token_Name"/>
<value class="com.ibi.wfrs.IBFSWFDescribe$BindingVar" isReqParm="false" value="トークン名"/>
</entry>
<entry>
<key _jt="string" value="SAVE_FEX_NAME"/>
<value class="com.ibi.wfrs.IBFSWFDescribe$BindingVar" isReqParm="false" value="amptest.fex"/>
</entry>
<entry>
<key _jt="string" value="SCRIPT_NAME"/>
<value class="com.ibi.wfrs.IBFSWFDescribe$BindingVar" isReqParm="false" value="/ibi_apps/rs"/>
</entry>
<entry>
<key _jt="string" value="IBIRS_args"/>
<value class="com.ibi.wfrs.IBFSWFDescribe$BindingVar" isReqParm="true" value="__null"/>
</entry>
<entry>
<key _jt="string" value="SAVE_PARMS"/>
<value class="com.ibi.wfrs.IBFSWFDescribe$BindingVar" isReqParm="false" value="TRUE"/>
</entry>
<entry>
<key _jt="string" value="XSL_NEWLINE_DELIM"/>
<value class="com.ibi.wfrs.IBFSWFDescribe$BindingVar" isReqParm="false" value="0xD;0xA;"/>
</entry>
<entry>
<key _jt="string" value="IBI_Webapp_Context_Default"/>
<value class="com.ibi.wfrs.IBFSWFDescribe$BindingVar" isReqParm="false" value="/ibi_apps"/>
</entry>
<entry>
<key _jt="string" value="IBIRS_service"/>
<value class="com.ibi.wfrs.IBFSWFDescribe$BindingVar" isReqParm="true" value="ibfs"/>
</entry>
<entry>
<key _jt="string" value="FOCHTMLURL"/>
<value class="com.ibi.wfrs.IBFSWFDescribe$BindingVar" isReqParm="false" value="/ibi_apps/ibi_html/S3_17207238601F"/>
</entry>
<entry>
<key _jt="string" value="SUBSYSTEM"/>
<value class="com.ibi.wfrs.IBFSWFDescribe$BindingVar" isReqParm="false" value="Self Service"/>
</entry>
<entry>
<key _jt="string" value="fromTool"/>
<value class="com.ibi.wfrs.IBFSWFDescribe$BindingVar" isReqParm="true" value="true"/>
</entry>
<entry>
<key _jt="string" value="SAVE_PARMRPT"/>
<value class="com.ibi.wfrs.IBFSWFDescribe$BindingVar" isReqParm="false" value="IBFS:/WFC/Repository/test/amptest.fex"/>
</entry>
<entry>
<key _jt="string" value="IBFS_displayName"/>
<value class="com.ibi.wfrs.IBFSWFDescribe$BindingVar" isReqParm="false" value="AMPTEST"/>
</entry>
<entry>
<key _jt="string" value="IBIRS_action"/>
<value class="com.ibi.wfrs.IBFSWFDescribe$BindingVar" isReqParm="true" value="describeFex"/>
</entry>
<entry>
<key _jt="string" value="トークン名"/>
<value class="com.ibi.wfrs.IBFSWFDescribe$BindingVar" isReqParm="true" value="トークン値"/>
</entry>
</bindingInfo>
<amperMap class="java.util.LinkedHashMap">
<entry>
<key _jt="string" value="FOCFOCEXEC"/>
<value aggType="" amperIdx="0" chainIdx="-1" class="com.ibi.wfrs.IBFSWFDescribe$AmperVar" format="" idxInChain="-1" inForm="false" isDefault="false" max="0.0" min="0.0" name="FOCFOCEXEC" noSelection="false" parent="" proc="" sortFields="" sortOrder="" validate="">
<type class="com.ibi.wfrs.IBFSAmperVarType" name="system"/>
<userDefValues _jt="array" itemsClass="string" size="0"/>
<defValues _jt="array" itemsClass="string" size="0"/>
<displayType class="com.ibi.wfrs.IBFSAmperDisplayType" name="prompt"/>
<values class="java.util.LinkedHashMap"/>
<parameters _jt="HashMap"/>
</value>
</entry>
<entry>
<key _jt="string" value="_PERSISTENT_GEO_UNIFIED_ROLE"/>
<value aggType="" amperIdx="1" chainIdx="-1" class="com.ibi.wfrs.IBFSWFDescribe$AmperVar" format="" idxInChain="-1" inForm="false" isDefault="false" max="0.0" min="0.0" name="_PERSISTENT_GEO_UNIFIED_ROLE" noSelection="false" parent="" proc="" sortFields="" sortOrder="" validate="">
<type class="com.ibi.wfrs.IBFSAmperVarType" name="global"/>
<userDefValues _jt="array" itemsClass="string" size="0"/>
<defValues _jt="array" itemsClass="string" size="0"/>
<displayType class="com.ibi.wfrs.IBFSAmperDisplayType" name="prompt"/>
<values class="java.util.LinkedHashMap"/>
<parameters _jt="HashMap"/>
</value>
</entry>
<entry>
<key _jt="string" value="_PERSISTENT_IBI_HOLDMAG_TARGET"/>
<value aggType="" amperIdx="2" chainIdx="-1" class="com.ibi.wfrs.IBFSWFDescribe$AmperVar" format="" idxInChain="-1" inForm="false" isDefault="false" max="0.0" min="0.0" name="_PERSISTENT_IBI_HOLDMAG_TARGET" noSelection="false" parent="" proc="" sortFields="" sortOrder="" validate="">
<type class="com.ibi.wfrs.IBFSAmperVarType" name="global"/>
<userDefValues _jt="array" itemsClass="string" size="0"/>
<defValues _jt="array" itemsClass="string" size="0"/>
<displayType class="com.ibi.wfrs.IBFSAmperDisplayType" name="prompt"/>
<values class="java.util.LinkedHashMap"/>
<parameters _jt="HashMap"/>
</value>
</entry>
<entry>
<key _jt="string" value="FOCEXURL"/>
<value aggType="" amperIdx="3" chainIdx="-1" class="com.ibi.wfrs.IBFSWFDescribe$AmperVar" format="" idxInChain="-1" inForm="false" isDefault="false" max="0.0" min="0.0" name="FOCEXURL" noSelection="false" parent="" proc="" sortFields="" sortOrder="" validate="">
<type class="com.ibi.wfrs.IBFSAmperVarType" name="set"/>
<userDefValues _jt="array" itemsClass="string" size="0"/>
<defValues _jt="array" itemsClass="string" size="0"/>
<displayType class="com.ibi.wfrs.IBFSAmperDisplayType" name="prompt"/>
<values class="java.util.LinkedHashMap"/>
<parameters _jt="HashMap"/>
</value>
</entry>
<entry>
<key _jt="string" value="FOCHTMLURL"/>
<value aggType="" amperIdx="4" chainIdx="-1" class="com.ibi.wfrs.IBFSWFDescribe$AmperVar" format="" idxInChain="-1" inForm="false" isDefault="false" max="0.0" min="0.0" name="FOCHTMLURL" noSelection="false" parent="" proc="" sortFields="" sortOrder="" validate="">
<type class="com.ibi.wfrs.IBFSAmperVarType" name="set"/>
<userDefValues _jt="array" itemsClass="string" size="0"/>
<defValues _jt="array" itemsClass="string" size="0"/>
<displayType class="com.ibi.wfrs.IBFSAmperDisplayType" name="prompt"/>
<values class="java.util.LinkedHashMap"/>
<parameters _jt="HashMap"/>
</value>
</entry>
<entry>
<key _jt="string" value="GOOGLEMAPSAPIKEY"/>
<value aggType="" amperIdx="5" chainIdx="-1" class="com.ibi.wfrs.IBFSWFDescribe$AmperVar" format="" idxInChain="-1" inForm="false" isDefault="false" max="0.0" min="0.0" name="GOOGLEMAPSAPIKEY" noSelection="false" parent="" proc="" sortFields="" sortOrder="" validate="">
<type class="com.ibi.wfrs.IBFSAmperVarType" name="set"/>
<userDefValues _jt="array" itemsClass="string" size="0"/>
<defValues _jt="array" itemsClass="string" size="0"/>
<displayType class="com.ibi.wfrs.IBFSAmperDisplayType" name="prompt"/>
<values class="java.util.LinkedHashMap"/>
<parameters _jt="HashMap"/>
</value>
</entry>
<entry>
<key _jt="string" value="WF_TITLE"/>
<value aggType="" amperIdx="6" chainIdx="-1" class="com.ibi.wfrs.IBFSWFDescribe$AmperVar" format="" idxInChain="-1" inForm="false" isDefault="false" max="0.0" min="0.0" name="WF_TITLE" noSelection="false" parent="" proc="" sortFields="" sortOrder="" validate="">
<type class="com.ibi.wfrs.IBFSAmperVarType" name="set"/>
<userDefValues _jt="array" itemsClass="string" size="0"/>
<defValues _jt="array" itemsClass="string" size="0"/>
<displayType class="com.ibi.wfrs.IBFSAmperDisplayType" name="prompt"/>
<values class="java.util.LinkedHashMap"/>
<parameters _jt="HashMap"/>
</value>
</entry>
<entry>
<key _jt="string" value="IBFS_FILENAME"/>
<value aggType="" amperIdx="7" chainIdx="-1" class="com.ibi.wfrs.IBFSWFDescribe$AmperVar" format="" idxInChain="-1" inForm="false" isDefault="false" max="0.0" min="0.0" name="IBFS_FILENAME" noSelection="false" parent="" proc="" sortFields="" sortOrder="" validate="">
<type class="com.ibi.wfrs.IBFSAmperVarType" name="set"/>
<userDefValues _jt="array" itemsClass="string" size="0"/>
<defValues _jt="array" itemsClass="string" size="0"/>
<displayType class="com.ibi.wfrs.IBFSAmperDisplayType" name="prompt"/>
<values class="java.util.LinkedHashMap"/>
<parameters _jt="HashMap"/>
</value>
</entry>
<entry>
<key _jt="string" value="IBFS_OlapFilePath"/>
<value aggType="" amperIdx="8" chainIdx="-1" class="com.ibi.wfrs.IBFSWFDescribe$AmperVar" format="" idxInChain="-1" inForm="false" isDefault="false" max="0.0" min="0.0" name="IBFS_OlapFilePath" noSelection="false" parent="" proc="" sortFields="" sortOrder="" validate="">
<type class="com.ibi.wfrs.IBFSAmperVarType" name="set"/>
<userDefValues _jt="array" itemsClass="string" size="0"/>
<defValues _jt="array" itemsClass="string" size="0"/>
<displayType class="com.ibi.wfrs.IBFSAmperDisplayType" name="prompt"/>
<values class="java.util.LinkedHashMap"/>
<parameters _jt="HashMap"/>
</value>
</entry>
<entry>
<key _jt="string" value="MR_FULL_FEXNAME"/>
<value aggType="" amperIdx="9" chainIdx="-1" class="com.ibi.wfrs.IBFSWFDescribe$AmperVar" format="" idxInChain="-1" inForm="false" isDefault="false" max="0.0" min="0.0" name="MR_FULL_FEXNAME" noSelection="false" parent="" proc="" sortFields="" sortOrder="" validate="">
<type class="com.ibi.wfrs.IBFSAmperVarType" name="set"/>
<userDefValues _jt="array" itemsClass="string" size="0"/>
<defValues _jt="array" itemsClass="string" size="0"/>
<displayType class="com.ibi.wfrs.IBFSAmperDisplayType" name="prompt"/>
<values class="java.util.LinkedHashMap"/>
<parameters _jt="HashMap"/>
</value>
</entry>
<entry>
<key _jt="string" value="MR_FULL_PATH"/>
<value aggType="" amperIdx="10" chainIdx="-1" class="com.ibi.wfrs.IBFSWFDescribe$AmperVar" format="" idxInChain="-1" inForm="false" isDefault="false" max="0.0" min="0.0" name="MR_FULL_PATH" noSelection="false" parent="" proc="" sortFields="" sortOrder="" validate="">
<type class="com.ibi.wfrs.IBFSAmperVarType" name="set"/>
<userDefValues _jt="array" itemsClass="string" size="0"/>
<defValues _jt="array" itemsClass="string" size="0"/>
<displayType class="com.ibi.wfrs.IBFSAmperDisplayType" name="prompt"/>
<values class="java.util.LinkedHashMap"/>
<parameters _jt="HashMap"/>
</value>
</entry>
<entry>
<key _jt="string" value="FOCREL"/>
<value aggType="" amperIdx="11" chainIdx="-1" class="com.ibi.wfrs.IBFSWFDescribe$AmperVar" format="" idxInChain="-1" inForm="false" isDefault="false" max="0.0" min="0.0" name="FOCREL" noSelection="false" parent="" proc="" sortFields="" sortOrder="" validate="">
<type class="com.ibi.wfrs.IBFSAmperVarType" name="system"/>
<userDefValues _jt="array" itemsClass="string" size="0"/>
<defValues _jt="array" itemsClass="string" size="0"/>
<displayType class="com.ibi.wfrs.IBFSAmperDisplayType" name="prompt"/>
<values class="java.util.LinkedHashMap"/>
<parameters _jt="HashMap"/>
</value>
</entry>
<entry>
<key _jt="string" value="EXCELSERVURL"/>
<value aggType="" amperIdx="12" chainIdx="-1" class="com.ibi.wfrs.IBFSWFDescribe$AmperVar" format="" idxInChain="-1" inForm="false" isDefault="false" max="0.0" min="0.0" name="EXCELSERVURL" noSelection="false" parent="" proc="" sortFields="" sortOrder="" validate="">
<type class="com.ibi.wfrs.IBFSAmperVarType" name="set"/>
<userDefValues _jt="array" itemsClass="string" size="0"/>
<defValues _jt="array" itemsClass="string" size="0"/>
<displayType class="com.ibi.wfrs.IBFSAmperDisplayType" name="prompt"/>
<values class="java.util.LinkedHashMap"/>
<parameters _jt="HashMap"/>
</value>
</entry>
<entry>
<key _jt="string" value="DEF_1"/>
<value aggType="" amperIdx="13" chainIdx="-1" class="com.ibi.wfrs.IBFSWFDescribe$AmperVar" format="" idxInChain="-1" inForm="true" isDefault="true" max="0.0" min="0.0" name="DEF_1" noSelection="false" parent="" proc="" sortFields="" sortOrder="" strDef="AAA" validate="">
<type class="com.ibi.wfrs.IBFSAmperVarType" name="defaultType"/>
<userDefValues _jt="array" itemsClass="string" size="1">
<item _jt="string" index="0" value="AAA"/>
</userDefValues>
<defValues _jt="array" itemsClass="string" size="1">
<item _jt="string" index="0" value="AAA"/>
</defValues>
<displayType class="com.ibi.wfrs.IBFSAmperDisplayType" name="prompt"/>
<values class="java.util.LinkedHashMap"/>
<parameters _jt="HashMap"/>
</value>
</entry>
<entry>
<key _jt="string" value="DEF_2"/>
<value aggType="" amperIdx="14" chainIdx="-1" class="com.ibi.wfrs.IBFSWFDescribe$AmperVar" format="" idxInChain="-1" inForm="true" isDefault="true" max="0.0" min="0.0" name="DEF_2" noSelection="false" parent="" proc="" sortFields="" sortOrder="" strDef="BBB" validate="">
<type class="com.ibi.wfrs.IBFSAmperVarType" name="defaultType"/>
<userDefValues _jt="array" itemsClass="string" size="1">
<item _jt="string" index="0" value="BBB"/>
</userDefValues>
<defValues _jt="array" itemsClass="string" size="1">
<item _jt="string" index="0" value="BBB"/>
</defValues>
<displayType class="com.ibi.wfrs.IBFSAmperDisplayType" name="prompt"/>
<values class="java.util.LinkedHashMap"/>
<parameters _jt="HashMap"/>
</value>
</entry>
<entry>
<key _jt="string" value="UND_1"/>
<value aggType="" amperIdx="15" chainIdx="-1" class="com.ibi.wfrs.IBFSWFDescribe$AmperVar" format="" idxInChain="-1" inForm="true" isDefault="false" max="0.0" min="0.0" name="UND_1" noSelection="false" parent="" proc="" sortFields="" sortOrder="" validate="">
<type class="com.ibi.wfrs.IBFSAmperVarType" name="unresolved"/>
<userDefValues _jt="array" itemsClass="string" size="0"/>
<defValues _jt="array" itemsClass="string" size="0"/>
<displayType class="com.ibi.wfrs.IBFSAmperDisplayType" name="prompt"/>
<values class="java.util.LinkedHashMap"/>
<parameters _jt="HashMap"/>
</value>
</entry>
<entry>
<key _jt="string" value="UND_2"/>
<value aggType="" amperIdx="16" chainIdx="-1" class="com.ibi.wfrs.IBFSWFDescribe$AmperVar" format="A8" idxInChain="-1" inForm="true" isDefault="false" max="0.0" min="0.0" name="UND_2" noSelection="false" parent="" proc="" sortFields="" sortOrder="" validate="">
<type class="com.ibi.wfrs.IBFSAmperVarType" name="unresolved"/>
<userDefValues _jt="array" itemsClass="string" size="0"/>
<defValues _jt="array" itemsClass="string" size="0"/>
<displayType class="com.ibi.wfrs.IBFSAmperDisplayType" name="prompt"/>
<values class="java.util.LinkedHashMap"/>
<parameters _jt="HashMap"/>
</value>
</entry>
<entry>
<key _jt="string" value="UND_3"/>
<value aggType="" amperIdx="17" chainIdx="-1" class="com.ibi.wfrs.IBFSWFDescribe$AmperVar" description="テキスト" format="A8" idxInChain="-1" inForm="true" isDefault="false" max="0.0" min="0.0" name="UND_3" noSelection="false" parent="" proc="" sortFields="" sortOrder="" validate="">
<type class="com.ibi.wfrs.IBFSAmperVarType" name="unresolved"/>
<userDefValues _jt="array" itemsClass="string" size="0"/>
<defValues _jt="array" itemsClass="string" size="0"/>
<displayType class="com.ibi.wfrs.IBFSAmperDisplayType" name="prompt"/>
<values class="java.util.LinkedHashMap"/>
<parameters _jt="HashMap"/>
</value>
</entry>
<entry>
<key _jt="string" value="UND_4"/>
<value aggType="" amperIdx="18" chainIdx="-1" class="com.ibi.wfrs.IBFSWFDescribe$AmperVar" format="" idxInChain="-1" inForm="true" isDefault="false" max="0.0" min="0.0" name="UND_4" noSelection="false" operation="" parent="" proc="" sortFields="" sortOrder="" validate="">
<type class="com.ibi.wfrs.IBFSAmperVarType" name="unresolved"/>
<userDefValues _jt="array" itemsClass="string" size="0"/>
<defValues _jt="array" itemsClass="string" size="0"/>
<displayType class="com.ibi.wfrs.IBFSAmperDisplayType" name="staticType"/>
<values class="java.util.LinkedHashMap">
<entry>
<key _jt="string" value="SEL1"/>
<value _jt="string" value="SEL1"/>
</entry>
<entry>
<key _jt="string" value="SEL2.SEL3"/>
<value _jt="string" value="SEL2.SEL3"/>
</entry>
</values>
<parameters _jt="HashMap"/>
</value>
</entry>
</amperMap>
<tableChainList _jt="ArrayList" size="0"/>
<globalRefreshPaths _jt="HashMap"/>
</rootObject>
</ibfsrpc>
レスポンスXMLを読み解く
ibfsrpc > rootObject
全体情報
<rootObject
class="com.ibi.wfrs.IBFSWFDescribe"
formAction="/ibi_apps/rs"
isSavedParam="false"
nrOfDefaultVars="2"
nrOfPromptVars="6"
>
- isSavedParam: 保存されたパラメータの有無
- nrOfDefaultVars: デフォルト値が設定された変数
- nrOfPromptVars: プロンプトすべき変数の数
ibfsrpc > rootObject > bindingInfo
対象としたfexの情報
使えそうな情報を抜粋
<bindingInfo _jt="HashMap">
<entry>
<key _jt="string" value="IBIF_describe_null"/>
<value
class="com.ibi.wfrs.IBFSWFDescribe$BindingVar" isReqParm="false"
value="_FOC_NULL"
/>
</entry>
<entry>
<key _jt="string" value="IBFS_description"/>
<value class="com.ibi.wfrs.IBFSWFDescribe$BindingVar" isReqParm="false"
value="AMPTEST"
/>
</entry>
<entry>
<key _jt="string" value="IBIRS_path"/>
<value class="com.ibi.wfrs.IBFSWFDescribe$BindingVar" isReqParm="true"
value="IBFS%3A%2FWFC%2FRepository%2Ftest%2Famptest.fex"
/>
</entry>
<entry>
<key _jt="string" value="IBIAPP_app"/>
<value class="com.ibi.wfrs.IBFSWFDescribe$BindingVar" isReqParm="false"
value="test"/>
</entry>
<entry>
<key _jt="string" value="IBFS_name"/>
<value class="com.ibi.wfrs.IBFSWFDescribe$BindingVar" isReqParm="false"
value="amptest.fex"
/>
</entry>
<entry>
<key _jt="string" value="IBFS_displayName"/>
<value class="com.ibi.wfrs.IBFSWFDescribe$BindingVar" isReqParm="false"
value="AMPTEST"
/>
</entry>
</bindingInfo>
以下の値を取得できます。入力フォームのタイトル表示や実行アクションに必要になります。
- IBIF_describe_null: 省略時に設定すべき値
- IBFS_description: アイテムの詳細
- IBIRS_path: アイテムのフルパス
- IBIAPP_app: APPパス
- IBFS_name: アイテム名
- IBFS_displayName: アイテムの表示名
ibfsrpc > rootObject > amperMap
プロシジャで利用する変数情報
<amperMap class="java.util.LinkedHashMap">
<entry>
<key _jt="string" value="FOCFOCEXEC"/>
<value aggType="" amperIdx="0" chainIdx="-1" class="com.ibi.wfrs.IBFSWFDescribe$AmperVar" format="" idxInChain="-1" inForm="false" isDefault="false" max="0.0" min="0.0" name="FOCFOCEXEC" noSelection="false" parent="" proc="" sortFields="" sortOrder="" validate="">
<type class="com.ibi.wfrs.IBFSAmperVarType" name="system"/>
<userDefValues _jt="array" itemsClass="string" size="0"/>
<defValues _jt="array" itemsClass="string" size="0"/>
<displayType class="com.ibi.wfrs.IBFSAmperDisplayType" name="prompt"/>
<values class="java.util.LinkedHashMap"/>
<parameters _jt="HashMap"/>
</value>
</entry>
<entry>
<key _jt="string" value="FOCEXURL"/>
<value aggType="" amperIdx="3" chainIdx="-1" class="com.ibi.wfrs.IBFSWFDescribe$AmperVar" format="" idxInChain="-1" inForm="false" isDefault="false" max="0.0" min="0.0" name="FOCEXURL" noSelection="false" parent="" proc="" sortFields="" sortOrder="" validate="">
<type class="com.ibi.wfrs.IBFSAmperVarType" name="set"/>
<userDefValues _jt="array" itemsClass="string" size="0"/>
<defValues _jt="array" itemsClass="string" size="0"/>
<displayType class="com.ibi.wfrs.IBFSAmperDisplayType" name="prompt"/>
<values class="java.util.LinkedHashMap"/>
<parameters _jt="HashMap"/>
</value>
</entry>
<entry>
<key _jt="string" value="WF_TITLE"/>
<value aggType="" amperIdx="6" chainIdx="-1" class="com.ibi.wfrs.IBFSWFDescribe$AmperVar" format="" idxInChain="-1" inForm="false" isDefault="false" max="0.0" min="0.0" name="WF_TITLE" noSelection="false" parent="" proc="" sortFields="" sortOrder="" validate="">
<type class="com.ibi.wfrs.IBFSAmperVarType" name="set"/>
<userDefValues _jt="array" itemsClass="string" size="0"/>
<defValues _jt="array" itemsClass="string" size="0"/>
<displayType class="com.ibi.wfrs.IBFSAmperDisplayType" name="prompt"/>
<values class="java.util.LinkedHashMap"/>
<parameters _jt="HashMap"/>
</value>
</entry>
<entry>
<key _jt="string" value="FOCREL"/>
<value aggType="" amperIdx="11" chainIdx="-1" class="com.ibi.wfrs.IBFSWFDescribe$AmperVar" format="" idxInChain="-1" inForm="false" isDefault="false" max="0.0" min="0.0" name="FOCREL" noSelection="false" parent="" proc="" sortFields="" sortOrder="" validate="">
<type class="com.ibi.wfrs.IBFSAmperVarType" name="system"/>
<userDefValues _jt="array" itemsClass="string" size="0"/>
<defValues _jt="array" itemsClass="string" size="0"/>
<displayType class="com.ibi.wfrs.IBFSAmperDisplayType" name="prompt"/>
<values class="java.util.LinkedHashMap"/>
<parameters _jt="HashMap"/>
</value>
</entry>
<entry>
<key _jt="string" value="DEF_1"/>
<value aggType="" amperIdx="13" chainIdx="-1" class="com.ibi.wfrs.IBFSWFDescribe$AmperVar" format="" idxInChain="-1" inForm="true" isDefault="true" max="0.0" min="0.0" name="DEF_1" noSelection="false" parent="" proc="" sortFields="" sortOrder="" strDef="AAA" validate="">
<type class="com.ibi.wfrs.IBFSAmperVarType" name="defaultType"/>
<userDefValues _jt="array" itemsClass="string" size="1">
<item _jt="string" index="0" value="AAA"/>
</userDefValues>
<defValues _jt="array" itemsClass="string" size="1">
<item _jt="string" index="0" value="AAA"/>
</defValues>
<displayType class="com.ibi.wfrs.IBFSAmperDisplayType" name="prompt"/>
<values class="java.util.LinkedHashMap"/>
<parameters _jt="HashMap"/>
</value>
</entry>
<entry>
<key _jt="string" value="DEF_2"/>
<value aggType="" amperIdx="14" chainIdx="-1" class="com.ibi.wfrs.IBFSWFDescribe$AmperVar" format="" idxInChain="-1" inForm="true" isDefault="true" max="0.0" min="0.0" name="DEF_2" noSelection="false" parent="" proc="" sortFields="" sortOrder="" strDef="BBB" validate="">
<type class="com.ibi.wfrs.IBFSAmperVarType" name="defaultType"/>
<userDefValues _jt="array" itemsClass="string" size="1">
<item _jt="string" index="0" value="BBB"/>
</userDefValues>
<defValues _jt="array" itemsClass="string" size="1">
<item _jt="string" index="0" value="BBB"/>
</defValues>
<displayType class="com.ibi.wfrs.IBFSAmperDisplayType" name="prompt"/>
<values class="java.util.LinkedHashMap"/>
<parameters _jt="HashMap"/>
</value>
</entry>
<entry>
<key _jt="string" value="UND_1"/>
<value aggType="" amperIdx="15" chainIdx="-1" class="com.ibi.wfrs.IBFSWFDescribe$AmperVar" format="" idxInChain="-1" inForm="true" isDefault="false" max="0.0" min="0.0" name="UND_1" noSelection="false" parent="" proc="" sortFields="" sortOrder="" validate="">
<type class="com.ibi.wfrs.IBFSAmperVarType" name="unresolved"/>
<userDefValues _jt="array" itemsClass="string" size="0"/>
<defValues _jt="array" itemsClass="string" size="0"/>
<displayType class="com.ibi.wfrs.IBFSAmperDisplayType" name="prompt"/>
<values class="java.util.LinkedHashMap"/>
<parameters _jt="HashMap"/>
</value>
</entry>
<entry>
<key _jt="string" value="UND_2"/>
<value aggType="" amperIdx="16" chainIdx="-1" class="com.ibi.wfrs.IBFSWFDescribe$AmperVar" format="A8" idxInChain="-1" inForm="true" isDefault="false" max="0.0" min="0.0" name="UND_2" noSelection="false" parent="" proc="" sortFields="" sortOrder="" validate="">
<type class="com.ibi.wfrs.IBFSAmperVarType" name="unresolved"/>
<userDefValues _jt="array" itemsClass="string" size="0"/>
<defValues _jt="array" itemsClass="string" size="0"/>
<displayType class="com.ibi.wfrs.IBFSAmperDisplayType" name="prompt"/>
<values class="java.util.LinkedHashMap"/>
<parameters _jt="HashMap"/>
</value>
</entry>
<entry>
<key _jt="string" value="UND_3"/>
<value aggType="" amperIdx="17" chainIdx="-1" class="com.ibi.wfrs.IBFSWFDescribe$AmperVar" description="テキスト" format="A8" idxInChain="-1" inForm="true" isDefault="false" max="0.0" min="0.0" name="UND_3" noSelection="false" parent="" proc="" sortFields="" sortOrder="" validate="">
<type class="com.ibi.wfrs.IBFSAmperVarType" name="unresolved"/>
<userDefValues _jt="array" itemsClass="string" size="0"/>
<defValues _jt="array" itemsClass="string" size="0"/>
<displayType class="com.ibi.wfrs.IBFSAmperDisplayType" name="prompt"/>
<values class="java.util.LinkedHashMap"/>
<parameters _jt="HashMap"/>
</value>
</entry>
<entry>
<key _jt="string" value="UND_4"/>
<value aggType="" amperIdx="18" chainIdx="-1" class="com.ibi.wfrs.IBFSWFDescribe$AmperVar" format="" idxInChain="-1" inForm="true" isDefault="false" max="0.0" min="0.0" name="UND_4" noSelection="false" operation="" parent="" proc="" sortFields="" sortOrder="" validate="">
<type class="com.ibi.wfrs.IBFSAmperVarType" name="unresolved"/>
<userDefValues _jt="array" itemsClass="string" size="0"/>
<defValues _jt="array" itemsClass="string" size="0"/>
<displayType class="com.ibi.wfrs.IBFSAmperDisplayType" name="staticType"/>
<values class="java.util.LinkedHashMap">
<entry>
<key _jt="string" value="SEL1"/>
<value _jt="string" value="SEL1"/>
</entry>
<entry>
<key _jt="string" value="SEL2.SEL3"/>
<value _jt="string" value="SEL2.SEL3"/>
</entry>
</values>
<parameters _jt="HashMap"/>
</value>
</entry>
</amperMap>
-
amperMap > entry > key
の"value"属性値が変数名 -
amperMap > entry > value
の"type"属性値が変数の種類- system: システム変数
- set: 通常の変数
- defaultType: DEFAULTで初期値が設定されている変数
- unresolved: 宣言されていないが利用されている変数
-
amperMap > entry > value
の"format"属性値が変数のフォーマット(UND_2に値あり) -
amperMap > entry > value
の"description"属性値が変数の表示名(UND_3に値あり) -
amperMap > entry > value > values
の<entry>に選択リストの値の表示名(UND_4に値あり)) -
amperMap > entry > userDefValues > item
の"value"属性値が初期値(DEF_1,DEF_2に値あり)
これらの値を利用して変数入力フォームを作成します。
応用
- 変数名に命名規則を付けて、表示順を制御する
- 変数名に命名規則を付けて、フォーム内のどのフィールドセットに配置するか制御する(&FS1_variableName)
- 決められた変数名に対応する選択リストやラジオボタン・チェックボックスを適用する
カスタム入力フォームの例
実行ボタンを押すと、変数をパラメータにしてレポートを実行します。
せっかくカスタムなのでここからデザインを頑張りましょう!
サンプルコード
XMLの読み方と使い方の参考になれば幸いです。
サンプル
WebFOCUS RESTサービスモジュールの一部
/**
* Fetches the description of a FEX file to determine if variable input is required.
* @param path The full path of the FEX file.
* @returns Parsed response indicating variable input requirements.
*/
public async describeFex(path: string): Promise<{ requiresInput: boolean; variables: any[] }> {
try {
const params = new URLSearchParams({
IBIRS_action: 'describeFex',
IBIRS_service: WebFocusService.IBIRS_SERVICE,
IBIRS_path: path,
});
const url = `${this.baseUrl}?${params.toString()}`;
const response = await fetch(url);
if (!response.ok) {
throw new Error(`describeFex failed with status: ${response.status} ${response.statusText}`);
}
const xmlText = await response.text();
const parser = new DOMParser();
const xmlDoc = parser.parseFromString(xmlText, 'text/xml');
const amperMap = xmlDoc.querySelector('amperMap');
const variables: any[] = [];
let requiresInput = false;
if (amperMap) {
amperMap.querySelectorAll('entry').forEach(entry => {
const key = entry.querySelector('key')?.getAttribute('value');
const value = entry.querySelector('value');
const type = value?.querySelector('type')?.getAttribute('name');
if (type === 'defaultType' || type === 'unresolved') {
requiresInput = true;
const variable = {
name: key,
type,
format: value?.getAttribute('format') || '',
defaultValue: value?.querySelector('userDefValues > item')?.getAttribute('value') || '',
options: Array.from(value?.querySelectorAll('values > entry') || []).map(option => ({
key: option.querySelector('key')?.getAttribute('value'),
value: option.querySelector('value')?.getAttribute('value'),
})),
};
variables.push(variable);
}
});
}
return { requiresInput, variables };
} catch (error) {
console.error('describeFex error:', error);
throw error;
}
}
フォームを表示するスクリプト
import React, { useState } from 'react';
import styles from './VariableInputForm.module.css';
interface Variable {
name: string;
type: string;
format: string;
defaultValue: string;
options: { key: string; value: string }[];
}
interface VariableInputFormProps {
variables: Variable[];
itemName: string; // クリックしたアイテムの名前を受け取る
onSubmit: (values: Record<string, string>) => void;
onCancel: () => void;
}
const VariableInputForm: React.FC<VariableInputFormProps> = ({ variables, itemName, onSubmit, onCancel }) => {
const [formValues, setFormValues] = useState<Record<string, string>>(
variables.reduce((acc, variable) => {
acc[variable.name] = variable.defaultValue || '';
return acc;
}, {} as Record<string, string>)
);
const handleChange = (name: string, value: string) => {
setFormValues({ ...formValues, [name]: value });
};
const handleSubmit = (event: React.FormEvent) => {
event.preventDefault();
onSubmit(formValues);
};
return (
<div className={styles.formContainer}>
{/* クリックしたアイテムの名前を表示 */}
<div className={styles.itemName}>{itemName}</div>
<form onSubmit={handleSubmit} className={styles.form}>
<h2>変数入力フォーム</h2>
{variables.map((variable) => (
<div key={variable.name} className={styles.formGroup}>
<label htmlFor={variable.name}>{variable.name}</label>
{variable.options.length > 0 ? (
<select
id={variable.name}
value={formValues[variable.name]}
onChange={(e) => handleChange(variable.name, e.target.value)}
>
{variable.options.map((option) => (
<option key={option.key} value={option.key}>
{option.value}
</option>
))}
</select>
) : (
<input
id={variable.name}
type="text"
value={formValues[variable.name]}
onChange={(e) => handleChange(variable.name, e.target.value)}
maxLength={variable.format === 'A8' ? 8 : undefined}
/>
)}
</div>
))}
<div className={styles.buttonGroup}>
<button type="submit">実行</button>
<button type="button" onClick={onCancel}>キャンセル</button>
</div>
</form>
</div>
);
};
export default VariableInputForm;
まとめ
RESTful APIのdescribeFexを利用すると変数入力フォームを構成するために必要な情報を全て得られます。
この方法を使えば、変数を利用するプロシジャを作成するだけでカスタムした入力フォームを作成できます。
レポート毎にHTMLを作成する必要がなくなるので、新規プログラム作成がとても捗ります。
是非とも利用しましょう!
Discussion