Show TOC

Step 1 a) Implementing <sf:SimpleFormItem>Locate this document in the navigation structure

Use

Since the <sf:SimpleFormItem> requires an HTML <table> wrapper, first create the <sf:SimpleForm> element to render the correct HTML in the output stream.

Within class CL_BSP_TUTCMPLX_SIMPLE_FORM, overwrite and implement the following two methods:

method IF_BSP_ELEMENT~DO_AT_BEGINNING .

  DATA: out TYPE REF TO IF_BSP_WRITER.
  out = me->GET_PREVIOUS_OUT( ).
  out->PRINT_STRING( '<table>'  ).
  RC = CO_ELEMENT_CONTINUE.
 
endmethod.


method IF_BSP_ELEMENT~DO_AT_END .

  DATA: out TYPE REF TO IF_BSP_WRITER.
  out = me->GET_PREVIOUS_OUT( ).
  out->PRINT_STRING( '</table>' ).
  RC = CO_PAGE_CONTINUE.

endmethod.


         

For the actual element <sf:SimpleFormItem>, the rendering code is as follows:

<tr>
  <td>
    <htmlb:Label/> 
      </td><td>
    <htmlb:inputField/>
  </td>
</tr>


         

For the implementation, the HTML coding is fetched in the usual way using the current output writer, and written to the data stream.

Processing the <htmlb:*> element is slightly more difficult. Since both elements are empty (that is, they don't have a body), they can be processed in one step. The processing steps are as follows for each element:

  1. Create the element class

  2. Set the attributes

  3. Use method ELEMENT_PROCESS for the final processing.

The complete coding is then as follows:

method IF_BSP_ELEMENT~DO_AT_BEGINNING .
  DATA:  out TYPE REF TO IF_BSP_WRITER.
  out = me->GET_PREVIOUS_OUT( ).

* <tr><td>
out->PRINT_STRING( '<tr><td>' ).

* <htmlb:Label/>
DATA: label TYPE REF TO CL_HTMLB_LABEL.
CREATE OBJECT label.

CONCATENATE me->id '_label' INTO label->id.
label->encode         = 'FALSE'.
label->for            = me->id.
label->wrapping       = 'FALSE'.
label->text           = me->label.

m_page_context->ELEMENT_PROCESS( element = label ).

* </td><td>
out->PRINT_STRING( '</td><td>' ).

* <htmlb:inputField/>

DATA: inputField TYPE REF TO CL_HTMLB_INPUTFIELD.
CREATE OBJECT inputField.


inputField->id             = me->id.
inputField->description    = me->description.
inputField->disabled       = me->disabled.
inputField->firstDayOfWeek = me->firstDayOfWeek.
inputField->invalid        = me->invalid.
inputField->maxlength      = me->maxlength.
inputField->password       = me->password.
inputField->required       = me->required.
inputField->showHelp       = me->showHelp.
inputField->size           = me->size.
inputField->type           = me->type.
inputField->value          = me->value.
inputField->visible        = me->visible.
inputField->width          = me->width.

m_page_context->ELEMENT_PROCESS( element = inputField ).

* </td></tr>
out->PRINT_STRING( '</td></tr>' ).

rc = CO_ELEMENT_DONE.

endmethod.



         
Caution

Note that you cannot make any changed to the actual output writer structures. The coding, exactly like the inner elements that are processed, is executed on the current writer. This is automatically controlled by the development environment (indirectly using the PROCESS_ELEMENT call).

You can now test page after.htm.

The following task appears:

Continue with Step 1 b) Using <htmlb:SimpleFormItem>.