1 29 30 package nextapp.echo2.webcontainer.syncpeer; 31 32 import org.w3c.dom.Element ; 33 import org.w3c.dom.Node ; 34 35 import nextapp.echo2.app.Component; 36 import nextapp.echo2.app.TextArea; 37 import nextapp.echo2.app.update.ServerComponentUpdate; 38 import nextapp.echo2.webcontainer.ContainerInstance; 39 import nextapp.echo2.webcontainer.RenderContext; 40 import nextapp.echo2.webrender.ClientProperties; 41 import nextapp.echo2.webrender.ServerMessage; 42 import nextapp.echo2.webrender.output.CssStyle; 43 44 50 public class TextAreaPeer extends TextComponentPeer { 51 52 56 public void renderHtml(RenderContext rc, ServerComponentUpdate addUpdate, Node parentNode, Component component) { 57 TextArea textArea = (TextArea) component; 58 String elementId = ContainerInstance.getElementId(component); 59 60 ServerMessage serverMessage = rc.getServerMessage(); 61 serverMessage.addLibrary(TEXT_COMPONENT_SERVICE.getId()); 62 63 Element textAreaElement = parentNode.getOwnerDocument().createElement("textarea"); 64 textAreaElement.setAttribute("id", elementId); 65 66 if (textArea.isFocusTraversalParticipant()) { 67 textAreaElement.setAttribute("tabindex", Integer.toString(textArea.getFocusTraversalIndex())); 68 } else { 69 textAreaElement.setAttribute("tabindex", "-1"); 70 } 71 72 String toolTipText = (String ) textArea.getRenderProperty(TextArea.PROPERTY_TOOL_TIP_TEXT); 73 if (toolTipText != null) { 74 textAreaElement.setAttribute("title", toolTipText); 75 } 76 77 String value = textArea.getText(); 78 if (value != null) { 79 if (!rc.getContainerInstance().getClientProperties().getBoolean( 80 ClientProperties.QUIRK_TEXTAREA_CONTENT)) { 81 textAreaElement.appendChild(rc.getServerMessage().getDocument().createTextNode(value)); 82 } 83 } 84 85 CssStyle cssStyle = createBaseCssStyle(rc, textArea); 86 if (cssStyle.hasAttributes()) { 87 textAreaElement.setAttribute("style", cssStyle.renderInline()); 88 } 89 90 parentNode.appendChild(textAreaElement); 91 92 renderInitDirective(rc, textArea); 93 } 94 } 95 | Popular Tags |