// Copyright 2008 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.tapestry5.integration.app1.pages;

import org.apache.tapestry5.ValueEncoder;
import org.apache.tapestry5.annotations.InjectComponent;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.beaneditor.Validate;
import org.apache.tapestry5.corelib.components.Submit;
import org.apache.tapestry5.internal.services.StringValueEncoder;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class DisabledFields
{
    private String stringValue;

    private boolean flag;

    private Date date;

    private List<String> values;

    void onPrepare()
    {
        if (values == null)
        {
            values = new ArrayList<String>();
        }
    }

    @InjectComponent
    @Property
    private Submit submit;

    @Validate("required")
    public String getStringValue()
    {
        return stringValue;
    }


    public void setStringValue(String stringValue)
    {
        this.stringValue = stringValue;
    }

    public boolean isFlag()
    {
        return flag;
    }

    public void setFlag(boolean flag)
    {
        this.flag = flag;
    }

    public Date getDate()
    {
        return date;
    }

    public void setDate(Date date)
    {
        this.date = date;
    }

    public List<String> getValues()
    {
        return values;
    }

    public void setValues(List<String> values)
    {
        this.values = values;
    }

    public ValueEncoder getEncoder()
    {
        return new StringValueEncoder();
    }

    public Object getRadioGroupValue()
    {
        return null;
    }

    public void setRadioGroupValue(String value)
    {
        throw new IllegalStateException("This should not happen");
    }
}
