001    /*
002     * Apache License
003     * Version 2.0, January 2004
004     * http://www.apache.org/licenses/
005     *
006     * Copyright 2008 by chenillekit.org
007     *
008     * Licensed under the Apache License, Version 2.0 (the "License");
009     * you may not use this file except in compliance with the License.
010     * You may obtain a copy of the License at
011     *
012     * http://www.apache.org/licenses/LICENSE-2.0
013     */
014    
015    package org.chenillekit.tapestry.core.components;
016    
017    import org.apache.tapestry5.MarkupWriter;
018    import org.apache.tapestry5.corelib.base.AbstractTextField;
019    
020    /**
021     * place a hidden field into a form.
022     *
023     * @version $Id: Hidden.java 317 2008-11-11 16:42:38Z homburgs $
024     */
025    public class Hidden extends AbstractTextField
026    {
027        /**
028         * Invoked from {@link #begin(org.apache.tapestry5.MarkupWriter)} to write out the element and attributes (typically, <input>). The
029         * {@linkplain org.apache.tapestry5.corelib.base.AbstractField#getControlName() controlName} and {@linkplain org.apache.tapestry5.corelib.base.AbstractField#getClientId() clientId}
030         * properties will already have been set or updated.
031         * <p/>
032         * Generally, the subclass will invoke {@link org.apache.tapestry5.MarkupWriter#element(String, Object[])}, and will be responsible for
033         * including an {@link org.apache.tapestry5.annotations.AfterRender} phase method to invoke {@link org.apache.tapestry5.MarkupWriter#end()}.
034         *
035         * @param writer markup write to send output to
036         * @param value  the value (either obtained and translated from the value parameter, or obtained from the tracker)
037         */
038        @Override
039        protected void writeFieldTag(MarkupWriter writer, String value)
040        {
041            writer.element("input",
042    
043                           "type", "hidden",
044    
045                           "id", getClientId(),
046    
047                           "name", getControlName(),
048    
049                           "value", value);
050        }
051    
052        final void afterRender(MarkupWriter writer)
053        {
054            writer.end(); // input
055        }
056    }