ビジネス・コンポーネント・データ・タグを使用した行の更新

ビジネス・コンポーネント・データソース内で編集する行を選択するJSPページでは、処理のためにHTTP Requestオブジェクトを介して発行用ページにポストする必要があります。

この操作をアプリケーション・モジュール・インスタンスとビュー・オブジェクトのデータソースに対して実行するには、後述のビジネス・コンポーネント・データ・タグを使用して2つのJSPページを作成します。

編集用JSPページ

  1. 必要なビジネス・コンポーネント・データ・タグをHTMLフォーム要素に追加します。データ・タグにより、ビュー・オブジェクト・データソースの指定の属性にバインドされたフォーム要素がレンダリングされます。たとえば、次のタグを使用します。

    <form name="edit" action="formSubmit.jsp" method="post">
      <table>
       <%-- Iterate through all the attributes of the current record --%>
       <jbo:AttributeIterate id="def" datasource="ds">
         <tr>
           <%-- Display attribute name and render value --%>
           <td align="right"><jbo:ShowHint hintname="LABEL" /></td>
           <td align="right"><jbo:RenderValue datasource="ds" /></td>
         </tr>
       </jbo:AttributeIterate>
      </table>
    </form>

  2. 既存の行を編集する場合は、編集イベントを処理する発行用ページへのHREFを作成します。<jbo:UrlEvent>データ・タグを使用して、必要なビジネス・コンポーネント識別子を渡します。

    <form name="edit" action="formSubmit.jsp" method="post">
      <table>
       <%-- Iterate through all the attributes of the current record --%>
       <jbo:AttributeIterate id="def" datasource="ds">
         <tr>
           <%-- Display attribute name and render value--%>
           <td align="right"><jbo:ShowHint hintname="LABEL" /></td>
           <td align="right"><jbo:RenderValue datasource="ds" /></td>
           <%-- Submit the jboEvent with the URL --%>
           <td> <a href="<jbo:UrlEvent targeturlparam='formSubmit.jsp'
                          event='Edit' datasource='ds' addrowkey='true'/>">Edit</a> </td>
         </tr>
       </jbo:AttributeIterate>
      </table>
    </form>

発行用JSPページ

  1. Editイベントを使用してビジネス・コンポーネントの<jbo:OnEvent>データ・タグを追加し、Getアクションを使用してビジネス・コンポーネントの<jbo:Row>データ・タグをネストし、編集用ページで指定したのと同じデータソースのHTTP Requestオブジェクトを処理します。

    <jbo:OnEvent name="Edit" datasource="ds">
       <jbo:Row id="delrow" rowkeyparam="jboRowKey" action="Get" </jbo:Row>
    </jbo:OnEvent>

  2. HTMLフォームを作成し、ビジネス・コンポーネント・データ・タグを使用して現行レコードの属性をすべて反復し、属性名を表示してから、入力フィールドと現在の値をレンダリングします。

    <form name="submit" action="formSubmit.jsp" method="post">
      <table>
       <%-- Iterate through all the attributes of the current record --%>
       <jbo:AttributeIterate id="def" datasource="ds">
         <tr>
           <%-- Display attribute name --%>
           <td align="right"><jbo:ShowHint hintname="LABEL" /></td>
           <%-- Display input field with current value --%>
           <td><jbo:InputRender formname="edit" /></td>
         </tr>
       </jbo:AttributeIterate>
      </table>
    </form>

  3. ビジネス・コンポーネントのPostまたはCommit、あるいはその両方のデータ・タグを追加して、データソースに対する変更をデータベースに適用します。

JSPページが更新タスク中にアクセスするアプリケーション・モジュール・オブジェクトには、発行用JSPページで更新が完了するまで予約済モードでアクセスする必要があります。この動作は、JSPページに追加する<jbo:ApplicationModule>データ・タグのreleasemode属性により制御されます。


ビジネス・コンポーネント・データ・タグについて
ビジネス・コンポーネント・データ・タグを使用した行の編集について
ビジネス・コンポーネント・フォームのInputデータ・タグについて

ビジネス・コンポーネント・データ・タグについては次のリファレンスを参照してください。

リファレンス: ビジネス・コンポーネント・データ・タグ・ライブラリ