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 add new sections to existing form in Liferay 7.1
I refered this link (Liferay 7.0)
https://dev.liferay.com/de/develop/tutorials/-/knowledge_base/7-0/form-navigator
The new sections are added to the forms, but the JSP content is not reflecting.
I am getting below error
java.lang.NullPointerException
at
com.liferay.portal.kernel.servlet.taglib.ui.BaseJSPFormNavigatorEntry.include(BaseJSPFormNavigatorEntry.java:51)
at
org.apache.jsp.html.taglib.ui.form_005fnavigator.lexicon.page_jsp$6.renderHTML(page_jsp.java:2812)
at
com.liferay.taglib.util.PortalIncludeUtil.include(PortalIncludeUtil.java:43)
at
org.apache.jsp.html.taglib.ui.form_005fnavigator.lexicon.page_jsp._jspService(page_jsp.java:2807)
at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439)
at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
at
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
at
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at
com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:119)
at
com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:100)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at
org.apache.logging.log4j.core.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:59)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:748)
Can you add your jsp OR If you have lot of logic in jsp, just try to display simple text.
Reference link you provided in based on Liferay 7.0, Post title says Liferay 7.1 - are you refererring to adding some section in System Settings (of Liferay 7.1). Please provide details where exactly you are trying to add new section.
Hi Nagendra,
I am using Liferay 7.1 and I didnt find form navigator related docs for liferay 7.1, hence refering to 7.0 docs as the approach is same (Hopefully).
I am adding a new section to oraganization forms (organization-information category), similar to organization site. I was able to create a section, but the section content is empty though I am trying to show simple text from respective JSP.
Hi Nagendra,
Below is my code
OrganizationInstallProductsFormNavigatorEntry.java
<span style="">package com.liferay.users.admin.web.internal.servlet.taglib.ui.portlet;</span>
import com.liferay.users.admin.web.internal.servlet.taglib.ui.constants.OrganizationAssociateFormNavigatorEntryKeys;
import org.osgi.service.component.annotations.Component;
import com.liferay.portal.kernel.language.LanguageUtil;
import com.liferay.portal.kernel.servlet.taglib.ui.FormNavigatorConstants;
import com.liferay.portal.kernel.servlet.taglib.ui.FormNavigatorEntry;
import com.liferay.portal.kernel.servlet.taglib.ui.BaseJSPFormNavigatorEntry;
import com.liferay.portal.kernel.model.Organization;
import java.util.Locale;
import javax.portlet.PortletPreferences;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ResourceBundle;
import java.io.IOException;
import com.liferay.portal.kernel.util.PrefsParamUtil;
import com.liferay.portal.kernel.util.PrefsPropsUtil;
import com.liferay.portal.kernel.util.ResourceBundleUtil;
import com.liferay.portal.kernel.util.WebKeys;
import com.liferay.portal.kernel.theme.ThemeDisplay;
import org.osgi.service.component.annotations.Reference;
@Component(
property = "form.navigator.entry.order:Integer=40",
service = FormNavigatorEntry.class
)
public class OrganizationInstallProductsFormNavigatorEntry
extends BaseJSPFormNavigatorEntry<Organization>
implements FormNavigatorEntry<Organization> {
@Override
public String getCategoryKey() {
return FormNavigatorConstants.
CATEGORY_KEY_ORGANIZATION_ORGANIZATION_INFORMATION;
}
@Override
public String getFormNavigatorId() {
return FormNavigatorConstants.FORM_NAVIGATOR_ID_ORGANIZATIONS;
}
@Override
protected String getJspPath() {
return "install_products.jsp";
}
@Override
public String getKey() {
return "install-products";
}
@Override
public String getLabel(Locale locale) {
ResourceBundle resourceBundle = ResourceBundleUtil.getBundle(
"content.Language", locale, getClass());
return resourceBundle.getString("install-products");
}
@Override
public void include(HttpServletRequest request, HttpServletResponse response)<span style="white-space: pre;"> </span>
throws IOException {
request.setAttribute(
OrganizationAssociateFormNavigatorEntryKeys.COMPANY_MY_APP_FEATURE_ENABLED, true);
super.include(request, response);
}
@Override
@Reference(
target = "(osgi.web.symbolicname=com.liferay.users.admin.web.internal.servlet.taglib.ui)",
unbind = "-"
)
public void setServletContext(ServletContext servletContext) {
super.setServletContext(servletContext);
}
}
bnd.bnd
Bundle-Name: organization-information-form-sections Bundle-SymbolicName: com.liferay.users.admin.web.internal.servlet.taglib.ui Bundle-Version: 1.0.0 Export-Package: com.liferay.users.admin.web.internal.servlet.taglib.ui.constants Include-Resource:\ META-INF/resources=src/main/resources/META-INF/resources -jsp: *.jsp,*.jspf -plugin.jsp: com.liferay.ant.bnd.jsp.JspAnalyzerPlugin -plugin.resourcebundle: com.liferay.ant.bnd.resource.bundle.ResourceBundleLoaderAnalyzerPlugin -plugin.sass: com.liferay.ant.bnd.sass.SassAnalyzerPlugin -sass: * Web-ContextPath: /organization-information-form-sections
install_products.jsp is inside src/main/resources/META-INF/resources folder
Thank you Prashant, please find working example in repo https://github.com/btnkumar/formnavigator-extender-add-section
Displays are static as of now.
Thanks Nagendra.
The issue with my code was jsp path
Powered by Liferay™