1 15 package org.apache.tapestry.form; 16 17 import java.io.IOException ; 18 19 import org.apache.hivemind.ApplicationRuntimeException; 20 import org.apache.tapestry.IActionListener; 21 import org.apache.tapestry.IForm; 22 import org.apache.tapestry.IMarkupWriter; 23 import org.apache.tapestry.IRequestCycle; 24 import org.apache.tapestry.listener.ListenerInvoker; 25 import org.apache.tapestry.services.DataSqueezer; 26 27 34 public abstract class Hidden extends AbstractFormComponent 35 { 36 39 protected void renderFormComponent(IMarkupWriter writer, IRequestCycle cycle) 40 { 41 IForm form = getForm(); 42 String externalValue = null; 43 44 if (getEncode()) 45 { 46 Object value = getValue(); 47 48 try 49 { 50 externalValue = getDataSqueezer().squeeze(value); 51 } 52 catch (IOException e) 53 { 54 throw new ApplicationRuntimeException(e.getMessage(), this, null, e); 55 } 56 } 57 else 58 externalValue = (String ) getBinding("value").getObject(String .class); 59 60 String id = getClientId(); 61 62 form.addHiddenValue(getName(), id, externalValue); 63 } 64 65 68 protected void rewindFormComponent(IMarkupWriter writer, IRequestCycle cycle) 69 { 70 String parameter = cycle.getParameter(getName()); 71 72 Object value = parameter; 73 74 if (getEncode()) 75 { 76 try 77 { 78 value = getDataSqueezer().unsqueeze(parameter); 79 } 80 catch (IOException ex) 81 { 82 throw new ApplicationRuntimeException(ex.getMessage(), this, null, ex); 83 } 84 } 85 86 89 setValue(value); 90 91 getListenerInvoker().invokeListener(getListener(), this, cycle); 92 } 93 94 95 public abstract DataSqueezer getDataSqueezer(); 96 97 public abstract Object getValue(); 98 99 public abstract void setValue(Object value); 100 101 public abstract IActionListener getListener(); 102 103 108 109 public abstract ListenerInvoker getListenerInvoker(); 110 111 116 public boolean isDisabled() 117 { 118 return false; 119 } 120 121 127 public abstract boolean getEncode(); 128 } | Popular Tags |