es.pode.gestorFlujo.presentacion.objetosPendientes.Eliminar.ConfirmacionAceptarFormImpl.java Source code

Java tutorial

Introduction

Here is the source code for es.pode.gestorFlujo.presentacion.objetosPendientes.Eliminar.ConfirmacionAceptarFormImpl.java

Source

// license-header java merge-point
package es.pode.gestorFlujo.presentacion.objetosPendientes.Eliminar;

public class ConfirmacionAceptarFormImpl extends org.apache.struts.validator.ValidatorForm implements
        java.io.Serializable, es.pode.gestorFlujo.presentacion.objetosPendientes.Eliminar.EliminarODEsForm {
    private java.util.Collection titulos;
    private java.lang.Object[] titulosValueList;
    private java.lang.Object[] titulosLabelList;
    private java.lang.String idiomaBuscador;
    private java.lang.Object[] idiomaBuscadorValueList;
    private java.lang.Object[] idiomaBuscadorLabelList;

    public ConfirmacionAceptarFormImpl() {
    }

    /**
     * Resets the given <code>titulos</code>.
     */
    public void resetTitulos() {
        this.titulos = null;
    }

    public void setTitulos(java.util.Collection titulos) {
        this.titulos = titulos;
    }

    /**
     * 
     */
    public java.util.Collection getTitulos() {
        return this.titulos;
    }

    public void setTitulosAsArray(Object[] titulos) {
        this.titulos = (titulos == null) ? null : java.util.Arrays.asList(titulos);
    }

    /**
     * Returns this collection as an array, if the collection itself would be <code>null</code> this method
     * will also return <code>null</code>.
     *
     * @see es.pode.gestorFlujo.presentacion.objetosPendientes.Eliminar.ConfirmacionAceptarFormImpl#getTitulos
     */
    public java.lang.Object[] getTitulosAsArray() {
        return (titulos == null) ? null : titulos.toArray();
    }

    public java.lang.Object[] getTitulosBackingList() {
        java.lang.Object[] values = this.titulosValueList;
        java.lang.Object[] labels = this.titulosLabelList;

        if (values == null || values.length == 0) {
            return values;
        }

        if (labels == null || labels.length == 0) {
            labels = values;
        }

        final int length = java.lang.Math.min(labels.length, values.length);
        java.lang.Object[] backingList = new java.lang.Object[length];

        for (int i = 0; i < length; i++) {
            backingList[i] = new LabelValue(labels[i], values[i]);
        }

        return backingList;
    }

    public java.lang.Object[] getTitulosValueList() {
        return this.titulosValueList;
    }

    public void setTitulosValueList(java.lang.Object[] titulosValueList) {
        this.titulosValueList = titulosValueList;
    }

    public java.lang.Object[] getTitulosLabelList() {
        return this.titulosLabelList;
    }

    public void setTitulosLabelList(java.lang.Object[] titulosLabelList) {
        this.titulosLabelList = titulosLabelList;
    }

    public void setTitulosBackingList(java.util.Collection items, java.lang.String valueProperty,
            java.lang.String labelProperty) {
        if (valueProperty == null || labelProperty == null) {
            throw new IllegalArgumentException(
                    "ConfirmacionAceptarFormImpl.setTitulosBackingList requires non-null property arguments");
        }

        this.titulosValueList = null;
        this.titulosLabelList = null;

        if (items != null) {
            this.titulosValueList = new java.lang.Object[items.size()];
            this.titulosLabelList = new java.lang.Object[items.size()];

            try {
                int i = 0;
                for (java.util.Iterator iterator = items.iterator(); iterator.hasNext(); i++) {
                    final java.lang.Object item = iterator.next();

                    this.titulosValueList[i] = org.apache.commons.beanutils.PropertyUtils.getProperty(item,
                            valueProperty);
                    this.titulosLabelList[i] = org.apache.commons.beanutils.PropertyUtils.getProperty(item,
                            labelProperty);
                }
            } catch (Exception ex) {
                throw new java.lang.RuntimeException(
                        "ConfirmacionAceptarFormImpl.setTitulosBackingList encountered an exception", ex);
            }
        }
    }

    /**
     * Resets the given <code>idiomaBuscador</code>.
     */
    public void resetIdiomaBuscador() {
        this.idiomaBuscador = null;
    }

    public void setIdiomaBuscador(java.lang.String idiomaBuscador) {
        this.idiomaBuscador = idiomaBuscador;
    }

    /**
     * 
     */
    public java.lang.String getIdiomaBuscador() {
        return this.idiomaBuscador;
    }

    public java.lang.Object[] getIdiomaBuscadorBackingList() {
        java.lang.Object[] values = this.idiomaBuscadorValueList;
        java.lang.Object[] labels = this.idiomaBuscadorLabelList;

        if (values == null || values.length == 0) {
            return values;
        }

        if (labels == null || labels.length == 0) {
            labels = values;
        }

        final int length = java.lang.Math.min(labels.length, values.length);
        java.lang.Object[] backingList = new java.lang.Object[length];

        for (int i = 0; i < length; i++) {
            backingList[i] = new LabelValue(labels[i], values[i]);
        }

        return backingList;
    }

    public java.lang.Object[] getIdiomaBuscadorValueList() {
        return this.idiomaBuscadorValueList;
    }

    public void setIdiomaBuscadorValueList(java.lang.Object[] idiomaBuscadorValueList) {
        this.idiomaBuscadorValueList = idiomaBuscadorValueList;
    }

    public java.lang.Object[] getIdiomaBuscadorLabelList() {
        return this.idiomaBuscadorLabelList;
    }

    public void setIdiomaBuscadorLabelList(java.lang.Object[] idiomaBuscadorLabelList) {
        this.idiomaBuscadorLabelList = idiomaBuscadorLabelList;
    }

    public void setIdiomaBuscadorBackingList(java.util.Collection items, java.lang.String valueProperty,
            java.lang.String labelProperty) {
        if (valueProperty == null || labelProperty == null) {
            throw new IllegalArgumentException(
                    "ConfirmacionAceptarFormImpl.setIdiomaBuscadorBackingList requires non-null property arguments");
        }

        this.idiomaBuscadorValueList = null;
        this.idiomaBuscadorLabelList = null;

        if (items != null) {
            this.idiomaBuscadorValueList = new java.lang.Object[items.size()];
            this.idiomaBuscadorLabelList = new java.lang.Object[items.size()];

            try {
                int i = 0;
                for (java.util.Iterator iterator = items.iterator(); iterator.hasNext(); i++) {
                    final java.lang.Object item = iterator.next();

                    this.idiomaBuscadorValueList[i] = org.apache.commons.beanutils.PropertyUtils.getProperty(item,
                            valueProperty);
                    this.idiomaBuscadorLabelList[i] = org.apache.commons.beanutils.PropertyUtils.getProperty(item,
                            labelProperty);
                }
            } catch (Exception ex) {
                throw new java.lang.RuntimeException(
                        "ConfirmacionAceptarFormImpl.setIdiomaBuscadorBackingList encountered an exception", ex);
            }
        }
    }

    /**
     * @see org.apache.struts.validator.ValidatorForm#reset(org.apache.struts.action.ActionMapping,javax.servlet.http.HttpServletRequest)
     */
    public void reset(org.apache.struts.action.ActionMapping mapping,
            javax.servlet.http.HttpServletRequest request) {
        this.idiomaBuscador = null;
    }

    public java.lang.String toString() {
        org.apache.commons.lang.builder.ToStringBuilder builder = new org.apache.commons.lang.builder.ToStringBuilder(
                this);
        builder.append("titulos", this.titulos);
        builder.append("idiomaBuscador", this.idiomaBuscador);
        return builder.toString();
    }

    /**
     * Allows you to clean all values from this form. Objects will be set to <code>null</code>, numeric values will be
     * set to zero and boolean values will be set to <code>false</code>. Backinglists for selectable fields will
     * also be set to <code>null</code>.
     */
    public void clean() {
        this.titulos = null;
        this.titulosValueList = null;
        this.titulosLabelList = null;
        this.idiomaBuscador = null;
        this.idiomaBuscadorValueList = null;
        this.idiomaBuscadorLabelList = null;
    }

    /**
     * Override to provide population of current form with request parameters when validation fails.
     *
     * @see org.apache.struts.action.ActionForm#validate(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
     */
    public org.apache.struts.action.ActionErrors validate(org.apache.struts.action.ActionMapping mapping,
            javax.servlet.http.HttpServletRequest request) {
        final org.apache.struts.action.ActionErrors errors = super.validate(mapping, request);
        if (errors != null && !errors.isEmpty()) {
            // we populate the current form with only the request parameters
            Object currentForm = request.getSession().getAttribute("form");
            // if we can't get the 'form' from the session, try from the request
            if (currentForm == null) {
                currentForm = request.getAttribute("form");
            }
            if (currentForm != null) {
                final java.util.Map parameters = new java.util.HashMap();
                for (final java.util.Enumeration names = request.getParameterNames(); names.hasMoreElements();) {
                    final String name = String.valueOf(names.nextElement());
                    parameters.put(name, request.getParameter(name));
                }
                try {
                    org.apache.commons.beanutils.BeanUtils.populate(currentForm, parameters);
                } catch (java.lang.Exception populateException) {
                    // ignore if we have an exception here (we just don't populate).
                }
            }
        }
        return errors;
    }

    public final static class LabelValue {
        private java.lang.Object label = null;
        private java.lang.Object value = null;

        public LabelValue(Object label, java.lang.Object value) {
            this.label = label;
            this.value = value;
        }

        public java.lang.Object getLabel() {
            return this.label;
        }

        public java.lang.Object getValue() {
            return this.value;
        }

        public java.lang.String toString() {
            return label + "=" + value;
        }
    }
}