1 package org.exoplatform.portlets.nav.renderer.html; 2 3 import java.io.IOException ; 4 5 import javax.faces.component.UIComponent; 6 import javax.faces.context.FacesContext; 7 import javax.faces.context.ResponseWriter; 8 import javax.faces.render.Renderer; 9 import org.exoplatform.faces.FacesConstants; 10 import org.exoplatform.portlets.nav.component.UINavigation; 11 12 13 19 20 public class NavigationEditRenderer extends Renderer 21 { 22 private static String FACE_FORM = "navigationEdit"; 23 private static String FACE_ACTION_SAVE = "faceActionSave"; 24 private static String FACE_ACTION_CANCEL = "faceActionCancel"; 25 26 public void encodeBegin(FacesContext context,UIComponent component) throws IOException 27 { 28 ResponseWriter writer = context.getResponseWriter(); 29 30 String actionURL = context.getExternalContext().encodeActionURL(null); 31 32 writer.write("<form name=\"" + FACE_FORM + "\" method=\"post\" action=\"" + actionURL + "\">"); 33 writer.write("<input type=\"hidden\" name=\"" + FacesConstants.ACTION + "\" value=\"" + FACE_ACTION_CANCEL + "\">"); 34 writer.write("<input type=\"hidden\" name=\"" + FacesConstants.COMPONENT + "\" value=\"" + UINavigation.DEFAULT_RENDERER_TYPE + "\">"); 35 36 writer.write("<table>"); 37 38 writer.write("<tr>"); 39 writer.write("<td><label>Menu</label></td>"); 40 writer.write("<td>"); 41 writer.write("<select name=\"renderer\">"); 42 43 writer.write("<option value=\"HorizontalMenuRenderer\">Horizontal Menu</option>"); 44 writer.write("<option value=\"BreadcrumbsRenderer\">Breadcrumbs</option>"); 45 46 writer.write("</select>"); 47 writer.write("</td>"); 48 writer.write("</tr>"); 49 64 writer.write("<tr>"); 65 writer.write("<td colspan=\"2\">"); 66 writer.write("<a HREF=\"javascript: document." + FACE_FORM + ".elements['" + FacesConstants.ACTION + "'].value = '" + FACE_ACTION_SAVE + "';document." + FACE_FORM + ".submit();\">Save</a>"); 67 writer.write("<a HREF=\"javascript: document." + FACE_FORM + ".elements['" + FacesConstants.ACTION + "'].value = '" + FACE_ACTION_CANCEL + "';document." + FACE_FORM + ".submit();\">Cancel</a>"); 68 writer.write("</td>"); 69 writer.write("</tr>"); 70 71 writer.write("</table>"); 72 73 writer.write("</form>"); 74 } 75 76 public void encodeChildren(FacesContext context,UIComponent component) throws IOException 77 { 78 } 79 80 public void encodeEnd(FacesContext context,UIComponent component) throws IOException 81 { 82 ResponseWriter writer = context.getResponseWriter(); 83 84 writer.write("</form>"); 85 } 86 } 87 | Popular Tags |