Open the menu

    Interface URL

    When a service interface is generating its content that will be returned to the client browser on a page, sometimes it needs to generate a link to another page of the portal or it may also generate a form whose data will need to be submitted back for processing. In these situations, the navigation target will be a page of the portal. In this case, it is necessary for the framework to calculate URLs for the portal as needed.

    If an interface needs to generate a link to another interface, it is necessary to know which page the other interface is on. For this, the service interface must request URLs from the framework.

    The Java interface IServiceInterfaceUrl solves the problem of calculating URLs. Service interfaces that need URLs from the portal can obtain an implementation of IServiceInterfaceUrl from the response object. It is necessary to specify whether the URL is for a render call (through the render method) or to process an action (through the processAction method).

    The Java interface IServiceInterfaceUrl has methods for adding parameters, specifying the destination of the link, etc. Finally, there is the toString() method that returns the requested URL of the portal.

    Example of a service interface that uses IServiceInterfaceUrl:

    In the example above, the service interface implements both the render and the processAction methods to render and process the page, respectively.

    During the rendering stage, an HTML form is created via code containing a <form> and two controls: a <input type="text"> and a <input type="submit">. The action attribute of the form will be generated using the method serviceInterfaceUrl.toString(). If there is a rendering parameter called comment, it will be printed at this stage. In the first presentation of the interface, this parameter does not exist because it will be defined at the process action stage.

    The user sees the form in the browser and fills in a name in the text box. When clicking the button, the form is submitted back to the Portal Server, which detects the user's action and triggers the process action. Here it checks whether the name parameter filled in by the user in the form has been received. If this parameter exists, the process action defines a render parameter ( render parameter ) called comment containing a message. Thus, the process action ends and the rendering stage begins again, where this time the value of the comment parameter is detected and rendered in the interface.