Package org.apache.tapestry.form

Source Code of org.apache.tapestry.form.Hidden

/* $$ Clover has instrumented this file $$ */// Copyright 2004 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package org.apache.tapestry.form;

import java.io.IOException;

import org.apache.hivemind.ApplicationRuntimeException;
import org.apache.tapestry.IActionListener;
import org.apache.tapestry.IBinding;
import org.apache.tapestry.IForm;
import org.apache.tapestry.IMarkupWriter;
import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.services.DataSqueezer;

/**
*  Implements a hidden field within a {@link Form}.
*
*  [<a href="../../../../../ComponentReference/Hidden.html">Component Reference</a>]
*
@author Howard Lewis Ship
*
**/

public abstract class Hidden extends AbstractFormComponent
{public static com.cortexeb.tools.clover.d __CLOVER_132_0 = com.cortexeb.tools.clover.aq.getRecorder(new char[] {67,58,92,119,111,114,107,115,112,97,99,101,92,106,97,107,97,114,116,97,45,116,97,112,101,115,116,114,121,92,102,114,97,109,101,119,111,114,107,92,116,97,114,103,101,116,92,99,108,111,118,101,114,45,100,98},1096998272901L);

    protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
    {try { __CLOVER_132_0.M[721]++;
        __CLOVER_132_0.S[3234]++;IForm form = getForm(cycle);
        __CLOVER_132_0.S[3235]++;boolean formRewound = form.isRewinding();

        __CLOVER_132_0.S[3236]++;String name = form.getElementId(this);

        // If the form containing the Hidden isn't rewound, then render.

        __CLOVER_132_0.S[3237]++;if ((((!formRewound) && (++__CLOVER_132_0.CT[593] != 0)) || (++__CLOVER_132_0.CF[593] == 0))){
        {
            // Optimiziation: if the page is rewinding (some other action or
            // form was submitted), then don't bother rendering.

            __CLOVER_132_0.S[3238]++;if ((((cycle.isRewinding()) && (++__CLOVER_132_0.CT[594] != 0)) || (++__CLOVER_132_0.CF[594] == 0))){
                __CLOVER_132_0.S[3239]++;return;}

            __CLOVER_132_0.S[3240]++;String externalValue = null;

            __CLOVER_132_0.S[3241]++;if ((((getEncode()) && (++__CLOVER_132_0.CT[595] != 0)) || (++__CLOVER_132_0.CF[595] == 0))){
            {
                __CLOVER_132_0.S[3242]++;Object value = getValueBinding().getObject();

                __CLOVER_132_0.S[3243]++;try
                {
                    __CLOVER_132_0.S[3244]++;externalValue = getDataSqueezer().squeeze(value);
                }
                catch (IOException ex)
                {
                    __CLOVER_132_0.S[3245]++;throw new ApplicationRuntimeException(ex.getMessage(), this, null, ex);
                }
            }}
            else{
                __CLOVER_132_0.S[3246]++;externalValue = (String) getValueBinding().getObject("value", String.class);}

            __CLOVER_132_0.S[3247]++;String id = getElementId();
            //if we would like to test the IForm.addHiddenValue(name, externalValue) method with
            //Hidden JUnit test the following code must be default. But from the performance issue
            //I don't use the id parameter clauses. 
/*      if(id == null || id.length() == 0){
        form.addHiddenValue(name, externalValue);
            }else{
        form.addHiddenValue(name, id, externalValue);
            }
*/
      __CLOVER_132_0.S[3248]++;form.addHiddenValue(name, id, externalValue);
           

            __CLOVER_132_0.S[3249]++;return;
        }}

        __CLOVER_132_0.S[3250]++;String externalValue = cycle.getRequestContext().getParameter(name);
        __CLOVER_132_0.S[3251]++;Object value = null;

        __CLOVER_132_0.S[3252]++;if ((((getEncode()) && (++__CLOVER_132_0.CT[596] != 0)) || (++__CLOVER_132_0.CF[596] == 0))){
        {
            __CLOVER_132_0.S[3253]++;try
            {
                __CLOVER_132_0.S[3254]++;value = getDataSqueezer().unsqueeze(externalValue);
            }
            catch (IOException ex)
            {
                __CLOVER_132_0.S[3255]++;throw new ApplicationRuntimeException(ex.getMessage(), this, null, ex);
            }
        }}
        else{
            __CLOVER_132_0.S[3256]++;value = externalValue;}

        // A listener is not always necessary ... it's easy to code
        // the synchronization as a side-effect of the accessor method.

        __CLOVER_132_0.S[3257]++;getValueBinding().setObject(value);

        __CLOVER_132_0.S[3258]++;IActionListener listener = getListener();

        __CLOVER_132_0.S[3259]++;if ((((listener != null) && (++__CLOVER_132_0.CT[597] != 0)) || (++__CLOVER_132_0.CF[597] == 0))){
            __CLOVER_132_0.S[3260]++;listener.actionTriggered(this, cycle);}
    } finally { }}

  public String getElementId(){try { __CLOVER_132_0.M[722]++;
    __CLOVER_132_0.S[3261]++;String value = null;
    __CLOVER_132_0.S[3262]++;IBinding idBinding = getIdBinding();
    __CLOVER_132_0.S[3263]++;if((((idBinding != null) && (++__CLOVER_132_0.CT[598] != 0)) || (++__CLOVER_132_0.CF[598] == 0))){{
      __CLOVER_132_0.S[3264]++;value = idBinding.getString();
    }}
    __CLOVER_132_0.S[3265]++;return value;
  } finally { }}

    /** @since 2.2 **/

    private DataSqueezer getDataSqueezer()
    {try { __CLOVER_132_0.M[723]++;
        __CLOVER_132_0.S[3266]++;return getPage().getEngine().getDataSqueezer();
    } finally { }}

    public abstract IActionListener getListener();

    public abstract IBinding getValueBinding();
  public abstract IBinding getIdBinding();

    /**
     *
     *  Returns false.  Hidden components are never disabled.
     *
     *  @since 2.2
     *
     **/

    public boolean isDisabled()
    {try { __CLOVER_132_0.M[724]++;
        __CLOVER_132_0.S[3267]++;return false;
    } finally { }}

    /**
     *
     *  Returns true if the compent encodes object values using a
     *  {@link org.apache.tapestry.util.io.DataSqueezerImpl}, false
     *  if values are always Strings.
     *
     *  @since 2.2
     *
     **/

    public abstract boolean getEncode();

    public abstract void setEncode(boolean encode);

    /**
     * Sets the encode parameter property to its default, true.
     *
     * @since 3.0
     */
    protected void finishLoad()
    {try { __CLOVER_132_0.M[725]++;
        __CLOVER_132_0.S[3268]++;setEncode(true);
    } finally { }}
}
TOP

Related Classes of org.apache.tapestry.form.Hidden

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.