on 01-08-2014 10:42 AM
Hi Experts,
I want to place the cursor/focus on input field based on the action triggered .
I have a WD comp where I have 3 buton on view having 3 action attached to it . Let it be action1 action2 & action3 . let there are 3 input field say inp1 inp2 and inp3.
I want that if action1 has triggered then cursor/focus should go on inp1. And if action2 triggered then inp2 .
So Please provide me the code that I should write in eventhandler ONACTION1 . so the focus go on inp1.
I know how to set focus on a particular input field using method REQUEST_FOCUS_ON_VIEW_ELEM. and write in WDDOMODIFYVIEW.
But I don't want to fixed cursor/ focus only on one input field rather I want to set focus based on action triggered. I don't know how to use FOCUS_BY_CONTEXT_ELEMENT method.
Thanks in advance.
Hi,
As a work around, you could create an attribute ( say ACTION) in the view , and set the attribute in each action.
then, in modifyview,
if action = action1
set focus on inp1
else if action = action2
set focus on inp2
.....
endif.
Even the method FOCUS_BY_CONTEXT_ELEMENT of input field you have to write in WDDOMODIFYVIEW!
Regards,
Kiran
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kiran,
Thanks for your quick response.
Probably what I have understood u want me to create a attribute in each event handler method. And set the attribute on each action and From method WDDOMODIFYVIEW set focus on respective attribute. But how to write code for this.
Can you provide me the code. What should I write in method WDDOMODIFYVIEW and how to capture view element or as you told to create attribute .
Pls help me by providing sample code.
Thanks in advance.
Hi,
No. What i meant was,
1. Go to the attributes tab of the View, create an attribute (say ACTION) of type string.
2. In the action handler method set the attribute (ACTION) to the name of action.
Ex: in the onActionBUT1 write the below code,
DATA ls_parameter TYPE wdr_event_parameter.
READ TABLE wdevent->parameters INTO ls_parameter WITH KEY name = 'ID'.
For button1 if you created action ACTION1 you will get that value in ls_parameter-id.
Now set that to the attribute( action)
wd_this->action = ls_parameter-ID .
3.
Now in DOMODIFYVIEW method, write the below code.
DATA: lr_elem TYPE REF TO if_wd_view_element.
case wd_this->action.
when 'ACTION1' " ACTION1 is the name of action for button 1
lr_elem = view->get_element( 'INP1' )." INP1 is the UI elem ID of in put field 1
view->request_focus_on_view_elem( lr_elem ).
when 'ACTION2'
lr_elem = view->get_element( 'INP2' )." INP1 is the UI elem ID of in put field 1
view->request_focus_on_view_elem( lr_elem ).
....
Hope this clears now.
Regards,
Kiran
Thanks for details reply.
I m following your steps.
1. I have declare a attribute with name action type string in attribute section of view.
2. Next when I m trying to get the value of button1 action ACTION1 into ls_parameter-id. It is showing error :
The data object "LS_PARAMETER" does not have a component called "ID". |
I have written in onactionACTION1
DATA ls_parameter TYPE wdr_event_parameter. READ TABLE wdevent->parameters INTO ls_parameter WITH KEY NAME = 'ID'.
wd_this->action = ls_parameter-ID .
Once i will get value into ls_parameter then only i can able to assign to wd_this->action .
Hi kiran,
I have followed steps . But don't know why focus/cursor is not coming on input field on view.
I have written as :
In view declared a attribute named action type string.
In all three event handler action.
wd_this->action = wdevent->get_string( name = 'ID' ).
so I got value of action button . Then in WDDOMODIFYVIEW it have written as
DATA: lr_elem TYPE REF TO if_wd_view_element.
case wd_this->action.
when 'B1'.
lr_elem = view->get_element( 'I1').
view->request_focus_on_view_elem( lr_elem ).
when 'B2'.
lr_elem = view->get_element( 'I2'). " I1 and I2 is is the UI elem ID of input field 1 & inptfld2
view->request_focus_on_view_elem( lr_elem ).
endcase.
Though it is not working . This method request_focus_on_view_elem works on support pack11 of NW7.? this is config wht i have.
Hi,
case wd_this->action.
when 'B1'.
lr_elem = view->get_element( 'I1').
view->request_focus_on_view_elem( lr_elem ).
What is B1 here? is this the name of action for button1 or the ID of button 1. It should be the button 1 ID name.
This method request_focus_on_view_elem works on support pack11 of NW7.?
Yes. this method is available from ERP 6.0 onwards IF_WD_VIEW - Web Dynpro for ABAP - SAP Library
Regards,
Kiran
Yes , B1 is the button1 id name . I debugged, It is going to WDDOMODIFYVIEW method as well as entering the rep case when event handler action is triggered. There is no syntax error also.
But focus is not getting set on input field I1. when Button B1 is triggered. view->request_focus_on_view_elem( lr_elem ). I think this method is not working .
Can u tell me Initially when application will reload it will focus to which input field ?
Hi,
Can u tell me Initially when application will reload it will focus to which input field ?
Initially, It will not focus on any input filed as the action name is empty. If you want to set focus intially to some input field write it in Others of case statement.
case wd_this->action.
when 'B1'.
lr_elem = view->get_element( 'I1').
when 'B2'.
lr_elem = view->get_element( 'I2'). " I1 and I2 is is the UI elem ID of input field 1 & inptfld2
when others.
lr_elem = view->get_element( 'I1'). " Set focus on input 1 initially
endcase.
view->request_focus_on_view_elem( lr_elem ).
I debugged, It is going toWDDOMODIFYVIEW method
Switch off debugging and just run the application and see. I tested the same and it's working.
If not, please let us know which browser version you are using.
Regards,
Kiran
Hi,
Just adding on a suggestion to do away with CASE statement in WDDOMODIFYVIEW.
Have the input fields ids as INP1,INP2, INP3 and the Button ids as INP1_BTN, INP2_BTN, INP3_BTN
1. In your action have the code as ( LV_INPT_ID is a view attribute of type string )
wd_this->lv_inpt_id = wdevent->get_string( name = 'ID ').
wd_this->lv_inpt_id = wd_this->lv_inpt_id(4).
2. In your WDDOMODIFYVIEW , just add 1 line
view->request_focus_on_view_elem( view->get_element( wd_this->lv_inpt_id ) ).
This works for me !!
Regards,
Shibin
Hi kiran,
Thanks a lot for ur response & unstanding the issue.
But still focus/cursor is not getting set on input field based on action.
Can u suggest what w'd be the reason behind it ??
Does it is becoz of error message I m reporting on view or smthing else. Once again I repeat wht I did.
I have declared a attribute name 'action' type string in attribute tab of view .
then in all three event handler action method I have written
wd_this->action = wdevent->get_string( name = 'ID '). " here getting Button id name (B1) on variable 'wd_this->action'.
And in the WDDOMODIFYVIEW method I have written.
DATA: lr_elem TYPE REF TO if_wd_view_element.
CASE wd_this->action.
when 'B1'. " here B1 is the ID name of button1
lr_elem = view->get_element( 'I1').
WHEN 'B2'.
lr_elem = view->get_element( 'I2').
WHEN OTHERS.
lr_elem = view->get_element( 'I1').
ENDCASE.
view->request_focus_on_view_elem( lr_elem ).
When application reload cursor goes on input field I1 ie ok. But
Now when button2(id name B2) is triggered cursor is not set to I2 (input fild id name).
I m having IE8 as browser. pls help
Hi,
Does it is becoz of error message I m reporting on view or smthing else.
Ah.. Yes. You should have mentioned this earlier .
When you display messages the focus will be moved to the message area. Comment the code to display message and try, it will work.
Which method you are using to display message? If you want to highlight the input field ( focus will not be set) use REPORT_ATTRIBUTE_ERROR_MESSAGE.
Regards,
Kiran
Hi,
Is there is any way where we can report message (either success or error) on view as well as focus will also Set on desire input field ??
No. If you are using few input fields( one or two ) a work around could be, without using message manager and creating a Text view with semantic color - 'negative' and bind the text of text view UI to an attribute and set the error text to that text view in the action handler of button. ( focus will be set in I/P but you will not see the icon for error message )
And How to remove/deactivate search help from input field of view without removing dictionary structure ?
In the context, select the required attribute to which you want to remove the search help, Under properties change the 'Input Help Mode' property from 'Automatic' to 'Deactivated'.
hope this helps u,
Regards,
Kiran
Hi Bhagat,
1. Create an attribute in your view called lr_view of type if_wd_view
2. In WDDOMODIFYVIEW
* This is to store the view parameter of wddomodifyview in lr_view, so that it can be used in our button actions
IF FIRST_TIME = abap_true.
wd_this->lr_view = view.
ENDIF.
3. In your action1 / action2 / action3 use below code with appropriate id for input field
DATA: lr_view_ele TYPE ref to if_wd_view_element.
lr_view_ele = wd_this->lr_view->get_element('INPUT1').
wd_this->lr_view->request_focus_on_view_elem( exporting view_element = lr_view_ele ).
Regards,
Shibin
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.
Hi Sankar,
Thanks for reply
What you are suggesting the focus will be set on one input field ATT1 <attribute name>.
But I want to Set focus/cursor on the desire input field based on action trigger by the user.
Can any body help me how to capture element in event handler onaction method and set focus in WDDOMODIFYVIEW.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.