NB. action_to_POST_method_jconsole.ijs
NB. making_of_app_def_file_jconsole_2023_08_01_english
NB. making of definition file for adding web GUI to your J function
NB. (c)2023 Yuji Suda


NB. action_to_POST_method_part1_jconsole start

NB. クライアントからのフォーム入力送信による POST method に応答するHTTPレスポンスメッセージを用意する
NB. (c)2023 Yuji Suda

NB. クライアントからのフォーム送信データに対する処理は大きく３つからなる 

NB. （１）最初にクライアントからの送信データを抽出する
NB. （２）そのデータを使って所望の J console 関数を実行し結果を得る
NB. （３）その結果をクライアントへ送信するための応答 HTTP メッセージを作成する

NB. この時、GET method に応答して送信したものと同じ HTMLフォームを含めて作成し
NB. クライントが継続して同じフォームを利用出来るようにする
NB. フォーム部品の初期値は、受信したクライアントの値に設定しなおす。
NB. 計算結果をフォーム部品に反映させる場合もある。

NB. 受信したメッセージからフォーム部品の値を抽出する関数
NB. ---------------------------------------------------------------------------------
extract_POSTed_values =: 3 : 0
NB. この関数はserver_core_jconsole.ijsの中で呼ばれるので関数名を変更しないこと

NB.print 'フォーム部品から抽出した部品IDとその値の一覧'
print 'List of Child Form Control and its posted value'

NB. 全てのアプリケーションに共通のサーバー継続・停止リクエスト用ラジオボタン radio99
NB. が設置されており、それぞれのVALUEを抽出する

NB. extract_entryID_value_and_display 関数は support_tools_jconsole.ijsで定義されている

NB. action_to_POST_method_part_1_jconsole end
TEXTBOX_90_VALUE =: extract_entryID_value_and_display 'textbox90'
TEXTBOX_91_VALUE =: extract_entryID_value_and_display 'textbox91'
TEXTBOX_92_VALUE =: extract_entryID_value_and_display 'textbox92'
CHECKBOX_00_VALUE =: extract_entryID_value_and_display 'checkbox00'
DROPDOWN_00_VALUE =: extract_entryID_value_and_display 'dropdown00'
TEXTBOX_00_VALUE =: extract_entryID_value_and_display 'textbox00'
TEXTBOX_01_VALUE =: extract_entryID_value_and_display 'textbox01'
TEXTBOX_02_VALUE =: extract_entryID_value_and_display 'textbox02'
CHECKBOX_10_VALUE =: extract_entryID_value_and_display 'checkbox10'
DROPDOWN_10_VALUE =: extract_entryID_value_and_display 'dropdown10'
TEXTBOX_10_VALUE =: extract_entryID_value_and_display 'textbox10'
TEXTBOX_11_VALUE =: extract_entryID_value_and_display 'textbox11'
TEXTBOX_12_VALUE =: extract_entryID_value_and_display 'textbox12'
CHECKBOX_20_VALUE =: extract_entryID_value_and_display 'checkbox20'
DROPDOWN_20_VALUE =: extract_entryID_value_and_display 'dropdown20'
TEXTBOX_20_VALUE =: extract_entryID_value_and_display 'textbox20'
TEXTBOX_21_VALUE =: extract_entryID_value_and_display 'textbox21'
TEXTBOX_22_VALUE =: extract_entryID_value_and_display 'textbox22'
CHECKBOX_30_VALUE =: extract_entryID_value_and_display 'checkbox30'
DROPDOWN_30_VALUE =: extract_entryID_value_and_display 'dropdown30'
TEXTBOX_30_VALUE =: extract_entryID_value_and_display 'textbox30'
TEXTBOX_31_VALUE =: extract_entryID_value_and_display 'textbox31'
TEXTBOX_32_VALUE =: extract_entryID_value_and_display 'textbox32'
TEXTBOX_33_VALUE =: extract_entryID_value_and_display 'textbox33'
CHECKBOX_40_VALUE =: extract_entryID_value_and_display 'checkbox40'
DROPDOWN_40_VALUE =: extract_entryID_value_and_display 'dropdown40'
TEXTBOX_40_VALUE =: extract_entryID_value_and_display 'textbox40'
TEXTBOX_41_VALUE =: extract_entryID_value_and_display 'textbox41'
CHECKBOX_50_VALUE =: extract_entryID_value_and_display 'checkbox50'
DROPDOWN_50_VALUE =: extract_entryID_value_and_display 'dropdown50'
TEXTBOX_50_VALUE =: extract_entryID_value_and_display 'textbox50'
TEXTBOX_51_VALUE =: extract_entryID_value_and_display 'textbox51'
CHECKBOX_60_VALUE =: extract_entryID_value_and_display 'checkbox60'
DROPDOWN_60_VALUE =: extract_entryID_value_and_display 'dropdown60'
TEXTBOX_60_VALUE =: extract_entryID_value_and_display 'textbox60'
TEXTBOX_61_VALUE =: extract_entryID_value_and_display 'textbox61'
TEXTBOX_62_VALUE =: extract_entryID_value_and_display 'textbox62'
TEXTBOX_63_VALUE =: extract_entryID_value_and_display 'textbox63'
TEXTBOX_64_VALUE =: extract_entryID_value_and_display 'textbox64'
TEXTBOX_65_VALUE =: extract_entryID_value_and_display 'textbox65'
TEXTBOX_66_VALUE =: extract_entryID_value_and_display 'textbox66'
CHECKBOX_70_VALUE =: extract_entryID_value_and_display 'checkbox70'
DROPDOWN_70_VALUE =: extract_entryID_value_and_display 'dropdown70'
TEXTBOX_70_VALUE =: extract_entryID_value_and_display 'textbox70'
TEXTBOX_71_VALUE =: extract_entryID_value_and_display 'textbox71'
TEXTBOX_72_VALUE =: extract_entryID_value_and_display 'textbox72'
TEXTBOX_73_VALUE =: extract_entryID_value_and_display 'textbox73'
TEXTBOX_74_VALUE =: extract_entryID_value_and_display 'textbox74'
TEXTBOX_75_VALUE =: extract_entryID_value_and_display 'textbox75'
TEXTBOX_76_VALUE =: extract_entryID_value_and_display 'textbox76'
TEXTBOX_77_VALUE =: extract_entryID_value_and_display 'textbox77'
CHECKBOX_80_VALUE =: extract_entryID_value_and_display 'checkbox80'
DROPDOWN_80_VALUE =: extract_entryID_value_and_display 'dropdown80'
TEXTBOX_80_VALUE =: extract_entryID_value_and_display 'textbox80'
TEXTBOX_81_VALUE =: extract_entryID_value_and_display 'textbox81'
TEXTBOX_82_VALUE =: extract_entryID_value_and_display 'textbox82'
TEXTBOX_83_VALUE =: extract_entryID_value_and_display 'textbox83'
TEXTBOX_84_VALUE =: extract_entryID_value_and_display 'textbox84'
TEXTBOX_85_VALUE =: extract_entryID_value_and_display 'textbox85'
TEXTBOX_86_VALUE =: extract_entryID_value_and_display 'textbox86'
TEXTAREA_00_VALUE =: extract_entryID_value_and_display 'textarea00'
TEXTAREA_01_VALUE =: extract_entryID_value_and_display 'textarea01'

