1 16 package org.apache.pluto.portlet.admin.taglib; 17 18 import java.io.IOException ; 19 import java.util.Iterator ; 20 import java.util.List ; 21 import java.util.Map ; 22 import java.util.Set ; 23 24 import javax.portlet.PortletRequest; 25 import javax.portlet.PortletSession; 26 import javax.servlet.jsp.JspException ; 27 import javax.servlet.jsp.JspTagException ; 28 import javax.servlet.jsp.JspWriter ; 29 import javax.servlet.jsp.tagext.TagSupport ; 30 31 import org.apache.pluto.Constants; 32 import org.apache.pluto.portlet.admin.PlutoAdminConstants; 33 import org.apache.pluto.portlet.admin.bean.PortletTO; 34 35 44 public class PortletSelectTag extends TagSupport { 45 46 private Map portletMap = null; 47 private int row = 1; 48 private int column = 1; 49 50 public int doStartTag() throws JspException { 51 PortletRequest request = (PortletRequest)pageContext.getRequest().getAttribute(Constants.PORTLET_REQUEST); 52 PortletSession session = request.getPortletSession(); 53 List portlets = (List )session.getAttribute(PlutoAdminConstants.PORTLET_APP_LIST_ATTR); 54 55 if (portletMap != null ) { 56 try { 57 JspWriter out = pageContext.getOut(); 58 out.println("<select name=\"portlet" + row + "." + column + "\">"); 59 Set vals = portletMap.entrySet(); 60 Iterator iter = vals.iterator(); 61 while (iter.hasNext()) { 62 Map.Entry item = (Map.Entry ) iter.next(); 63 String name = (String )item.getKey(); 64 String val = (String )item.getValue(); 65 out.print("<option value=\"" + name + "_" + val + "\""); 66 if (portlets != null) { 68 Iterator iter2 = portlets.iterator(); 69 while(iter.hasNext()) { 70 PortletTO plet = (PortletTO)iter2.next(); 71 int currrow = plet.getRow(); 72 int currcol = plet.getCol(); 73 if (row == currrow && column == currcol) { 74 out.print(" checked "); 75 break; 76 } 77 } 78 } 79 out.print(">"); 80 out.print(name); 81 out.print("</option>"); 82 } 83 out.println("</select>"); 84 } catch (IOException e) { 85 throw new JspTagException ("Error: " + e.toString()); 86 } 87 } 88 return SKIP_BODY; 89 } 90 91 94 public void setPortletMap(Map portletMap) { 95 this.portletMap = portletMap; 96 } 97 100 public void setColumn(int column) { 101 this.column = column; 102 } 103 106 public void setRow(int row) { 107 this.row = row; 108 } 109 } 110 | Popular Tags |