cancel
Showing results for 
Search instead for 
Did you mean: 

Navigate to Http link on a new window from a Assignment block

former_member611341
Participant
0 Kudos

From ERPH/HeaderDetail_ view, on click on a field, I should navigate user to a new window using the HTTP link I have.

For this, I've created a newfield and redefined GET_P method to make the field type 'event_link' and a On-click even handler. Now field is showing as a link on UI, what should I do in even handler method to navigate user to a external http link. I generate this link depending on some conditions and it is a dynamic link - not same always .

please advice.

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member611341
Participant
0 Kudos

I know the solution how to do it on clicking a Button  i.e. can open a webpage,  let’s say www.google.com on click of a Button by calling the java script as seen in the code below.
 

ls_button-ON_CLIENT_CLICK = 'javascript:window.open( "http://www.google.com" );'.                 
  ls_button-page_id  = me->component_id.
  ls_button-enabled  = abap_true.
  APPEND ls_button TO rt_buttons.

I want to achieve the same clicking a field ( not BUTTON) ??

For this, I've redefined GET_P method to make the field type 'event_link' and now here there is no ON_CLIENT_CLICK  property in GET_P method, but just  Onclick .

If I write this code in GET_p method

CASE iv_property.   

WHEN if_bsp_wd_model_setter_getter=>fp_fieldtype.     

rv_value = cl_bsp_dlc_view_descriptor=>field_type_event_link.   

WHEN if_bsp_wd_model_setter_getter=>fp_onclick.     

rv_value =  'javascript:window.open( "http://www.google.com");'.

Java script is not working for onclick ,  how can i achieve this??

robert_kunstelj
Active Contributor
0 Kudos

One way is to define in get_p...

    WHEN if_bsp_wd_model_setter_getter=>fp_onclick.
      rv_value = 'ZPOPUP'.

Then create new event ZPOPUP in which you can for example fill global attribute (e.g. ZURL =

'http://www.google.com') of that view.

Then in htm layout of that view add the codding...

<% if not controller->zurl is initial.%>
  <script type="text/javascript">
    window.open("<%=controller->zurl%>").focus();
  </script>
<% clear controller->zurl.
endif.

former_member611341
Participant
0 Kudos

Thank you Robert, it helped to solve my issue to most extenet. Really appreciate it.

But one minor issue,  When I click on the field, the new Google tab webpage is opened in IE, but it does not  take me to the new google screen, I'm still on the WEB UI screen.

Thank you.

former_member611341
Participant
0 Kudos

Hey

Former Member
0 Kudos

Aday,

I believe that is what the problem is with hyperlink, you are actually setting the URL on roundtrip in event handler, once window is closed - there is no round trip again, so URL would be empty and link would not work again - whereas in case of button, URL is there due to onclientclick.

Thanks,

Rohit

robert_kunstelj
Active Contributor
0 Kudos

Rohit is right.

Former Member
0 Kudos

Hi Aday,

if you were able to solve your issue : The window opens for the first time on click, not for the second time.

Please suggest we have also the same issue.

In My Dev system the Link opens as many times i click on hyperlink, but in Quality system this link opens only for the first time, all code is same evry thing is same.

and i checked every time the URL gets created and it calls the Window.open( "url").

Please share if your problem is resolved.

Regards,

VD

former_member611341
Participant
0 Kudos

Thanks Rohit and Robert for your inputs.

Vanitha, I still has this issue, I'm trying to find any alternate solution if possible.

Let me know if you find any.

Thank you.

former_member611341
Participant
0 Kudos

Vanitha,

were you able to fix this issue? pleas let me know if you find any solution.

Former Member
0 Kudos

also supply the name attribute of window.open

<% if not controller->zurl is initial.%>
  <script type="text/javascript">
    window.open("<%=controller->zurl%>","<%= sy-uzeit %>");
  </script>
<% clear controller->zurl.
endif.

0 Kudos

Hi,

You can achieve this by implementing the following.

1.Create a new form view.

2.Add an iframe to the htm page.

3.Prepare the dynamic url and provide it to the iframe.

4.Call this new view on click of your link.

This will open your external url in the BSP view.

Regards,

Leon