Show TOC

Calling ControllersLocate this document in the navigation structure

Context

You can call a controller from a page with flow logic, or from a view.

Procedure

  1. Create a page within your BSP application.

    Ensure that you select Page with Flow Logic as the page type.

  2. In the Tag Browser, select BSP extension bsp and drag it to the second line of your BSP's layout under the page directive.
  3. Now drag the <bsp:goto> directive of BSP extension bsp to the body of the HTML layout and add the URL parameter.

    The source now appears as follows:

    <%@page language="abap"%>
    <%@ extension name="bsp" prefix="bsp" %>
    <html>
      <head>
        <link rel="stylesheet" href="../../sap/public/bc/bsp/styles/sapbsp.css">
        <title> Einstiegsseite </title>
      </head>
    
      <body class="bspBody1">
        <bsp:goto url="example.do">
        </bsp:goto>
      </body>
    </html>
                   
  4. You can now activate and test the page.
    Note

    Ensure that the page you have tested looks exactly the same as when you tested the controller. The URL is different, however. You can use View Source in the browser to see that nothing remains of the HTML text from the BSP, but that only the content of the view is displayed:

    <html>

    <head>

    <link rel="stylesheet" href="../../sap/public/bc/bsp/styles/sapbsp.css">

    <title> Layout zum Controller </title>

    </head>

    <body class="bspBody1">

    <H1>View-Beispiel</H1>

    <H3>Hallo, Benutzer GREBEL</H3>

    </body>

    </html>

  5. You can now try out the difference between the <bsp:goto> element and the <bsp:call> element.

    If you use the <bsp:call> element instead of the <bsp:goto> element, the calling page text remains the same. In the view that is inserted, you should therefore delete the HTML text available on the outline page, otherwise these texts will be transferred twice.

  6. You can add another attribute to the controller. This is a public class attribute.

    It is set up using the <bsp:parameter> element. You can use it for example to control which view is called, or this value can be passed to the view.