main.MainFormImpl.java Source code

Java tutorial

Introduction

Here is the source code for main.MainFormImpl.java

Source

// license-header java merge-point
//
// Attention: Generated code! Do not modify by hand!
// Generated by: MainFormImpl.java.vsl in andromda-bpm4struts-cartridge-coppetec.
//
package main;

public class MainFormImpl extends br.mdarte.exemplo.academico.accessControl.LoginFormImpl
        implements java.io.Serializable {

    public MainFormImpl() {
    }

    /**
     * @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) {
    }

    /**
     * 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() {
    }

    /**
     * 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 (Exception exception) {
                    // ignore if we have an exception here (we just don't populate).
                }
            }
        }
        return errors;
    }

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

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

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

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

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

    public boolean isFieldVisibleInOperationMode(String field, java.util.Collection modosOperacao) {
        return true;
    }

    public String getOperationModeKey() {
        return "";
    }
}