You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/development-guide/user-interface/developing-ui.md
+17-11
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,7 @@ order: 10
5
5
---
6
6
7
7
This documentation covers page creation, HTML rendering, and event handling.
8
+
8
9
- See also [UI - CSS and Assets](./developing-ui-css.html)
9
10
- See also [UI - JavaScript](./developing-ui-js.html)
10
11
- See also [HTML Forms](./developing-ui-forms.html)
@@ -18,6 +19,7 @@ This documentation covers page creation, HTML rendering, and event handling.
18
19
- Please, please, care about usability, content readability, and style in general :pray: ;)
19
20
- Check `ZCL_ABAPGIT_GUI_CHUNK_LIB` for some existing HTML chunks like `render_error`
20
21
- To register postponed HTML parts, scripts, and hotkeys - access corresponding methods via `gui_services` method of `zcl_abapgit_gui_component`
22
+
- See `zcl_abapgit_gui_page_template` as en example and template for new pages. Also see other page templates available in `test` sub-package. Follow the `TODO` comments in the template code.
21
23
22
24
## GUI Components
23
25
@@ -61,24 +63,25 @@ ENDMETHOD.
61
63
-**ADD** - adds a chunk to accumulated HTML. You can pass a string or another `ZCL_ABAPGIT_HTML` instance. In the example above `render_some_stuff` may either return a string or have the same pattern as `render_content` (retuning `ZCL_ABAPGIT_HTML` instance)
62
64
-**ADD_ICON and ICON** - renders an icon. abapGit uses web fonts to render icons (see [adding icons](./adding-icons.html)). The method accepts the icon name and a CSS class name which represents a color separated by '/'. E.g., in the example above it will render 'star' icon and assign 'error' CSS class to it which has red color in the abapGit styles. The method has its static brother `ZCL_ABAPGIT_HTML=>ICON` which is more convenient in some cases and just returns a rendered HTML string.
63
65
-**ADD_A and A** - render a link (anchor) (`A` - static method). It is strongly suggested that you use this method instead of rendering `<a>` tags directly. Params:
64
-
-`IV_TXT` - text to be rendered inside the anchor
65
-
-`IV_TYP` - the type of action done on click. 3 options:
66
-
-`zif_abapgit_html=>c_action_type-url`- direct link to an URL,
67
-
-`...-sapevent` (the default) - pass an event to sap handler,
68
-
-`...-onclick` - call a JS function,
69
-
-`...-dummy` - just render an anchor but no action
70
-
-`IV_ACT` - depending on the type should be either URL or sapevent name or JS function to call
71
-
-`IV_OPT` - `zif_abapgit_html=>c_html_opt-strong` or `...-cancel` or `...-crossout` - some semantic predefined styles to add to the link
72
-
-`IV_CLASS` - additional CSS class, if needed
73
-
-`IV_STYLE` - additional direct styles to use (generally discouraged, please use CSS classes instead)
74
-
-`IV_ID` - id of the anchor (may be needed for JS code)
66
+
-`IV_TXT` - text to be rendered inside the anchor
67
+
-`IV_TYP` - the type of action done on click. 3 options:
68
+
-`zif_abapgit_html=>c_action_type-url`- direct link to an URL,
69
+
-`...-sapevent` (the default) - pass an event to sap handler,
70
+
-`...-onclick` - call a JS function,
71
+
-`...-dummy` - just render an anchor but no action
72
+
-`IV_ACT` - depending on the type should be either URL or sapevent name or JS function to call
73
+
-`IV_OPT` - `zif_abapgit_html=>c_html_opt-strong` or `...-cancel` or `...-crossout` - some semantic predefined styles to add to the link
74
+
-`IV_CLASS` - additional CSS class, if needed
75
+
-`IV_STYLE` - additional direct styles to use (generally discouraged, please use CSS classes instead)
76
+
-`IV_ID` - id of the anchor (may be needed for JS code)
75
77
-**SET_TITLE** - the method is used for debugging purposes for postponed HTML parts. As it is not visible which class registered an HTML part, the title can be used to specify the origin.
76
78
77
79
## Renderables
78
80
79
81
Sub-classing `ZCL_ABAPGIT_GUI_PAGE` is not the only way to render the content. You may want to separate some visual component that is not a page e.g. `ZCL_ABAPGIT_GUI_VIEW_REPO` is a class like that. In essence, you have to implement `ZIF_ABAPGIT_GUI_RENDERABLE` and its method - `render`. Then you can reuse it or even pass it directly to the GUI class as a page to render.
80
82
81
83
It makes sense to also subclass your component from `ZCL_ABAPGIT_GUI_COMPONENT`. This class has a protected `gui_services` method returning the singleton instance of `ZIF_ABAPGIT_GUI_SERVICES`. The GUI services are good for:
84
+
82
85
- registering self as an event handler (`register_event_handler`). Importantly, later registered event handlers have higher priority (processing is done from bottom to top)
83
86
- accessing hotkey services (`get_hotkeys_ctl`) - to register own hotkeys for the page (hotkeys are combined from the whole component stack)
84
87
- registering postponed HTML parts (`get_html_parts`)
@@ -93,13 +96,15 @@ Components may have postponed parts, e.g. scripts or hidden forms. These chunks
93
96
iv_collection = c_html_parts-scripts
94
97
ii_part = render_my_scripts( ) ).
95
98
```
99
+
96
100
where `render_my_scripts( )` must return an instance of `ZCL_ABAPGIT_HTML`.
97
101
98
102
Currently, two collections are supported out of the box - scripts and hidden_forms (see definition of `zcl_abapgit_gui_component`). Scripts rendered after the page body. Hidden forms right before the end of the body. But this does not limit you to these categories only - you may register your own collections to exchange postponed parts between components supported by you. The collection is just a named list of `ZCL_ABAPGIT_HTML` instances.
99
103
100
104
## Router and Event Handlers
101
105
102
106
To process sapevents in abap the component (page) must implement `ZIF_ABAPGIT_GUI_EVENT_HANDLER=>on_event`. It imports `ii_event` instance which represents `sapevent` handler of `cl_gui_html_viewer`. In particular:
107
+
103
108
-`ii_event->mv_action` - sapevent code (part of URL before `?`)
104
109
-`ii_event->mv_getdata` - raw URL query (part of URL after `?`)
105
110
-`ii_event->mt_postdata` - raw post data (if present)
@@ -112,6 +117,7 @@ To process sapevents in abap the component (page) must implement `ZIF_ABAPGIT_GU
112
117
-`ii_event->form_data()` - attempts to parse post_data assuming it is set of key value pairs. Returns a string map. Otherwise behaves as `query()` above. `iv_upper_cased = false` by default.
113
118
114
119
Events can be processed on 2 levels - in page/component **or** in the router. On new event:
120
+
115
121
- the GUI goes through the event handlers stack - a list of components that registered themselves as event handlers during rendering via `gui_services`
116
122
- the processing is done from the last registered handler to the first one (stack top to bottom)
117
123
- the first event handler that returns "handled" status breaks the cycle (see below how this is indicated)
0 commit comments