on 11-11-2010 1:03 PM
Hallo Everyone,
Which should you use to set the focus on the UI element in a view . What are the advantages and disadvantages of using the below methods?.
REQUEST_FOCUS_ON_VIEW_ELEM of IF_WD_VIEW
or
REQUEST_FOCUS of IF_WD_VIEW_CONTROLLER
Both methods originate from the same class, they are not entirely identical but bottom line do the same. I'm not experienced enough to judge whether one's better or not, maybe Kris can tell us. Interesting question indeed.
IF_WD_VIEW --> CL_WDR_VIEW
method if_wd_view~request_focus_on_view_elem .
data: l_view_element type ref to cl_wdr_view_element.
l_view_element ?= view_element.
me->view_manager->request_focus( view_element = l_view_element
context_element = context_element ).
endmethod.
IF_WD_VIEW_CONTROLLER --> CL_WDR_VIEW
method if_wd_view_controller~request_focus.
* Requests to place the UI's keyboard input focus on the UI element whose
* primary use is to edit a property bound to the given attribute. Chooses one
* such UI element in case there are several ones. It is unspecified which
* request wins in case there are several ones.
*
* The given node element is used to decide e.g. which row of a table should
* receive focus. Note that only the combination of node element and attribute
* info allows to uniquely identify an attribute instance at runtime.
*
data: l_binding type ref to wdr_property_binding,
l_context_element type ref to cl_wdr_context_element,
l_path type string,
l_ctrl_prefix type string,
l_element type wdr_element_line.
translate attribute to upper case. "#EC TRANSLANG
* get path
l_path = cl_wd_context_services=>get_element_path_for_ctrl(
element = context_element
controller = me ).
concatenate me->name '.1.' into l_ctrl_prefix.
replace l_ctrl_prefix in l_path with ''.
concatenate l_path '.' attribute into l_path.
if attribute is not initial.
replace all occurrences of regex '\.[0-9]+\.' in l_path with '.'.
else.
replace all occurrences of regex '\.[0-9]+\.' in l_path with ''.
endif.
* get bound view element
l_context_element ?= context_element.
loop at me->elements into l_element.
l_binding = l_element-view_element->get__primary_property_binding( ).
if l_binding is bound and l_binding->path_name = l_path.
me->view_manager->request_focus( view_element = l_element-view_element
context_element = context_element ).
exit.
endif.
endloop.
endmethod.
Cheers, Lukas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.