Websphere Portlet migration, missing parameter in DispatchAction - java

I'm migrating an old portlet application from WPS5 to WPS6. The application is using IBM legacy container. According to the migration guide, I only renew some portal library and some tag reference. The application is still using IBM legacy container and the modified Struts Portlet.
When I create a link like by:
<html:link page="/page1.do?method=display">Go to Page 1</html:link>
The link render such url:
/wps/.../...[hash-like chars]_spf_strutsAction=!2fpage1.do!3fmethod%3ddisplay#[hash-like chars]
I'm using DispatchAction, which would look up parameter 'method' for dispatch. However, click on the above link cannot pass the 'method' parameter to dispatchAction. Further investigation on the request parameter found out this key-value pair:
name: spf_strutsAction
value: !2fpage1.do!3fmethod=display
So it's quite obviously that request.getParameter('method') returns null because the parameter is buried under request.getParameter('spf_strutsAction') and thus the action cannot be dispatched.
Of course I can force the dispatch action by reading the buried parameter. But the problem is that there are many other parameter other than 'method'.
I think that the portal server should provides its implementation of PortletRequest. Is that the PortletRequest.getParameter() is somehow incorrect? Or is it the Portlet Struts Problem? How can I put those parameters back inside the request object?

Some ideas:
You could use the portlet tags to generate the links.
Check out the "newer" struts jars that come with IBM Portal 6.0
Consider using a better portlet web framework, such as Spring Portlet MVC, which is jsr168 compliant. IBM will not be supporting it's old portlet model in the future.

Related

Vaadin 14 how to move the vaadin servlet to a different URL?

I have a pretty basic vaadin application running. The application is spring-boot backed and I defined some rest API.
I've added OpenAPI documentation using org.springdoc:springdoc-openapi-ui:1.4.4, which worked perfectly before adding vaadin.
After adding the vaadin dependencies as shown in the vaadin spring-boot tutorial, and creating a view (which works), the swagger UI is no longer reachable.
It seems to me that vaadin completely takes over all web requests. Digging deeper, I've found that vaadin registers a new servlet and catches all requests.
I don't find any docs on how to configure this -- I'd expect that one could configure vaadin such that it serves UI from a different path, say /ui or similar.
I've tried to set
vaadin:
url-mapping: "/ui/*"
in my application.yaml -- but this results in blank pages (no errors) for my vaadin views,
and the vaadin servlet does still take over /.
I use spring.boot 2.3.2.RELEASE, vaadin 14.3.1.
The value to override is (note the camelCase instead of the kebab-case):
vaadin:
urlMapping: /ui/*
Using the kebab-case did (does) not work. As expected, this is a bug. See https://github.com/vaadin/spring/issues/637
From the docs at the point of time:
You can set properties for Spring Boot in your application.properties file.
Example: Setting Spring URL mapping in application.properties.
vaadin.urlMapping=/my_mapping/*
By default, URL mapping is /*.
An additional servlet, such as /my_mapping/*, is required to handle the frontend resources for non-root servlets. The servlet can be defined in your application class. See this Application class for a example.
Source: https://vaadin.com/docs/v14/flow/spring/tutorial-spring-configuration.html#using-spring-boot-properties

runtime added portlets do not rendered when parent portlet has use-default-template value true

I am working on a portlet which accepts the portlet ids and renders those portlets. So, basically you can think of something like a container portlet.
When the container portlet has a value <use-default-template>false</use-default-template> in liferay-portlet.xml, everything works fine. It is able to render the portlet via tag <liferay-portlet:runtime portletName="1_WAR_sampleportlet" />
But, if I make the entry <use-default-template>true</use-default-template> for the container portlet (or just remove the tag, as default is true), it simply ignore the <liferay-portlet:runtime /> tag and shows nothing.
The other information are
Liferay version : liferay 6.2 EE
Java version : Java 7
Portlet Type : Spring MVC portlet
Please refer below links, as this question is already answered earlier in stackoverflow.
use-default-template configuration tag does not work
Also, not that if you disable "use-default-template" then Liferay is doing exactly what you requested: It does not display any default controls and only shows the content created by the portlet's render() method.
So if you need to have a configuration link (or a remove button or any other control present in the default template), your portlet has to render it on its own.

Portlet jsp + jquery datatable +servlet implementation

I have created a liferay portlet using mvc (jsp ) and i'm using JQuery for datatable.
I have succeeded to bring a list and display it on a table using Jquery.
Now, I'm trying to make it editable to use CRUD functions.
The problem that i'm using java not php and i couldn't assign a servlet function (doget).i didn't understand it well (how to use it) and they set the url of this class to jquery.
If i'm not wrong this would be configured in web.xml (servlet mapping). So i wonder how to properly configured and use it?
Also, i don't know jquery but it seems that the buttons needs to be manually included. is there any method to include them directly? (with jquery looks and pop up).
Servlet comes in 2.4 version i had troubles changing it to 3.0 using eclipse.
Best Regards
If you use web.xml and servlets, you are out of liferay and the implementation for user login, themeDisplay, permissions and other features. This way is dificult and improductive.
Better choice is override the method "serveResource" of your portlet, in this method you have all control like in servlets and you can use other features of liferay.
In this question you have an example and more information:
respond to http request with json object in portlet

How to run a Spring portlet

I am new to Spring portlet i am unable to run a sample spring portlet project.. I am trying to run the project from eclipse as run on server on jboss server. My questions are 1. How can we run a portlet project. Do i need some kind of portlet container(I have no idea of this container i just know few names like liferay etc)?? I cant find a full documented example any where.. In Spring mvc based on the request mapping i can call that purticular Controller class but in Spring mvc portlet how can we call this controllers( or Portlets). Is it possible to call a portlet directly by an url?? The sample project is deployed without any error but i cant find a way by which i can call or trigger a portlet. Any help would be much appriciated.
thx
nkovi
Yes, you will need to deploy to a portlet container like Liferay etc, or uPortal. Once you have the portlet container up and running, things should hopefully become more obvious.
Regarding your other questions, I strongly suggest you read some documentation - the Spring portlet docs are not too bad although they are a little behind on annotations.

How to obtain Liferay session in custom servlet?

I wrote custom servlet in Liferay and want to know which user page calls it and know other parameters like theme. But the request's attributes and session fields are all nulls.
How to make custom servlet to receive request as if portlet does?
Thanks
P.S. I don't want to use this solution https://www.everit.biz/web/guest/blog/-/blogs/getting-current-liferay-user-in-a-standalone-webapp?_33_redirect=/web/guest/blog
which reads cookies manually. I want to do such as Liferay does, i.e. by using it's API. Is it possible?
Update 1.
I have a portlet and a servlet in one WAR. I can know who am I (logged in user) from within portlet JSP like this:
HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);
themeDisplay.getUser()
Now I want to do the same from a servlet. Is it possible?
I am working in eclips which deploys automatically.
You either have to mimic what Liferay does in the portlet request handling (not recommended) or, alternatively, put your servlet code into a portlet - this can be the "resource handling" of a portlet - here you get full access to the http request and can do everything yourself with regards to data types transmitted in the stream.
I'd rather recommend this as it will be significantly easier to upgrade. Portlet Resource Handler are very similar to servlets from a logical point of view. There might be other (more advisable) options, but this is what comes to my mind for this type of problem.

Categories