Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating liferay-ui elements in a JSP

I need to generate several <liferay-ui:panel>s. The idea would be to have a JSP that looks something like this:

<liferay-ui:panel-container extended="true">
    <%=MyJavaClass.generatePanel() %>
</liferay-ui:panel-container>

and Java code along the lines of:

class MyJavaClass {
    public static String generatePanel() {
        String result="<liferay-ui:panel collapsible=\"false\" extended=\"true\" title=\"Some Title\">Some Content</liferay-ui:panel>";
        return result;
    }
}

Liferay won't convert the <liferay-ui panel...>. I'm guessing this is because it only does so before the java code is executed, so I'm not getting any panels.

Is there any way to get Liferay to go through the JSP after I generated the panels? Or am I missing a better way to do this?

like image 849
icke Avatar asked Dec 28 '25 22:12

icke


1 Answers

Move the line <liferay-ui:panel collapsible=\"false\" extended=\"true\" title=\"Some Title\">Some Content</liferay-ui:panel>" to a jsp tag located at WEB-INF/tags/liferay-panel.tag.

And include the tag in the required jsp.

Below is the solution for the same:

liferay-panel.tag

<liferay-ui:panel collapsible=\"false\" extended=\"true\" title=\"Some Title\">
    Some Content
</liferay-ui:panel>

And include the tag like this:

<%@taglib prefix="tags" tagdir="/WEB-INF/tags"% >
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<liferay-ui:panel-container extended="true">
     <c:forEach var="i" begin="1" end="20" step="1">
        <tags:liferay-panel/>
     </c:forEach>
</liferay-ui:panel-container>
like image 76
Ramesh PVK Avatar answered Dec 30 '25 12:12

Ramesh PVK



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!