1 package com.dotmarketing.portlets.structure.action; 2 3 import java.util.List ; 4 import javax.portlet.PortletConfig; 5 import javax.portlet.RenderRequest; 6 import javax.portlet.RenderResponse; 7 import javax.portlet.WindowState; 8 import org.apache.struts.action.ActionForm; 9 import org.apache.struts.action.ActionForward; 10 import org.apache.struts.action.ActionMapping; 11 import com.dotmarketing.portal.struts.DotPortletAction; 12 import com.dotmarketing.portlets.structure.factories.StructureFactory; 13 import com.dotmarketing.util.UtilMethods; 14 import com.dotmarketing.util.WebKeys; 15 16 public class ViewStructureAction extends DotPortletAction { 17 public ActionForward render(ActionMapping mapping, ActionForm form, 18 PortletConfig config, RenderRequest req, RenderResponse res) 19 throws Exception { 20 String orderBy = req.getParameter("orderBy"); 21 orderBy = (UtilMethods.isSet(orderBy) ? orderBy : "description"); 22 if (req.getWindowState().equals(WindowState.NORMAL)) { 23 int limit = 5; 24 _loadStructures(form, req, res, orderBy, limit); 25 return mapping.findForward("portlet.ext.structure.view"); 26 } else { 27 int limit = -1; 28 _loadStructures(form, req, res, orderBy, limit); 29 return mapping.findForward("portlet.ext.structure.view_structure"); 30 } 31 } 32 33 private void _loadStructures(ActionForm form, RenderRequest req, 34 RenderResponse res, String orderBy, int limit) { 35 List list = StructureFactory.getStructures(orderBy,limit); 36 req.setAttribute(WebKeys.Structure.STRUCTURES, list); 37 } 38 } 39 | Popular Tags |