Step 1 b) Using <htmlb:SimpleFormItem>
Element<sf:SimpleFormItem> has been implemented and can therefore be used. You must now ensure that each entry is rendered directly in the current output stream. If the <htmlb:gridLayout> is used later, a counter is required to count exactly the number of fields that are required so that the gridLayout and, of course, each individual cell can be configured correctly. This means that entries are first counted and then later rendered.
The best way to do this is if elements<htmlb:label> and <htmlb:inputField> are rendered immediately, although not in the output stream. Instead, these elements are rendered in separate writers, in which the content is stored and the entries are counted, and with which they are finally rendered.
To realize this, the entry must be changed so that it renders a string, and that this string is forwarded for rendering the <sf:SimpleForm> later.
A new methodADD_ITEM is added to element <sf:SimpleForm> with the two parameters label_html and inputField_html, which are both of type string.
You can add additional methods to the BSP event handlers, which implement additional functionality, and which can in turn be used by "lesser" elements. The element handler classes are normal ABAP classes that can be processed in the Workbench.
The simple coding will be as follows:
method ADD_ITEM .
DATA: out TYPE REF TO IF_BSP_WRITER.
out->PRINT_STRING( '<tr><td>' ). " <tr><td>
The only task forADD_ITEM at the moment to render the string immediately.
In the next step, the coding is changed within<sf:SimpleFormItem>. For each internal element that is used, the element output must not be written to the current writer under any circumstance. As a result, this ensures that a new writer is pushed on the stack. Furthermore, all new elements will write to this new writer, and the context can be extracted from this new writer at any time.
The changed coding is then as follows:
method IF_BSP_ELEMENT~DO_AT_BEGINNING .
DATA: my_out TYPE REF TO IF_BSP_WRITER,
* Add own temporary writer on stack
* Remove my writer from stack
* Copy Text to <sf:SimpleForm>
sf ?= me->GET_CLASS_NAMED_PARENT( 'CL_BSP_TUTCMPLX_SIMPLE_FORM' ).
sf->ADD_ITEM( label_html = label_html inputField_html = inputField_html ).
rc = CO_ELEMENT_DONE.
Note the following points:
All new elements that are now processed write to the top writer on the stack. At the end of this method, the additional writer must be removed from the stack using method
You can now execute pageafter.htm again to ensure that it still runs correctly.
The element<sf:SimpleFormItem> is then complete.
For more information, seeStep 2: Creating <sf:SimpleForm>