How to provide a "link" that allows to pass parameters into a MWS portlet application

Hi all,

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:

http://server.company.com/8585/WebAppName?uuid=76f191d0-0938-4856-a519-99ad9e875e5d&action=search

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.

Any ideas?

Thanks in advance!

  • Joachim
1 Like

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.

For example, something like this:

http://localhost:8585/page.alias?wmp1234.text=Hello

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:

http://localhost:8585/page.alias?wmpP1=alias_of_portlet_instance_here&wmpP1.text=Hello

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:

http://localhost:8585/page.alias?sh.text=Hello
1 Like

Hello Eric,

I have verified both options (2) (alias of portlet instance) and (3) (shared namespace) in my environment, and this is working as expected.

Thanks a lot for your explanation, this was very helpful!

Best regards,

  • Joachim