1 29 30 package nextapp.echo2.webcontainer.partialupdate; 31 32 import nextapp.echo2.app.Border; 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.BorderRender; 38 import nextapp.echo2.webrender.servermessage.DomUpdate; 39 40 44 public class BorderUpdate 45 implements PartialUpdateParticipant { 46 47 public static final String CSS_BORDER = "border"; 48 49 private String componentPropertyName; 50 private String cssAttributeName; 51 private String idSuffix; 52 53 62 public BorderUpdate(String componentPropertyName, String idSuffix, String cssAttributeName) { 63 super(); 64 this.componentPropertyName = componentPropertyName; 65 this.idSuffix = idSuffix; 66 this.cssAttributeName = cssAttributeName; 67 } 68 69 73 public boolean canRenderProperty(RenderContext rc, ServerComponentUpdate update) { 74 return true; 75 } 76 77 81 public void renderProperty(RenderContext rc, ServerComponentUpdate update) { 82 Border border = (Border) update.getParent().getRenderProperty(componentPropertyName); 83 String elementId = idSuffix == null ? ContainerInstance.getElementId(update.getParent()) 84 : ContainerInstance.getElementId(update.getParent()) + idSuffix; 85 if (border == null) { 86 DomUpdate.renderStyleUpdate(rc.getServerMessage(), elementId, cssAttributeName, ""); 87 } else { 88 DomUpdate.renderStyleUpdate(rc.getServerMessage(), elementId, cssAttributeName, 89 BorderRender.renderCssAttributeValue(border)); 90 } 91 } 92 } | Popular Tags |