在我的webdynpro中,当我单击一个按钮时,我不会获取该按钮的工具提示并将其用作弹出窗口的标题。
method WDDOMODIFYVIEW .
"write view to attribute so it can be accessed from other methods.
wd_this->DETAILVIEW = view.
endmethod.
。
method ONACTIONOPENDIALOG .
data lv_title type string.
data lv_buttonID type string.
data lv_button type ref to if_wd_view_element.
buttonID = wdevent->get_string( name = 'ID' ).
button = wd_this->detailview->get_element( lv_buttonid ).
call method cl_fitv_wd_util=>UI_GET_PROPERTY(
exporting
io_view = wd_this->detailview
io_view_element = lv_button
iv_id = buttonid
iv_property_name = 'TOOLTIP'
importing
ev_value = lv_title ).
wd_this->dopopup( title = lv_title ).
endmethod.
方法UI_GET_PROPERTY无法获得工具提示。可能是因为它试图在if_wd_view_element而不是cl_wd_button上调用GET_TOOLTIP方法。这是此方法中的错误吗? 有没有一种方法可以将if_wd_view_element转换为cl_wd_button?
答案 0 :(得分:1)
向下转换为对cl_wd_uielement的引用。向按钮cl_wd_button的向下转换也适用于按钮,但对于工具栏按钮则无效。 cl_wd_uielement可能适用于所有元素。
method ONACTIONOPENDIALOG .
data lv_title type string.
data lv_buttonID type string.
data lv_button type ref to if_wd_view_element.
data lv_realbutton type ref to cl_wd_uielement.
lv_buttonID = wdevent->get_string( name = 'ID' ).
lv_button = wd_this->detailview->get_element( lv_buttonid ).
"downcast view_element to uielement
lv_realbutton ?= lv_button.
lv_title = lv_realbutton->get_tooltip( ).
selectbuttonrow( exporting actionevent = wdevent ).
wd_this->dopopup( title = lv_title ).
endmethod.
我在这里找到了一篇有关垂头丧气的文章:https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abapmove_cast.htm