RE: How to add new sections to existing form in Liferay 7.1

Prashanth Relekar, modified 6 Years ago. New Member Posts: 17 Join Date: 9/20/18 Recent Posts

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)

thumbnail
Nagendra Kumar Busam, modified 6 Years ago. Liferay Master Posts: 678 Join Date: 7/7/09 Recent Posts

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.

Prashanth Relekar, modified 6 Years ago. New Member Posts: 17 Join Date: 9/20/18 Recent Posts

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. 

thumbnail
Nagendra Kumar Busam, modified 6 Years ago. Liferay Master Posts: 678 Join Date: 7/7/09 Recent Posts
Can you please add a screen shot, to get idea of where you are trying to add. If you can add your code to post, will help to debug ( instead of doing it from scratch for the community memebers to try out)
Prashanth Relekar, modified 6 Years ago. New Member Posts: 17 Join Date: 9/20/18 Recent Posts

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&lt;Organization&gt;
    implements FormNavigatorEntry&lt;Organization&gt; {

    @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
thumbnail
Nagendra Kumar Busam, modified 6 Years ago. Liferay Master Posts: 678 Join Date: 7/7/09 Recent Posts

Thank you Prashant, please find working example in repo https://github.com/btnkumar/formnavigator-extender-add-section

 

Displays are static as of now.

 

Prashanth Relekar, modified 6 Years ago. New Member Posts: 17 Join Date: 9/20/18 Recent Posts

Thanks Nagendra.

 

The issue with my code was jsp path smiley

Gilberto Lam, modified 6 Years ago. New Member Post: 1 Join Date: 2/16/19 Recent Posts
I was also facing same issue,but unable to get a solution to it.mybkexperience