如何将图像添加到Liferay 7控制菜单

时间:2017-04-11 09:11:46

标签: liferay liferay-7

我正在使用Liferay 7并希望在控制菜单的中央添加图像。怎么办呢?

我已按照官方网站上提到的有关如何自定义控制菜单的步骤进行操作。 我的几个具体问题是:

  1. 是否需要使用定义的JSP文件模板?
  2. 是否有需要使用的JSP文件的已定义名称?
  3. 我使用的代码是:

    package portlet;
    
    
    import java.io.IOException;
    import java.lang.reflect.GenericArrayType;
    import java.util.Locale;
    
    import javax.servlet.RequestDispatcher;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    import org.osgi.service.component.annotations.Component;
    
    import com.liferay.product.navigation.control.menu.BaseJSPProductNavigationControlMenuEntry;
    import com.liferay.product.navigation.control.menu.BaseProductNavigationControlMenuEntry;
    import com.liferay.product.navigation.control.menu.ProductNavigationControlMenuEntry;
    import com.liferay.product.navigation.control.menu.constants.ProductNavigationControlMenuCategoryKeys;
    
    @Component(
        immediate = true,
        property = {
            "com.liferay.portlet.display-category=category.sample",
            "product.navigation.control.menu.category.key=" + ProductNavigationControlMenuCategoryKeys.TOOLS,
            "product.navigation.control.menu.category.order:Integer=19",
            "com.liferay.portlet.instanceable=true",
            "javax.portlet.security-role-ref=power-user,user",
            "javax.portlet.display-name=Customproductnavigationcontrolmenuentry Portlet"
        },
        service = ProductNavigationControlMenuEntry.class
    )
    public class CustomproductnavigationcontrolmenuentryPortlet extends BaseJSPProductNavigationControlMenuEntry implements ProductNavigationControlMenuEntry  {
    
        @Override
        public boolean includeIcon(HttpServletRequest request, HttpServletResponse response) throws IOException {
            // TODO Auto-generated method stub
            RequestDispatcher requestdispacher = request.getRequestDispatcher("/view.jsp");
            try{
            requestdispacher.include(request, response);
    
            }
            catch(Exception e){
                e.printStackTrace();
            }
    
            return true;
        }
    
    
        @Override
        public boolean includeBody(HttpServletRequest request, HttpServletResponse response) throws IOException {
            // TODO Auto-generated method stub
            RequestDispatcher requestdispacher = request.getRequestDispatcher("/view.jsp");
            try{
            requestdispacher.include(request, response);
    
            }
            catch(Exception e){
                e.printStackTrace();
            }
    
            return true;
        }
        @Override
        public String getIconJspPath() {
            // TODO Auto-generated method stub
            return null;
        }
    
    }
    

    在服务器上部署它时,我收到以下错误:

    ERROR [http-nio-8080-exec-10][IncludeTag:128] Current URL /web/guest generates exception: java.lang.NullPointerException
    java.lang.NullPointerException
    at com.liferay.product.navigation.control.menu.BaseJSPProductNavigationControlMenuEntry.include(BaseJSPProductNavigationControlMenuEntry.java:84)
    at com.liferay.product.navigation.control.menu.BaseJSPProductNavigationControlMenuEntry.includeIcon(BaseJSPProductNavigationControlMenuEntry.java:68)
    at org.apache.jsp.control_005fmen.....
    

0 个答案:

没有答案