we have recently created a MWS portlet application providing a simple search functionality for messages exchanged on our ESB: You have a portlet containing a form, enter some search parameters, for example the uuid of the message, into text input fields, and click on “Search” to start a search. All pretty basic - a textbook example.
Now we have been requested by another team in the company to provide a “link” that allows to pass the uuid of a message directly into our portlet, and presents directly the search results. In a normal Java Web Application, this could be easily done by calling an URL in the following form:
Now the question is, how something like this could be built for a MWS portlet application. What I found out already is that by creating a page alias I can directly access the page needed. But what’s missing is how to pass parameters to the page and trigger the search (i.e. execute an action) directly.
So far I have been working with the standard Java objects available in the view source. For example using getFacesContext().getExternalContext().getRequestHeaderMap() I tried to get hold of the HTTP paramters. However, it seems like HTTP parameters are not even available within the portlet.
The name of the request parameter must be prefixed with the portlet namespace of the target portlet to be visible to that portlet instance. Since the same portlet type can be used multiple times on the same page, this parameter namespacing ensures that the values go to the correct portlet instance.
When using the APIs to generate a porlet url, this generated link would prefix the parameter name with something like “wmp1234.” where 1234 would be replaced by the real dbID of the portlet instance.
If you want to generate a link manually, you could accomplish the same without knowing the dbID by using an alias by defining what alias the prefix resolves to like this:
Alternately, MWS has a proprietary “sh.” prefix for request parameters that acts as a shared namespace. For example, a ‘text’ portlet preference would be passed to each of the portlets on the page if the address of the page looked something like this: