I am new to Liferay development. Currently I am using LR 7.2.
I am tasked to create a form that take a few text input from user in LR. On submit, it posts the form data to an external URL and displays the result in a new popup window (so the original window can keep in LR context).
What are the options to accomplish something like this in LR?
Is it possible to use the LR form UI to do this?
Do I really have to develop a new portlet to do this?
I have looked into developing a new Storage Adapter to be used in LR Form setup, but that's backend.
Just feel that this is just all front end stuff and should be very easy in the typical HTML and JS. Not sure what the easiest and proper routes in LR
Many Thanks for any suggestion!
I am tasked to create a form that take a few text input from user in LR. On submit, it posts the form data to an external URL and displays the result in a new popup window (so the original window can keep in LR context).
I read this (and your post on stackoverflow, where topics are about programming) in a way that you're developing a web application, maybe in the form of a portlet, that displays a form within the page, but posts the user input to some external site. This is a quite unusual way to write web applications: I'd rather expect the application to be a JS appliation in the browser that is interfacing with an external REST API - but that's not what you're asking for.
In general: Liferay does not limit you do do this in any way - and any way you generate the required HTML is ok.
How StorageAdapters get into the game: I don't know. Certainly overkill for the scenario as I understand it (though I might not understand it correctly). They're used for Liferay Forms, which post their data back to the Liferay server and are rather "application use" than "programming". Just mentioning StorageAdapters does not make this a programming question...
Just feel that this is just all front end stuff and should be very easy in the typical HTML and JS. Not sure what the easiest and proper routes in LR
A portlet, or even just CMS content, that generates a HTML form, and adds a bit of JS to handle the popup is trivial. The starting point of any new portlet project that you can find does exactly that. You'll just have to edit the HTML and JS portion to suit your needs.
E.g. a trivial portlet that takes its HTML from a JSP:
@Component(
immediate = true,
property = {
"com.liferay.portlet.css-class-wrapper=portlet-jsp",
"com.liferay.portlet.display-category=category.sample",
"com.liferay.portlet.header-portlet-css=/css/main.css",
"com.liferay.portlet.instanceable=true",
"javax.portlet.display-name=Blade JSP Portlet",
"javax.portlet.init-param.template-path=/",
"javax.portlet.init-param.view-template=/view.jsp",
"javax.portlet.resource-bundle=content.Language",
"javax.portlet.security-role-ref=power-user,user"
},
service = Portlet.class
)
public class JSPPortlet extends MVCPortlet {
}
(and you can add a JS file to the portlet's properties by declaring it similar to the CSS file above, just use com.liferay.portlet.footer-portlet-javascript=/path/to/your.js
)
This jsp generates your HTML (here simplified, add your form)
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>
<p>
<b class="redBackground"><liferay-ui:message key="blade_portlet_jsp_JSPPortlet.caption" /></b>
</p>
Or, really simple, build it all as part of the CMS: You're posting elsewhere anyway, so there's no server-side component required.