Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: How to link my page created programatically to its own module
I really need your help, friends, please advise.
João Machado
I have this difficulty, i dont understand how to associate my content of the module (a simple Hello from "xpto") to the newly created page where i have the code.
Liferay has a utility method, DefaultLayoutPrototypesUtil.addPortletId, that it uses when it creates page templates. I don't see any code that looks specific to page templates (so in theory, it can be used for any page), so you should be able to use it in your own custom code in order to add portlets to pages.
Minhchau DangLiferay has a utility method, DefaultLayoutPrototypesUtil.addPortletId, that it uses when it creates page templates. I don't see any code that looks specific to page templates (so in theory, it can be used for any page), so you should be able to use it in your own custom code in order to add portlets to pages.
Thank you, Minhchau,
how would i use this method in my created page? As where in the code that generates the page? The portlet is already in the module that calls the programatically generated page. Its unclear to me.
ThemeDisplay themeDisplay =(ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);
String layoutPrototypeId = DefaultLayoutPrototypesUtil.addPortletId(themeDisplay.getLayout(), themeDisplay.getPortletDisplay().getId(), themeDisplay.getPortletDisplay().getColumnId());
System.out.println(layoutPrototypeId);
This generates a java.lang.NullPointerException
And when i try with a hard coded layoutprototypeID i get this stacktrace...
2018-11-05 10:16:57.801 ERROR [http-nio-8081-exec-1][VirtualHostFilter:375] java.lang.IllegalArgumentException: Path [web/guest/home] does not start with a "/" character
java.lang.IllegalArgumentException: Path [web/guest/home] does not start with a "/" character
at org.apache.catalina.core.ApplicationContext.getRequestDispatcher(ApplicationContext.java:404)
at org.apache.catalina.core.ApplicationContextFacade.getRequestDispatcher(ApplicationContextFacade.java:222)
at com.liferay.portal.servlet.filters.virtualhost.VirtualHostFilter.processFilter(VirtualHostFilter.java:370)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:188)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:188)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)
at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:389)
at com.liferay.portal.servlet.filters.urlrewrite.UrlRewriteFilter.processFilter(UrlRewriteFilter.java:65)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:168)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:168)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:188)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:100)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:651)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:407)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:754)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1376)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
I have made available my snippet of code here, please share your insights.
https://github.com/jmrmm-eurohelp/liferay
Would this be an option also?
https://community.liferay.com/forums/-/message_boards/message/106173
Kind regards.
Hello to all,
could anyone assist me in this topic, please?
I am trying to use portal startup events to deploy my pages. (following: https://github.com/jmrmm-eurohelp/startupLiferay)
How can i achieve this? Per documentation as follows:
Portal Context Initialization Phase
The Portal Context Initialization phase runs first with these tasks:
-
Set up low level utilities such as logging and those in
PortalUtil
andInitUtil
. -
OSGi framework is initialized.
-
Spring Phase 1: INFRASTRUCTURE beans specified by the Spring context files listed in Portal property
spring.infrastructure.configs
are loaded. -
INFRASTRUCTURE beans are published as OSGi services.
-
OSGi framework starts.
- Static bundles are installed and started.
- Dynamic bundles are started.
-
OSGi framework starts the runtime.
-
Spring Phase 2: MAIN
- Load Spring beans specified by the Spring context files listed
in Portal property
spring.configs
. - A
ModuleServiceLifecycle
event service with a service propertymodule.service.lifecycle
valuespring.initialized
(i.e.,SPRING_INITIALIZED
) registers.
- Load Spring beans specified by the Spring context files listed
in Portal property
-
MAIN Spring beans are published as OSGi services.
Thank you, David.
But i needed to create the layout for the newly created page also, so i can add pages with portlets without using the portal interface.
For that purpose i needed to have the ThemeDisplay available, how would i use this to be able to access it when loading the pre event?
I tried to use com.liferay.portal.instance.lifecycle, but on runtime i get an exception.
2018-11-08 11:44:24.433 ERROR [Framework Event Dispatcher: Equinox
Container: 50154a96-4be3-0018-13d4-a86dbed45c57][com_startup:97]
FrameworkEvent ERROR
org.osgi.framework.BundleException: Could
not resolve module: com.startup [1051]_ Unresolved requirement:
Import-Package: com.liferay.portal.instance.lifecycle;
version="[2.0.0,3.0.0)"_ [Sanitized]
On compilation, the jar is there as you can see, and it is both present on bnd.bnd and build.gradle.
Attachments:
Powered by Liferay™