jPorta ships with a simple column based layout manager. However a custom layout manager can be easily added to the system. The core logic for a portal page should be:
1) Get the user's session ( using the <jee:session/> tag)
2) Get the gadgets for the user (using the <jpt:gadgets/> tags)
3) Create the layout manager and pass it the list of gadgets retrieved by the <jpt:gadgets/> tag
4) Use the information provided by the layout manager to render the gadgets (using the <jsp:include/> tag)
jPorta ships with the ColumnGadgetSorter layout manager. This sorts the gadgets into a number of gadgets based on a layout constraint consisting of "col row".
The following is an example of using the ColumnGadgetSorter:
<%@ taglib uri="jeenius" prefix="jee" %>
<%@ taglib uri="jporta" prefix="jpt" %>
<%-- setup the session info --%>
<jee:session/>
<%-- load gadgets for current user --%>
<jpt:gadgets id="userGadgets"/>
<%-- sort the gadgets --%>
<jsp:useBean id="sorter" class="com.mentumgroup.jporta.webclient.ColumnGadgetSorter">
<jsp:setProperty name="sorter" property="maximumColumnCount" value="3"/>
<jsp:setProperty name="sorter" property="gadgets" value="<%= userGadgets.getGadgets() %>"/>
</jsp:useBean>
<%
//Render out the gadgets
//Note: enumerate tag not used since the jsp:include does a flush !
GadgetColumn[] columns = sorter.getColumns();
for (int colLoop=0; colLoop < columns.length; colLoop++)
{
%>
. . .
HTML to create oclumn goes here
. . .
<%
GadgetInfo[] gadgets = columns[colLoop].getGadgets();
for (int gadgetLoop=0; gadgetLoop < gadgets.length; gadgetLoop++)
{
GadgetInfo gadget = gadgets[gadgetLoop];
if (gadget.isVisible())
{
%>
. . .
rendering of gadget frame goes here
. . .
<%-- include body of gadget into page --%>
<jsp:include page="<%= gadget.getContentUrl() %>" flush="true" />
<%
}
}
%>
<%
}
%>