| 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.HtmlInputHidden; |
| 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 | 33 | public class HtmlInputHiddenRenderer extends AbstractInputRenderer { |
| 35 | |
|
| 36 | |
public static final String COMPONENT_FAMILY = "javax.faces.Input"; |
| 37 | |
|
| 38 | |
public static final String RENDERER_TYPE = "javax.faces.Hidden"; |
| 39 | |
|
| 40 | 33 | private final IgnoreAttribute ignoreComponent = new IgnoreAttribute(); |
| 41 | |
{ |
| 42 | 33 | ignoreComponent.addAttributeName(JsfConstants.ID_ATTR); |
| 43 | 33 | ignoreComponent.addAttributeName(JsfConstants.VALUE_ATTR); |
| 44 | 33 | ignoreComponent.addAttributeName(JsfConstants.TYPE_ATTR); |
| 45 | 33 | ignoreComponent.addAttributeName(JsfConstants.NAME_ATTR); |
| 46 | 33 | } |
| 47 | |
|
| 48 | |
public void encodeEnd(FacesContext context, UIComponent component) |
| 49 | |
throws IOException { |
| 50 | 8 | assertNotNull(context, component); |
| 51 | 6 | if (!component.isRendered()) { |
| 52 | 1 | return; |
| 53 | |
} |
| 54 | 5 | encodeHtmlInputHiddenEnd(context, (HtmlInputHidden) component); |
| 55 | 5 | } |
| 56 | |
|
| 57 | |
protected void encodeHtmlInputHiddenEnd(FacesContext context, |
| 58 | |
HtmlInputHidden htmlInputHidden) throws IOException { |
| 59 | 5 | ResponseWriter writer = context.getResponseWriter(); |
| 60 | 5 | writer.startElement(JsfConstants.INPUT_ELEM, htmlInputHidden); |
| 61 | 5 | RendererUtil.renderAttribute(writer, JsfConstants.TYPE_ATTR, |
| 62 | |
JsfConstants.HIDDEN_VALUE); |
| 63 | 5 | RendererUtil.renderIdAttributeIfNecessary(writer, htmlInputHidden, |
| 64 | |
getIdForRender(context, htmlInputHidden)); |
| 65 | 5 | RendererUtil.renderAttribute(writer, JsfConstants.NAME_ATTR, |
| 66 | |
htmlInputHidden.getClientId(context)); |
| 67 | |
|
| 68 | 5 | String value = ValueHolderUtil.getValueForRender(context, |
| 69 | |
htmlInputHidden); |
| 70 | 5 | RendererUtil.renderAttribute(writer, JsfConstants.VALUE_ATTR, value); |
| 71 | 5 | renderRemainAttributes(htmlInputHidden, writer, ignoreComponent); |
| 72 | 5 | writer.endElement(JsfConstants.INPUT_ELEM); |
| 73 | 5 | } |
| 74 | |
|
| 75 | |
public void decode(FacesContext context, UIComponent component) { |
| 76 | 4 | assertNotNull(context, component); |
| 77 | 2 | decodeHtmlInputHidden(context, (HtmlInputHidden) component); |
| 78 | 2 | } |
| 79 | |
|
| 80 | |
protected void decodeHtmlInputHidden(FacesContext context, |
| 81 | |
HtmlInputHidden htmlInputHidden) { |
| 82 | 2 | getDecoder().decode(context, htmlInputHidden); |
| 83 | 2 | } |
| 84 | |
|
| 85 | |
} |