NB. action_to_POST_method_part_2__jconsole start

RADIO_99_VALUE    =: extract_entryID_value_and_display 'radio99'

NB. print 'フォーム部品から抽出した部品IDと値の一覧の終わり'
print 'End of Child Form Control and its posted value'

)

NB. 抽出した VALUE を使って所望の jconsole 関数を実行する
NB. ---------------------------------------------------------------------------------
execute_your_job =: 3 : 0

initialize_response_image_bmp 0  NB. response_image.bmp must be initialized as 03x03_Orange.bmp
NB. in YOUR_JOB function user can revise response_image.bmp according to its result...

NB.print '設計ファイルで定義された YOUR_JOB を実行して戻り値ストリングを設定します。'
print 'execute YOUR_JOB defined in app plan file and assign return string'
RETURN_MSG =: YOUR_JOB 0 
1
NB. end of POSTed data processing
)

NB. 結果をクライアントへ返す HTTP レスポンスメッセージを作成する
NB. ---------------------------------------------------------------------------------
prepare_http_response_message_to_POST_method =: 3 : 0

http_response_status_and_header_field =. prepare_http_response_status_and_header_field 0

NB. HTTPのボディをhtml form documentとして用意する

NB. MSG_FROM_SERVERには実行結果終了時に定義された RETURN_MSGを代入する。

MSG_FROM_SERVER =: RETURN_MSG

define_html_code_for_controls_based_on_plan_ijs 0

html_form_doc =. make_html_form_doc 0

NB. 完成した html_docのバイト数を数える
byteCount =. $ html_form_doc

NB. クライントへ送信するレスポンスhttpメッセージを完成させる
NB. HTTPプロトコル上、html_docの前に空行が必要
http_response_status_and_header_field, (":byteCount), CRLF, CRLF, html_form_doc
)

NB. End of file

