cancel
Showing results for 
Search instead for 
Did you mean: 

Change View on Click on Link

narinderpal
Explorer
0 Kudos

Hello Friends,

I am new to Webdynpro, I am in a situation where i do have an view having an ViewContainerUIElement in which by default an other view is being displayed. I am having an link on the toolbar of this ViewContainerUIElement. i want to change the view in container to be replaced by another view. Kindly advice how i can do this.

Thanks in advance.

Regards,

Narinder Pal

Accepted Solutions (0)

Answers (1)

Answers (1)

RicardoRomero_1
Active Contributor
0 Kudos

Hi,

Try with this:

- Create an Inbound plug in your second view

- Create an Outboung plug in your MAIN view

- Create a navigation link in the window for navigate from the view MAIN to your second view

- Drag and drop both views into your view container within the window.

- Within the method you have to change the view put the following code using the code wizard:

wd_this->fire_YOUR_PLUG_NAME_plg(  ).

With this you can change the view is displayed in your viewcontainer in your MAIN view.

Hope this help you...

Regards,

Ricardo

narinderpal
Explorer
0 Kudos

Hi Ricardo ,

Thanks a lot for your comment. But i afraid about this answer, as link button is on the tool bar of container and if i fire this in method of this link it will replace the main view rather than the view in the container in this view.

Kindly check the senario.

Regards,

Narinder Pal.

Former Member
0 Kudos

Hi,

Create two outbound plugs in the Main view, and create a inbound plug in each view.

Now create navigation links from main view to other view.

Create a Char attribute in context, that will store the value of the view to be called.

Write the code in the method:



  DATA lo_el_context TYPE REF TO if_wd_context_element.
  DATA ls_context TYPE wd_this->element_context.
  DATA lv_ca_view TYPE wd_this->element_context-ca_mime_fu.

*   get element via lead selection
  lo_el_context = wd_context->get_element( ).
*   @TODO handle not set lead selection
  IF lo_el_context IS INITIAL.
  ENDIF.

*   get single attribute
  lo_el_context->get_attribute(
    EXPORTING
      name =  `CA_VIEW`
    IMPORTING
      value = lv_ca_view ).


  IF lv_ca_view IS INITIAL.
    lv_ca_view = 'X'.

    lo_el_context->set_attribute(
      EXPORTING
        name =  `CA_VIEW`
        value = lv_ca_view ).

    wd_this->fire_to_view_plg(
    ).                                                                           " Call First View

  ELSE.
    lv_ca_mime_fu = ''.

    lo_el_context->set_attribute(
      EXPORTING
        name =  `CA_VIEW`
        value = lv_ca_view ).

    wd_this->fire_to_second1_plg(
    ).                                                                          " Call Second View

  ENDIF.

Hope this will help.

Amit

narinderpal
Explorer
0 Kudos

Hi Amit,

Thanks a lot for your reply and your code, but i feel this will also not work, as in your code depending on certain condition i can decide which view to call but which ever view will be called that will over write the view from which it will be clicked. i want to change view in the container.

Regards,

Narinder

Former Member
0 Kudos

Hi Narinder,

I tried this code in my application, I have a button and a View container (VC_ELEMENT) element on the main View.

then I created two views First and Second in the Comp.

In the MAIN window, I have embedded First and Second Views in the VC_ELEMENT.

I have put a condition, just in case user wants to come back to previous view. You can remove the condition if reqired.

Regards,

Amit

narinderpal
Explorer
0 Kudos

Hi Amit,

Once again big thanks for your comment. Amit, i am still in a doubt that this code will not solve my problem. Kindly confirm me one thing, where you have placed that button, from which this method is triggering.

As per my understanding this code will work under following scenario:-

1. you have an view container.

2. that view is displaying an view

3. you have button on the view which is in that container

4. upon clicking the button, you wan to display another view depending upon some condition.

My scenario is bit different as :-

1. there is an view having an button and view container

2. view is being displayed in that container

3. button is on outer view

4. upon clicking button on outer view i want to change view of container.

Kindly advice will this code work in this scenario too????

Narinder

Former Member
0 Kudos

Are you statically embedding the view insde the view container element in the WINDOW CONTEXT of the MAIN view.

If Yes, then donot do that. As your requirement is something dynamic.

As there is only one View container element..In the MODIFYVIEW, get the reference of the Viewcontainer UI element and store this object reference in that view's attributes tab. Inn that class CL_WD_VIEWCONTAINTER...check for the excat class name there will be some method EMBED view method or some relevant method and pass the view name there in the BUTTON click event by usign that view'attribute reference.

Hope this helps.

Regards,

Lekha.

Former Member
0 Kudos

Hi narinder,

The button is in Outer view. And on click of the button, inner view changes.

And it is working for me.

Regards,

Amit