1 17 18 package org.objectweb.jac.aspects.gui.web; 19 20 import java.io.IOException ; 21 import java.io.PrintWriter ; 22 import java.util.Iterator ; 23 import javax.servlet.http.HttpServletResponse ; 24 import org.objectweb.jac.aspects.gui.Constants; 25 import org.objectweb.jac.aspects.gui.DialogView; 26 import org.objectweb.jac.aspects.gui.FieldEditor; 27 import org.objectweb.jac.aspects.gui.GuiAC; 28 import org.objectweb.jac.aspects.gui.View; 29 30 public class ObjectView extends Container implements DialogListener 31 { 32 public ObjectView() { 33 super(Constants.VERTICAL); 34 } 35 36 public void removeAllViews(boolean validate) { 37 Iterator it = components.iterator(); 38 while (it.hasNext()) { 39 Object component = it.next(); 40 if (component instanceof FieldEditor) { 41 context.removeEditor((FieldEditor)component); 42 } 43 } 44 super.removeAllViews(validate); 45 } 46 47 public void removeView(View component, boolean validate) 48 { 49 super.removeView(component,validate); 50 if (component instanceof FieldEditor) { 51 context.removeEditor((FieldEditor)component); 52 } 53 } 54 55 public void genHTML(PrintWriter out) throws IOException { 56 boolean showButtons = context.showButtons() && !(parentView instanceof DialogView); 59 if (showButtons) 60 out.println("<form action=\""+ 61 ((WebDisplay)context.getDisplay()).getServletName()+"\" "+ 62 "method=\"post\" accept-charset=\""+GuiAC.getEncoding()+"\" "+ 63 "enctype=\"multipart/form-data\">"); 64 65 super.genHTML(out); 66 if (showButtons) 67 out.println(" <input type=\"hidden\" name=\"source\" value=\""+getId()+"\">"); 68 if (context.hasEnabledEditor() && showButtons) { 69 out.println(" <div class=\"actions\">"); 70 out.println(" <input type=\"hidden\" name=\"event\" value=\"onValidate\">"); 71 out.println(" <input class=\"button\" type=\"submit\" name=\"onOK\" value=\""+GuiAC.getLabelOK()+"\">"); 72 out.println(" <input class=\"button\" type=\"submit\" name=\"onCancel\" value=\""+GuiAC.getLabelCancel()+"\">"); 73 79 out.println(" </div>"); 80 } 81 if (showButtons) 82 out.println("</form>"); 83 } 84 85 87 public void onOK(JacRequest request) { 88 onValidate(request); 89 ((WebDisplay)context.getDisplay()).refresh(); 90 } 91 92 public void onRefresh(JacRequest request) { 93 onValidate(request); 94 ((WebDisplay)context.getDisplay()).refresh(); 95 } 96 97 public void onValidate(JacRequest request) { 98 try { 99 WebDisplay.readValues(context,request,true); 100 setDescription(null); 101 } catch (Exception e) { 102 setDescription(e.getMessage()); 103 logger.error(this+".onValidate",e); 104 } 105 } 106 107 public void onCancel() { 108 ((WebDisplay)context.getDisplay()).refresh(); 109 } 110 111 public void restoreContext() { 112 } 113 114 public HttpServletResponse getResponse() { 115 return null; 116 } 117 118 public JacRequest getRequest() { 119 return null; 120 } 121 } 122 | Popular Tags |