How to Use Go Buttons and Go Links

18-8 Web User Interface Developers Guide for Oracle Application Development Framework Example 18–1 Context Parameter to Configure a Browser’s Context Menu context-param param-nameoracle.adf.view.rich.ACTION_LINK_BROWSER_CONTEXT_SUPPRESSIONparam-name param-valuenoparam-value context-param For more information about ADF Faces configuration options in your application’s web.xml file, see Section A.2, Configuration in web.xml. At runtime, end users can invoke a browser’s context menu by right-clicking on the links rendered by certain components, as described in Section 18.3, Configuring a Browser’s Context Menu for Command Links.

18.4 Using Buttons or Links to Invoke Functionality

In addition to using command components for navigation, ADF Faces also includes listener tags that you can use in conjunction with command components to have specific functionality execute when the action event fires. Listener tags included with ADF Faces include: ■ exportCollectionActionListener: Use to export data from an ADF Faces application to an Excel spreadsheet. For more information, see Section 10.9, Exporting Data from Table, Tree, or Tree Table . ■ fileDownloadActionListener: Use to initiate a file download from the server to the local computer. For more information, see Section 18.4.1, How to Use a Command Component to Download Files . ■ resetActionListener: Use to reset submitted values. However, no data model states will be altered. For more information, see Section 18.4.2, How to Use a Command Component to Reset Input Fields . If you want to reset the input components to their previous state, which was partially or fully submitted successfully to the server, then you can use a reset button. For more information, see Section 9.2.3, How to Add a Reset Button to a Form .

18.4.1 How to Use a Command Component to Download Files

You can create a way for users to download files by creating an action component such as a command button and associating it with a fileDownloadActionListener tag. When the user selects or clicks the action component, a popup dialog is displayed that allows the user to select different download options, as shown in Figure 18–3 . Figure 18–3 File Download Dialog Working with Navigation Components 18-9 The fileDownloadActionListener tag is used declaratively to allow an action component such as command button, command link, or menu item to programmatically send the contents of a file to the user. You can also declare a specific content type or file name. Because file download must be processed with an ordinary request instead of the XMLHttp AJAX requests, the parent component’s partialSubmit attribute, if supported, must be set to false. After the content has been sent to the browser, how that content is displayed or saved depends on the option selected in the dialog. If the Open with option was selected, the application associated with that file type will be invoked to display the content. For example, a text file may result in the Notepad application being started. If the Save to Disk option was selected, depending on the browser, a popup dialog may appear to select a file name and a location in which to store the content. Example 18–2 shows the tags of a command button with the fileDownloadActionListener tag to download the file content Hi there to the user. Example 18–2 File Download Using Command Button and fileDownloadActionListener Tag af:commandButton value=Say Hello af:fileDownloadActionListener filename=hello.txt contentType=textplain; charset=utf-8 method={bean.sayHello} af:commandButton Example 18–3 shows the managed bean method used to process the file download. Example 18–3 Managed Bean Method Used to Process File Download public void sayHelloFacesContext context, OutputStream out throws IOException { OutputStreamWriter w = new OutputStreamWriterout, UTF-8; w.writeHi there; . . . } To create a file download mechanism: 1. From the Component Palette, drag and drop any action component to your page for more information about action components, see Section 18.2, Using Buttons and Links for Navigation .

2. Expand the Operations section of the Component Palette, and drag and drop the

File Download Action Listener tag as a child to the action component. 3. In the Property Inspector set the following attributes: ■ contentType: Specify the MIME type of the file, for example textplain, textcsv, applicationpdf, and so on. ■ filename: Specify the proposed file name for the object. When the file name is specified, a Save File dialog will typically be displayed, though this is ultimately up to the browser. If the name is not specified, the content will typically be displayed inline in the browser, if possible. Tip: For information about uploading a file to the server, see Section 9.9, Using File Upload .