| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.seasar.teeda.core.render.html; |
| 17 | |
|
| 18 | |
import java.io.IOException; |
| 19 | |
|
| 20 | |
import javax.faces.component.UIComponent; |
| 21 | |
import javax.faces.component.html.HtmlInputTextarea; |
| 22 | |
import javax.faces.context.FacesContext; |
| 23 | |
import javax.faces.context.ResponseWriter; |
| 24 | |
import javax.faces.internal.IgnoreAttribute; |
| 25 | |
|
| 26 | |
import org.seasar.teeda.core.JsfConstants; |
| 27 | |
import org.seasar.teeda.core.render.AbstractInputRenderer; |
| 28 | |
import org.seasar.teeda.core.util.RendererUtil; |
| 29 | |
import org.seasar.teeda.core.util.ValueHolderUtil; |
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | 34 | public class HtmlInputTextareaRenderer extends AbstractInputRenderer { |
| 35 | |
|
| 36 | |
public static final String COMPONENT_FAMILY = "javax.faces.Input"; |
| 37 | |
|
| 38 | |
public static final String RENDERER_TYPE = "javax.faces.Textarea"; |
| 39 | |
|
| 40 | 34 | private final IgnoreAttribute ignoreAttribute = new IgnoreAttribute(); |
| 41 | |
{ |
| 42 | 34 | addIgnoreAttributeName(JsfConstants.ID_ATTR); |
| 43 | 34 | addIgnoreAttributeName(JsfConstants.VALUE_ATTR); |
| 44 | 34 | addIgnoreAttributeName(JsfConstants.NAME_ATTR); |
| 45 | 34 | addIgnoreAttributeName(JsfConstants.STYLE_CLASS_ATTR); |
| 46 | 34 | } |
| 47 | |
|
| 48 | |
public void encodeEnd(FacesContext context, UIComponent component) |
| 49 | |
throws IOException { |
| 50 | 9 | assertNotNull(context, component); |
| 51 | 7 | if (!component.isRendered()) { |
| 52 | 1 | return; |
| 53 | |
} |
| 54 | 6 | encodeHtmlInputTextareaEnd(context, (HtmlInputTextarea) component); |
| 55 | 6 | } |
| 56 | |
|
| 57 | |
protected void encodeHtmlInputTextareaEnd(FacesContext context, |
| 58 | |
HtmlInputTextarea htmlInputTextarea) throws IOException { |
| 59 | 6 | ResponseWriter writer = context.getResponseWriter(); |
| 60 | 6 | writer.startElement(JsfConstants.TEXTAREA_ELEM, htmlInputTextarea); |
| 61 | 6 | RendererUtil.renderIdAttributeIfNecessary(writer, htmlInputTextarea, |
| 62 | |
getIdForRender(context, htmlInputTextarea)); |
| 63 | 6 | RendererUtil.renderAttribute(writer, JsfConstants.NAME_ATTR, |
| 64 | |
htmlInputTextarea.getClientId(context)); |
| 65 | 6 | renderStyleClass(context, htmlInputTextarea, writer); |
| 66 | 6 | renderRemainAttributes(htmlInputTextarea, writer, ignoreAttribute); |
| 67 | |
|
| 68 | |
|
| 69 | 6 | String value = ValueHolderUtil.getValueForRender(context, |
| 70 | |
htmlInputTextarea); |
| 71 | 6 | writer.writeText(value, null); |
| 72 | 6 | writer.endElement(JsfConstants.TEXTAREA_ELEM); |
| 73 | 6 | } |
| 74 | |
|
| 75 | |
protected void renderStyleClass(final FacesContext context, |
| 76 | |
final HtmlInputTextarea htmlInputTextarea, |
| 77 | |
final ResponseWriter writer) throws IOException { |
| 78 | 6 | final String styleClass = htmlInputTextarea.getStyleClass(); |
| 79 | 6 | RendererUtil.renderAttribute(writer, JsfConstants.STYLE_CLASS_ATTR, |
| 80 | |
styleClass); |
| 81 | 6 | } |
| 82 | |
|
| 83 | |
public void decode(FacesContext context, UIComponent component) { |
| 84 | 4 | assertNotNull(context, component); |
| 85 | 2 | decodeHtmlInputText(context, (HtmlInputTextarea) component); |
| 86 | 2 | } |
| 87 | |
|
| 88 | |
protected void decodeHtmlInputText(FacesContext context, |
| 89 | |
HtmlInputTextarea htmlInputTextarea) { |
| 90 | 2 | getDecoder().decode(context, htmlInputTextarea); |
| 91 | 2 | } |
| 92 | |
|
| 93 | |
public void addIgnoreAttributeName(final String name) { |
| 94 | 136 | ignoreAttribute.addAttributeName(name); |
| 95 | 136 | } |
| 96 | |
|
| 97 | |
} |