Package org.apache.tapestry.form

Examples of org.apache.tapestry.form.IPropertySelectionModel


        if (selectedList == null)
            throw Tapestry.createRequiredParameterException(this,
                    "selectedList");

        IPropertySelectionModel model = getModel();

        if (model == null)
            throw Tapestry.createRequiredParameterException(this, "model");

        IMultiplePropertySelectionRenderer renderer = getRenderer();

        // Start rendering
        renderer.beginRender(this, writer, cycle);

        int count = model.getOptionCount();

        for(int i = 0; i < count; i++)
        {
            Object option = model.getOption(i);

            // Try to find the option in the list and if yes, then it is
            // checked.
            boolean optionSelected = selectedList.contains(option);
View Full Code Here


    protected void rewindFormComponent(IMarkupWriter writer, IRequestCycle cycle)
    {
        // get all the values
        String[] optionValues = cycle.getParameters(getName());

        IPropertySelectionModel model = getModel();

        List selectedList = new ArrayList(getModel().getOptionCount());

        // Nothing was selected
        if (optionValues != null)
        {
            // Go through the array and translate and put back in the list
            for(int i = 0; i < optionValues.length; i++)
            {
                // Translate the new value
                Object selectedValue = model.translateValue(optionValues[i]);

                // Add this element in the list back
                selectedList.add(selectedValue);
            }
        }
View Full Code Here

        _availableWriter.println();

        // Each value specified in the model will go into either the selected or available
        // lists.

        IPropertySelectionModel model = getModel();

        int count = model.getOptionCount();
        for (int i = 0; i < count; i++)
        {
            IMarkupWriter w = _availableWriter;

            Object optionValue = model.getOption(i);

            if (selectedSet.contains(optionValue))
                w = _selectedWriter;

            w.begin("option");
            w.attribute("value", model.getValue(i));
            w.print(model.getLabel(i));
            w.end(); // <option>
            w.println();
        }

        // Close the <select> tags
View Full Code Here

        if (count == 0)
            return;

        List selected = new ArrayList(count);
        IPropertySelectionModel model = getModel();

        for (int i = 0; i < count; i++)
        {
            String value = values[i];
            Object option = model.translateValue(value);

            selected.add(option);
        }

        setSelected(selected);
View Full Code Here

        List selectedList = (List) getSelectedListBinding().getObject("selectedList", List.class);

        if (selectedList == null)
            throw Tapestry.createRequiredParameterException(this, "selectedList");

        IPropertySelectionModel model = getModel();

        if (model == null)
            throw Tapestry.createRequiredParameterException(this, "model");

        // Handle the form processing first.
        if (rewinding)
        {
            // If disabled, ignore anything that comes up from the client.

            if (isDisabled())
                return;

            // get all the values
            String[] optionValues = cycle.getRequestContext().getParameters(name);

            // Clear the list

            selectedList.clear();

            // Nothing was selected
            if (optionValues != null)
            {

                // Go through the array and translate and put back in the list
                for (int i = 0; i < optionValues.length; i++)
                {
                    // Translate the new value
                    Object selectedValue = model.translateValue(optionValues[i]);

                    // Add this element in the list back
                    selectedList.add(selectedValue);
                }
            }

            return;
        }

        IMultiplePropertySelectionRenderer renderer = getRenderer();

        // Start rendering
        renderer.beginRender(this, writer, cycle);

        int count = model.getOptionCount();

        for (int i = 0; i < count; i++)
        {
            Object option = model.getOption(i);

            // Try to find the option in the list and if yes, then it is checked.
            boolean optionSelected = selectedList.contains(option);

            renderer.renderOption(this, writer, cycle, model, option, i, optionSelected);
View Full Code Here

public abstract class SelectionField extends AbstractPostfield
{
    protected void rewind(IRequestCycle cycle)
    {
        String optionValue = cycle.getRequestContext().getParameter(getName());
        IPropertySelectionModel model = getModel();
        Object value = (optionValue == null) ? null : model.translateValue(optionValue);

        updateValue(value);
    }
View Full Code Here

    {
        boolean render = !cycle.isRewinding();

        if (render)
        {
            IPropertySelectionModel model = getModel();

            writer.begin("select");

            writer.attribute("name", getName());

            renderInformalParameters(writer, cycle);

            writer.println();

            int count = model.getOptionCount();

            for (int i = 0; i < count; i++)
            {

                writer.begin("option");
                writer.attribute("value", model.getValue(i));

                writer.print(model.getLabel(i));

                writer.end();
                writer.println();
            }
View Full Code Here

public abstract class SelectionField extends AbstractPostfield
{
    protected void rewind(IRequestCycle cycle)
    {
        String optionValue = cycle.getRequestContext().getParameter(getName());
        IPropertySelectionModel model = getModel();
        Object value = (optionValue == null) ? null : model.translateValue(optionValue);

        updateValue(value);
    }
View Full Code Here

        List selectedList = (List) getSelectedListBinding().getObject("selectedList", List.class);

        if (selectedList == null)
            throw Tapestry.createRequiredParameterException(this, "selectedList");

        IPropertySelectionModel model = getModel();

        if (model == null)
            throw Tapestry.createRequiredParameterException(this, "model");

        // Handle the form processing first.
        if (rewinding)
        {
            // If disabled, ignore anything that comes up from the client.

            if (isDisabled())
                return;

            // get all the values
            String[] optionValues = cycle.getRequestContext().getParameters(name);

            // Clear the list

            selectedList.clear();

            // Nothing was selected
            if (optionValues != null)
            {

                // Go through the array and translate and put back in the list
                for (int i = 0; i < optionValues.length; i++)
                {
                    // Translate the new value
                    Object selectedValue = model.translateValue(optionValues[i]);

                    // Add this element in the list back
                    selectedList.add(selectedValue);
                }
            }

            return;
        }

        IMultiplePropertySelectionRenderer renderer = getRenderer();

        // Start rendering
        renderer.beginRender(this, writer, cycle);

        int count = model.getOptionCount();

        for (int i = 0; i < count; i++)
        {
            Object option = model.getOption(i);

            // Try to find the option in the list and if yes, then it is checked.
            boolean optionSelected = selectedList.contains(option);

            renderer.renderOption(this, writer, cycle, model, option, i, optionSelected);
View Full Code Here

    {
        boolean render = !cycle.isRewinding();

        if (render)
        {
            IPropertySelectionModel model = getModel();

            writer.begin("select");

            writer.attribute("name", getName());

            renderInformalParameters(writer, cycle);

            writer.println();

            int count = model.getOptionCount();

            for (int i = 0; i < count; i++)
            {

                writer.begin("option");
                writer.attribute("value", model.getValue(i));

                writer.print(model.getLabel(i));

                writer.end();
                writer.println();
            }
View Full Code Here

TOP

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

Copyright © 2018 www.massapicom. 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.