Portlet URL Types Intraportlet links refer to the Oracle Portal page on which

7-18 Oracle Fusion Middleware Developers Guide for Oracle Portal boolean replaceParams UrlUtils resides in the package called oracle.portal.provider.v2.url. Notice that you do not actually fetch the page URL yourself. Rather you use one of the supplied portlet URL types, UrlUtils.PAGE_LINK. The parameter names in the params argument should be fully qualified. Moreover, assuming that you properly qualify the parameters, UrlUtils.constructLink with the appropriate linkType does not disturb other URL parameters that are not owned by the portlet. An alternative version of UrlUtils.contructLink accepts a URL as the basis for the returned URL. If you require an HTML link, you can use UrlUtils.constructHTMLLink to produce a complete anchor element. The following example portlet, ThesaurusLink.jsp, uses the parameter q to identify the word for which to search the thesaurus. It then creates links on the found, related words that the user may follow in order to get the thesaurus to operate on that new word. Refer to the example in Section 7.2.3.3.3, Building Forms with the Portlet URL Types to see the initial submission form that sets the value of q. String paramNameQ = q; String qualParamNameQ = HttpPortletRendererUtil.portletParameterparamNameQ; PortletRenderRequest pRequest = PortletRenderRequest request.getAttributeHttpCommonConstants.PORTLET_RENDER_REQUEST; String paramValueQ = pRequest.getQualifiedParameterparamNameQ; -- Output the HTML content -- center Words similar to = paramValueQ br Click on the link to search for words related to that word. br ul String[] relatedWords = Thesaurus.getRelatedWordsparamValueQ; NameValue[] linkParams = new NameValue[1]; for int i=0; i=relatedWords.length; i++ { linkParams[0] = new NameValue qualParamNameQ, relatedWords[i]; li b = relatedWords[i] b = UrlUtils.constructHTMLLink pRequest, UrlUtils.PAGE_LINK, words related to + relatedWords[i] + , , Note: When rendering attributes in SimpleResult for a mobile portlet, you must escape the attribute value if it is likely to contain invalid XML characters. Most URLs contain to separate the URLs parameters. Hence, you usually need to escape attributes that contain URLs with: oracle.portal.utils.xml.v2.XMLUtil.escapeXMLAttribute Enhancing Java Portlets 7-19 linkParams, true, true li } ul center

7.2.3.3.3 Building Forms with the Portlet URL Types Use of portlet parameters in forms is

little different from links. The following two fundamental rules continue to apply: ■ Qualify the portlets parameter names. ■ Do not manipulate or remove the other parameters on the incoming URL. In terms of markup and behavior, forms and links differ quite considerably. However, just as with links, PDK-Java contains utilities for complying with these two basic rules. The code for properly qualifying the portlets parameter name is the same as described in Section 7.2.3.3.2, Building Links with the Portlet URL Types . After all, a parameter name is just a string, whether it be a link on a page or the name of a form element. Forms differ from links in the way you ensure that the other parameters in the URL remain untouched. Once you open the form in the markup, you can make use of one of the following APIs: UrlUtils.htmlFormHiddenFieldspRequest,UrlUtils.PAGE_LINK, formName; UrlUtils.htmlFormHiddenFieldssomeURL; where formName = UrlUtils.htmlFormNamepRequest,null. The htmlFormHiddenFields utility writes HTML hidden form elements into the form, one form element for each parameter on the specified URL that is not owned by the portlet. INPUT TYPE=hidden name=paramName value=paramValue Thus, the developer needs only to add their portlets parameters to the form. The other item of which you need to be aware is how to derive the submission target of your form. In most cases, the submission target is the current page: formTarget = UrlUtils.htmlFormActionLinkpRequest,UrlUtils.PAGE_LINK The value of formTarget can be the action attribute in an HTML form or the target attribute in a SimpleForm. Even though the method name includes HTML, it actually just returns a URL and thus you can use it in mobile portlets, too. The following example form renders the thesaurus portlets submission form. Refer to the example in Section 7.2.3.3.2, Building Links with the Portlet URL Types for the portlet that results from the submission of this form. Note: Just as parameters in URLs and element names in forms require qualification to avoid clashing with other portlets on the page, form names must be fully qualified because any given page might have several forms on it.