!--a11y-->
Custom-Rendering for the Author
Column 
An entry in the results list of the books that were found in the search is of type BSBOOKDATA (see also Data Model for the Bookshop Tutorials). The field AUTHORS is also of table type BSAUTHORS, since a book can have more than one author.
Rendering an HTMLB table view takes place in one go (during the DO_AT_END call), there is no interaction with the inner BSP elements such as individual table fields. For this application it is necessary for the BSP element to communicate with the application and to execute the rendering for the author column authors at a later point. An iterator interface is available for this for the table view (Interface IF_HTMLB_TABLEVIEW_ITERATOR), which can be implemented by any class in the BSP application – in our case, this is the controller class. BSP element <htmlb:tableView> then communicates with the application at specific times.
You must first implement interface IF_HTMLB_TABLEVIEW_ITERATOR in controller class CL_TUT_MVC_RESULT_CO. Enter this interface in the index card Interfaces of the class.
Since you want to be informed with every table field and in the case of the author column you want to program rendering, you must use method RENDER_CELL_START.
Overwrite methods IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START of controller class CL_TUT_MVC_RESULT_CO to result.do as follows.
method IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START . IF NOT ( p_column_key = 'AUTHORS' AND p_edit_mode IS INITIAL ). RETURN. ENDIF. FIELD-SYMBOLS: <row> TYPE ANY, <col> TYPE ANY. DATA: authors TYPE AUTHOR_TAB, author TYPE bsauthors. ASSIGN p_row_data_ref->* TO <row>. ASSIGN COMPONENT p_column_key OF STRUCTURE <row> TO <col>. authors = <col>. DATA: html_bee TYPE REF TO CL_BSP_BEE_HTML. CREATE OBJECT html_bee. LOOP AT authors INTO author. html_bee->ADD( html1 = author-authfnam html2 = ‘ ‘ html3 = author-authlnam html4 = ‘<br>‘ ). ENDLOOP. p_replacement_bee = html_bee. endmethod. |
No coding will run if you want to render a column other than the author column.
An HTML-BEE (BSP element expression) is created for the author column and all entries from the internal author table are written to the BEE in HTML format.
BSP Element Expression (BEE)Interface IF_BSP_BEE uses methods RENDER() and RENDER_TO_STRING()to provide you with a tool so that you can program rendering yourself.
The interface is implemented by a few classes, such as class CL_BSP_BEE_HTML which is used here to output HTML data.
The elements of the internal table are now displayed in the author column:
