cancel
Showing results for 
Search instead for 
Did you mean: 

Using method report_element_error_message

Former Member
0 Kudos

Hi

I'm using the method report_element_error_message to display an error message.



l_element = wd_context->get_element( ).

CALL METHOD lo_message_manager->report_element_error_message
  EXPORTING
    message_text              = lv_message
    element                   = l_element
*    attributes                = l_attribute
*    params                    =
*    msg_user_data             =
*    is_permanent              = ABAP_FALSE
*    scope_permanent_msg       = CO_MSG_SCOPE_CTXT_ELEMENT
*    msg_index                 =
*    cancel_navigation         =
*    is_validation_independent = ABAP_FALSE
    .

I wanted to focus on a specific UI element (file input) after the display of the message. But what happens here is that somehow the radio buttons get underlined with tooltips.

Thanks

Pushpraj

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Use report_attribute_errror_message then you get the focus on Input field automatically by passing the attribute name.

Hope it helps!

Regards,

Radhika.

Former Member
0 Kudos

Hi Radhika

Ok the radio buttons getting focussed upon problem gets solved with this method but I still can't get the focus on the UI element fileUpload (whose name property is bound with the attribute upload_filename).


CALL METHOD lo_message_manager->report_attribute_error_message
  EXPORTING
    message_text              = lv_message
    element                   = l_element
    attribute_name            = 'UPLOAD_FILENAME'
*    params                    =
*    msg_user_data             =
*    is_permanent              = ABAP_FALSE
*    scope_permanent_msg       = CO_MSG_SCOPE_CTXT_ELEMENT
*    msg_index                 =
*    cancel_navigation         =
*    is_validation_independent = ABAP_FALSE
    .

Pushpraj

uday_gubbala2
Active Contributor
0 Kudos

Hi Pushpraj,

Whenever WDA is throwing any messages the framework does automatically set the focus to the MessageArea of your component. Using report_attribute_error_message all the messages get displayed with a LinkToAction field, up on clicking which the focus would shift to that particular ui element. Its not possible to both display a message and have that particular ui element focused for the user.

Regards,

Uday

Former Member
0 Kudos

Hi Uday

I checked the WDC WDR_TEST_MSG_MANAGER_00 ; it's got a validation error message for a date type input field. It does focus on the field (a red outline) as well as give the eror message. Any idea how it does that?

Pushpraj

Former Member
0 Kudos

Hi,

With the method "report_attribute_errror_message " you should be able to give an error message and at the same time highlight the UI element for which the error has occured. You have to make sure that you pass the correct the "UI element name and the correct node element reference to the method". Once this is done, the UI element for which the error has occured will be highlighted. Also, put this validation code in wddobeforeaction.

Best Regards,

Ashish.

Former Member
0 Kudos

Hi Ashish

I use this line for getting the element reference


l_element = wd_context->get_element( ).

Any idea how to get a particular UI element?

If I pass any index other than 1 (index = 2) it throws up a syntax error. An even 1 doesn't get the focus.

Pushpraj

Former Member
0 Kudos

Hi,

l_element = wd_context->get_element( ).

Is this attribute is under any node or directly to root context.

If it is driectly under the root context then there is no need of the INDEX.

If it under the node with cardinality (1:N, 0:N) then you can use INDEX to get that particular element.

In your case if you give other than 1 it will throw error because the attribute is under the ROOT context

as you are using the WDCONTEXT key word.

Is this clear.

Regards,

Lekha.

Former Member
0 Kudos

Hi Lekha

This element is directly under root context. But then there are other elements too directly under root context. How to specify which element we want to fetch?

Pushpraj

Former Member
0 Kudos

Hi,

You can use the GET_ATTRIBUTE method of IF_WD_CONTEXT_NODE, pass the ATTRIBUTE name.

In this case you need to use the method REPORT_ATTRIBUTE_ERROR_MESSAGE not element.

If you use element as specified by you then you need to again use the GET_ATTRIBUTE of IF_WD_CONTEXT_ELEMENT and pass the attribute name.

Then you can use the method REPORT_ELEMENT_ERROR_MESSAGE.

Is this clear.

Regards,

Lekha.

Former Member
0 Kudos

Ok I think it's simply not possible to have the focus on the UIelement after an error display. I give up.

I've tried

attribute_name            = 'MAIN.UPLOAD_FILENAME'
attribute_name            = 'UPLOAD_FILENAME'
* nothing works.

Thnks for the reply Lekha, but get_attribute gets the value of the attribute (the file path in this case) and not the name (or whatever it is that this method wants).

Pushpraj

Former Member
0 Kudos

Hi,

attribute_name = `MAIN.UPLOAD_FILENAME`

attribute_name = `UPLOAD_FILENAME` Use the tilde opertor.

  • nothing works

for GET_ATTRIBUTE, pass the context attribute name and import the value.

Use the code wizard by reading that attribute.

For Ex: if your context attribute for sorting file name FILE_NAME as string.

You can use the get_attribute by passing this FILE_NAME and returns a string.

If you want the attribute names then use the method GET_ATTRIBUTE_NAMES of the IF_WD_CONTEXT_NODE_INFO.

First get the ndoe info

lr_nd_info = wd_context->get_node_info.

lt_names = lr_nd_info->get_attributes_names.

Regards,

Lekha.

uday_gubbala2
Active Contributor
0 Kudos

Hi Pushparaj,

Joined the conversation late. As how I said earlier its not possible to have the erroneous ui element set in focus. The system does by default highlight all the ui elements where an error has occured. But it doesn't set the focus on any specific one nor can we do the same. You can try coding your own set focus stuff but they all wouldn't work.

Regards,

Uday

Former Member
0 Kudos

Hi Uday

I thought highlight and focus were the same thing.

But in my case it doesn't even do that.

Anyway its not really all that important now.

Hi Lekha

Tilde ` doesn't help either. And wouldn't get_attribute_names get the same thing that I'm anyways putting into the method?

Thanks for your help guys.

Edited by: Pushpraj Singh on Jun 1, 2009 5:48 PM

Answers (0)