1 29 30 package nextapp.echo2.webcontainer.partialupdate; 31 32 import nextapp.echo2.app.Insets; 33 import nextapp.echo2.app.update.ServerComponentUpdate; 34 import nextapp.echo2.webcontainer.ContainerInstance; 35 import nextapp.echo2.webcontainer.PartialUpdateParticipant; 36 import nextapp.echo2.webcontainer.RenderContext; 37 import nextapp.echo2.webcontainer.propertyrender.InsetsRender; 38 import nextapp.echo2.webrender.servermessage.DomUpdate; 39 40 44 public class InsetsUpdate 45 implements PartialUpdateParticipant { 46 47 public static final String CSS_PADDING = "padding"; 48 public static final String CSS_MARGIN = "margin"; 49 50 private String componentPropertyName; 51 private String cssAttributeName; 52 private String idSuffix; 53 54 63 public InsetsUpdate(String componentPropertyName, String idSuffix, String cssAttributeName) { 64 super(); 65 this.componentPropertyName = componentPropertyName; 66 this.idSuffix = idSuffix; 67 this.cssAttributeName = cssAttributeName; 68 } 69 70 74 public boolean canRenderProperty(RenderContext rc, ServerComponentUpdate update) { 75 return true; 76 } 77 78 82 public void renderProperty(RenderContext rc, ServerComponentUpdate update) { 83 Insets insets = (Insets) update.getParent().getRenderProperty(componentPropertyName); 84 String elementId = idSuffix == null ? ContainerInstance.getElementId(update.getParent()) 85 : ContainerInstance.getElementId(update.getParent()) + idSuffix; 86 if (insets == null) { 87 DomUpdate.renderStyleUpdate(rc.getServerMessage(), elementId, cssAttributeName, ""); 88 } else { 89 DomUpdate.renderStyleUpdate(rc.getServerMessage(), elementId, cssAttributeName, 90 InsetsRender.renderCssAttributeValue(insets)); 91 } 92 } 93 } | Popular Tags |