Calling a Service many times from an HTML form

It is possible to call a Service multiple times from a single HTML form (for example, one time for each row in the form) by placing a line similar to the following with a service-multi event type defined for the controller.xml request-map entry of the target Service.

How to do it...

Follow these steps to call a Service multiple times:

  1. Use the event type service-multi within the controller.xml request-map entry as shown here:
    <request-map uri="someService" />
    <event type="service-multi" invoke="someService"/>
    <!-- Other request-map statements intentionally left out -->
    </request-map>
    
  2. If using an OFBiz Form Widget, add a line similar to the following to the Form Widget definition. Note, the list-name is the name of the list that is generating multiple rows for the HTML form:
    <form name="someFormName" type="multi" use-row-submit="true"
    list-name="someList" target="someServiceName" /
    <!-- Form fields removed for reading clarity -->
    </form>
    
  3. If using a FreeMarker template, add lines similar to the following:
    <form name="mostrecent" mode="POST"
    action="<@ofbizUrl>someService</@ofbizUrl>"/>
    <#assign row=0/>
    <#list someList as listItem>
    <#-- HTML removed for reading clarity.
    Each row has a unique input name associated with it
    allowing this single Form to be submitted to the
    "someServiceName" Service from each row -->
    <input type="radio" name="someFormField_o_${row}"
    value="someValue" checked/>
    <input type="radio" name="someFormField_o_${row}"
    value="someValue"/>
    </#list>
    </form>
    

How it works...

The Event type service-multi provides a convenient shortcut for coding HTML forms that are embedded within lists. Each list item is automatically converted to a unique form field so that a single Service may be called from any row within the list.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.249.174