NB. action_to_POST_method_part_2__jconsole end
monitor_entry_ID_values =: 3 : 0
a_collection =. 'form control values submitted from client is as follows', CRLF
a_collection =. a_collection, 'TEXTBOX_90_VALUE  = ', TEXTBOX_90_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_91_VALUE  = ', TEXTBOX_91_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_92_VALUE  = ', TEXTBOX_92_VALUE, CRLF
a_collection =. a_collection, 'CHECKBOX_00_VALUE  = ', CHECKBOX_00_VALUE, CRLF
a_collection =. a_collection, 'DROPDOWN_00_VALUE  = ', DROPDOWN_00_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_00_VALUE  = ', TEXTBOX_00_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_01_VALUE  = ', TEXTBOX_01_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_02_VALUE  = ', TEXTBOX_02_VALUE, CRLF
a_collection =. a_collection, 'CHECKBOX_10_VALUE  = ', CHECKBOX_10_VALUE, CRLF
a_collection =. a_collection, 'DROPDOWN_10_VALUE  = ', DROPDOWN_10_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_10_VALUE  = ', TEXTBOX_10_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_11_VALUE  = ', TEXTBOX_11_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_12_VALUE  = ', TEXTBOX_12_VALUE, CRLF
a_collection =. a_collection, 'CHECKBOX_20_VALUE  = ', CHECKBOX_20_VALUE, CRLF
a_collection =. a_collection, 'DROPDOWN_20_VALUE  = ', DROPDOWN_20_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_20_VALUE  = ', TEXTBOX_20_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_21_VALUE  = ', TEXTBOX_21_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_22_VALUE  = ', TEXTBOX_22_VALUE, CRLF
a_collection =. a_collection, 'CHECKBOX_30_VALUE  = ', CHECKBOX_30_VALUE, CRLF
a_collection =. a_collection, 'DROPDOWN_30_VALUE  = ', DROPDOWN_30_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_30_VALUE  = ', TEXTBOX_30_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_31_VALUE  = ', TEXTBOX_31_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_32_VALUE  = ', TEXTBOX_32_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_33_VALUE  = ', TEXTBOX_33_VALUE, CRLF
a_collection =. a_collection, 'CHECKBOX_40_VALUE  = ', CHECKBOX_40_VALUE, CRLF
a_collection =. a_collection, 'DROPDOWN_40_VALUE  = ', DROPDOWN_40_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_40_VALUE  = ', TEXTBOX_40_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_41_VALUE  = ', TEXTBOX_41_VALUE, CRLF
a_collection =. a_collection, 'CHECKBOX_50_VALUE  = ', CHECKBOX_50_VALUE, CRLF
a_collection =. a_collection, 'DROPDOWN_50_VALUE  = ', DROPDOWN_50_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_50_VALUE  = ', TEXTBOX_50_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_51_VALUE  = ', TEXTBOX_51_VALUE, CRLF
a_collection =. a_collection, 'CHECKBOX_60_VALUE  = ', CHECKBOX_60_VALUE, CRLF
a_collection =. a_collection, 'DROPDOWN_60_VALUE  = ', DROPDOWN_60_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_60_VALUE  = ', TEXTBOX_60_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_61_VALUE  = ', TEXTBOX_61_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_62_VALUE  = ', TEXTBOX_62_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_63_VALUE  = ', TEXTBOX_63_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_64_VALUE  = ', TEXTBOX_64_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_65_VALUE  = ', TEXTBOX_65_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_66_VALUE  = ', TEXTBOX_66_VALUE, CRLF
a_collection =. a_collection, 'CHECKBOX_70_VALUE  = ', CHECKBOX_70_VALUE, CRLF
a_collection =. a_collection, 'DROPDOWN_70_VALUE  = ', DROPDOWN_70_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_70_VALUE  = ', TEXTBOX_70_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_71_VALUE  = ', TEXTBOX_71_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_72_VALUE  = ', TEXTBOX_72_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_73_VALUE  = ', TEXTBOX_73_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_74_VALUE  = ', TEXTBOX_74_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_75_VALUE  = ', TEXTBOX_75_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_76_VALUE  = ', TEXTBOX_76_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_77_VALUE  = ', TEXTBOX_77_VALUE, CRLF
a_collection =. a_collection, 'CHECKBOX_80_VALUE  = ', CHECKBOX_80_VALUE, CRLF
a_collection =. a_collection, 'DROPDOWN_80_VALUE  = ', DROPDOWN_80_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_80_VALUE  = ', TEXTBOX_80_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_81_VALUE  = ', TEXTBOX_81_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_82_VALUE  = ', TEXTBOX_82_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_83_VALUE  = ', TEXTBOX_83_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_84_VALUE  = ', TEXTBOX_84_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_85_VALUE  = ', TEXTBOX_85_VALUE, CRLF
a_collection =. a_collection, 'TEXTBOX_86_VALUE  = ', TEXTBOX_86_VALUE, CRLF
a_collection =. a_collection, 'TEXTAREA_00_VALUE  = ', TEXTAREA_00_VALUE, CRLF
a_collection =. a_collection, 'TEXTAREA_01_VALUE  = ', TEXTAREA_01_VALUE, CRLF
a_collection
)
