1 25 26 package org.snipsnap.render.macro; 27 28 import org.snipsnap.render.macro.parameter.SnipMacroParameter; 29 import org.snipsnap.snip.SnipLink; 30 import org.radeox.util.i18n.ResourceManager; 31 32 import java.io.IOException ; 33 import java.io.Writer ; 34 import java.util.ResourceBundle ; 35 36 43 44 public class FieldMacro extends SnipMacro { 45 public String getName() { 46 return "field"; 47 } 48 49 public String getDescription() { 50 return ResourceManager.getString("i18n.messages", "macro.field.description"); 51 } 52 53 public String [] getParamDescription() { 54 return ResourceManager.getString("i18n.messages", "macro.field.params").split(";"); 55 } 56 57 60 public void execute(Writer writer, SnipMacroParameter params) 61 throws IllegalArgumentException , IOException { 62 63 if (params.getLength() > 0) { 64 writer.write("<form class=\"form\" action=\""); 65 if (params.getLength() >= 3) { 66 SnipLink.appendUrl(writer, params.get("2")); 67 } else { 68 SnipLink.appendUrl(writer, params.getSnipRenderContext().getSnip().getName()); 69 } 70 writer.write("\" method=\"get\">"); 71 writer.write("<input size=\"18\" name=\""); 72 writer.write(params.get("0")); 73 writer.write("\""); 74 if (params.getLength() >= 2) { 75 writer.write(" value=\""); 76 writer.write(params.get("1")); 77 writer.write("\""); 78 } 79 writer.write("/>"); 80 if (params.getLength() >= 4) { 81 writer.write(" <input type=\"submit\" name=\"submit\" value=\""); 82 writer.write(params.get("3")); 83 writer.write("\"/>"); 84 } 85 writer.write("</form>"); 86 return; 87 } else { 88 throw new IllegalArgumentException ("Number of arguments does not match"); 89 } 90 } 91 } | Popular Tags |