cancel
Showing results for 
Search instead for 
Did you mean: 

Tabstrip navigation restriction

Former Member
0 Kudos

Dear All,

I have a tabstrip with two tabs, say Tab1, and Tab2.

In the tab Tab1, i have an input field, say input1, type D.

In the tab Tab2 i have an input field, say input2, type I.

Now i enter a string in the input field Input1 of tab Tab1, and presses second tab Tab2.

Here the navigation happens, rather i want to stop the navigation, and wants the system auto generated mesage and also it should not allow me to go to tab Tab2 till i correct the error.

Is there any logic for this, or any settings needs to be done to achieve this?

Actually i am able to get the system generated error message but cannot stop navigation into another tab.

Please suggest me something.

Thank you,

Shashi.

Accepted Solutions (1)

Accepted Solutions (1)

abhimanyu_lagishetti7
Active Contributor
0 Kudos

There is a property called SelectedTab for TabStrip, set it back to the previous tab when there is an error in event handler of onSelect of the TabStrip

Check if there is any message using IS_EMPTY method of the message manager

Abhi

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

You marked the answer from Abhimanyu Lagishetti as helpful, but you didn't mark the thread as answered. His answer seems fairly complete to me. Is there some aspect that you are still struggling with?

Former Member
0 Kudos

Its not so good to call the 'Is_Empty' Method,

this also checks the success/warning messages.

better call the 'HAS_VALIDATION_ERRORS',

this handles only the error messages.

So if you are on an old NetWeaver SP Stack,

you can also call this method from the Class 'cl_wdr_message_manager'


    data: lr_component        type ref to if_wd_component,
          lr_message_manager  type ref to cl_wdr_message_manager.
    data: l_val_errors type ABAP_BOOL.

    lr_component = wd_comp_controller->wd_get_api( ).
    lr_message_manager ?= lr_component->get_message_manager( ).

    l_val_errors = lr_message_manager->HAS_VALIDATION_ERRORS( ).

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>

> Its not so good to call the 'Is_Empty' Method,

> this also checks the success/warning messages.

>

> better call the 'HAS_VALIDATION_ERRORS',

> this handles only the error messages.

>

> So if you are on an old NetWeaver SP Stack,

> you can also call this method from the Class 'cl_wdr_message_manager'

>

>


>     data: lr_component        type ref to if_wd_component,
>           lr_message_manager  type ref to cl_wdr_message_manager.
>     data: l_val_errors type ABAP_BOOL.
> 
>     lr_component = wd_comp_controller->wd_get_api( ).
>     lr_message_manager ?= lr_component->get_message_manager( ).
> 
>     l_val_errors = lr_message_manager->HAS_VALIDATION_ERRORS( ).
> 

You also have to be careful with the HAS_VALIDATION_ERRORS method. It only catches messages that are attached to the context. It also by default doesn't catch Permanent Messages (although there is a importing parameter you can use to control this). You can of course use the GET_MESSAGES method and loop through them yourself if you want to be real sure. My personal preference however it to do my validation in WDDOBEFOREACTION and the let the Phase Model stop any further actions or navigtion.

Former Member
0 Kudos

You also have to be careful with the HAS_VALIDATION_ERRORS method. It only catches messages that are attached to the context. It also by default doesn't catch Permanent Messages (although there is a importing parameter you can use to control this). You can of course use the GET_MESSAGES method and loop through them yourself if you want to be real sure. My personal preference however it to do my validation in WDDOBEFOREACTION and the let the Phase Model stop any further actions or navigtion.

Yes, that right if you use "standard" view navigatoin

But the Phase Model logic doesnt prevent you from changing the tab in a tabstrip.

You always can change the tab error-independent.

So the question was related to context errors, so the use of the HAS_VALIDATION_ERRORS

is here he easiest way to handle this.

So if you want prevent tab-changes for all kind of errors, so you have to you use the GET_MESSAGES method. But this method is only available in higher NW SP Stacks.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>

> Yes, that right if you use "standard" view navigatoin

> But the Phase Model logic doesnt prevent you from changing the tab in a tabstrip.

You are correct using the default settings of the tabStrip. My application that I had tested with implements the onSelect Event and the selectionChangeBehaviour of the tabStrip is set to manual. In this case the Phase Model does cause the onSelect Event handler not to be fired when an error message is issued in the WDDOBEFOREACTION and since the onSelect is needed to change the context attribute bound to the selectedTab property of the tabStrip - no tab change occurs.

Former Member
0 Kudos

You are correct using the default settings of the tabStrip. My application that I had tested with implements the onSelect Event and the selectionChangeBehaviour of the tabStrip is set to manual. In this case the Phase Model does cause the onSelect Event handler not to be fired when an error message is issued in the WDDOBEFOREACTION and since the onSelect is needed to change the context attribute bound to the selectedTab property of the tabStrip - no tab change occurs

Thanks, that works fine!

Answers (1)

Answers (1)

Former Member
0 Kudos

Dear All,

First of all Thanks a lot to all the people replied to this thread..

I have come to know various reasons of checking the error messages.

I have another problem related to this, How shall we stop navigation if we catch the error messages?

When the error message is present in the tab1 should not allow me to navigate to tab2 untill I correct the error.

Any code chunk would give me an idea..

Thank you once again for all the replies.

Good day!

Former Member
0 Kudos

I have another problem related to this, How shall we stop navigation if we catch the error messages?

When the error message is present in the tab1 should not allow me to navigate to tab2 untill I correct the error.

Just follow the procedure of Abhimanyu Lagis, its described quite well.

So its no big deal.

1. Bind the TabStrip-property selectedTabto a context-attribute (e.g. SELTAB, type: String)

2. Set the TabStrip-property selectionChangeBehavior to manual (recommendation of Thomas Jung)

3. Create an Event-Handler for the onSelect-Event (e.g. CHANGE_TAB)

4. Create a method (e.g. SET_SELTAB) to set the context-attribute (SELTAB)

with an importing parameter (e.g. I_SELTAB), here you can use the wizzard, to do this.

5.1: in your Event-Handler (CHANGE_TAB), you can check your error_messages,

described in the previous answers.

5.2. then you have to call the SET_SELTAB() method with standard parameters (TAB, OLD_TAB)

so if there is no error : set_seltab(i_seltab = tab),

else if there is an error: set_seltab(i_seltab = old_tab)

For furhter Information related to Tabstrip (Properties, Event and Standardparameters) check following links of the SAP Online Help:

Link: [TabStrip Properties|http://help.sap.com/saphelp_nw04s/helpdata/en/f0/e5a8411fdbcc46e10000000a155106/frameset.htm]

Link: [TabStrip Events|http://help.sap.com/saphelp_nw04s/helpdata/en/a6/4aae42e5adcd6ae10000000a155106/content.htm]