| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 
 | package com.anam.amid.administration.forms;
 
import java.util.List;
 
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
 
 
import org.apache.commons.validator.Validator;
import org.apache.commons.validator.ValidatorException;
import org.apache.commons.validator.ValidatorResults;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.validator.Resources;
import org.springframework.util.StringUtils;
 
import com.anam.amid.general.forms.PaginationForm;
 
/**
 * 
 * @author 
 * @version 1.0 
 */
public class AdministrationForm extends PaginationForm {
 
	/**
         * 
         */
	private static final long serialVersionUID = 3L;
 
	private Integer id;
 
	private String login;	
 
	private String password1;
 
	private String password2;
 
	private String nom;
 
	private String prenom;
 
	private List listeProfils;
	private String profilSelected;
 
	private boolean actif;
 
	private boolean enregistrementOk;	
 
	private boolean modification;	
 
	private boolean checkAll;
 
	private boolean fromListe;
 
	private String popupNotModalHandler;
 
 
	/**
         * Override the reset method from Struts for this custom form
         * 
         * @param mapping
         * @param request
         */
	public void reset(ActionMapping mapping, HttpServletRequest request) {
 
		super.reset(mapping,request);	
		checkAll=false;
	}
 
	/**
         * Default constructor
         */
	public AdministrationForm() {
		super();	
	}
 
	public void init()
	{
		super.init();
		id=null;
		login=null;
		password1=null;
		password2=null;
		nom=null;
		prenom=null;
		listeProfils=null;
		profilSelected=null;
		actif=false;
		enregistrementOk=false;
		modification=false;
		checkAll=false;
		popupNotModalHandler=null;
		fromListe=false;
	}
 
	public Integer getId() {
		return id;
	}
 
	public void setId(Integer id) {
		this.id = id;
	}
 
	public boolean isActif() {
		return actif;
	}
 
	public void setActif(boolean actif) {
		this.actif = actif;
	}
 
	public List getListeProfils() {
		return listeProfils;
	}
 
	public void setListeProfils(List listeProfils) {
		this.listeProfils = listeProfils;
	}
 
	public String getLogin() {
		return login;
	}
 
	public void setLogin(String login) {
		this.login = login;
	}
 
	public String getNom() {
		return nom;
	}
 
	public void setNom(String nom) {
		this.nom = nom;
	}
 
	public String getPassword1() {
		return password1;
	}
 
	public void setPassword1(String password1) {
		this.password1 = password1;
	}
 
	public String getPassword2() {
		return password2;
	}
 
	public void setPassword2(String password2) {
		this.password2 = password2;
	}
 
	public String getPrenom() {
		return prenom;
	}
 
	public void setPrenom(String prenom) {
		this.prenom = prenom;
	}
 
	public String getProfilSelected() {
		return profilSelected;
	}
 
	public void setProfilSelected(String profilSelected) {
		this.profilSelected = profilSelected;
	}
 
	public boolean isEnregistrementOk() {
		return enregistrementOk;
	}
 
	public void setEnregistrementOk(boolean enregistrementOk) {
		this.enregistrementOk = enregistrementOk;
	}
 
	public boolean isModification() {
		return modification;
	}
 
	public void setModification(boolean modification) {
		this.modification = modification;
	}
	public boolean isCheckAll() {
		return checkAll;
	}
 
	public void setCheckAll(boolean checkAll) {
		this.checkAll = checkAll;
	}
 
	public String getPopupNotModalHandler() {
		return popupNotModalHandler;
	}
	public void setPopupNotModalHandler(String popupNotModalHandler) {
		this.popupNotModalHandler = popupNotModalHandler;
	}
 
	public boolean isFromListe() {
		return fromListe;
	}
 
	public void setFromListe(boolean fromListe) {
		this.fromListe = fromListe;
	}
 
	/*
	 * PARTIE VALIDATION
	 */
 
	/**
     * The results returned from the validation performed
     * by the <code>Validator</code>.
     */
    protected ValidatorResults validatorResults = null;
 
    /**
     * Used to indicate the current page of a multi-page form.
     */
    protected int page;
 
 
	public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
 
		ActionErrors errors = new ActionErrors();
 
    	if ( StringUtils.hasLength(request.getParameter("dispatch")) && request.getParameter("dispatch").equalsIgnoreCase("onEnregistrer")){ 
        ServletContext application = getServlet().getServletContext();
 
        String validationKey = getValidationKey(mapping, request);
 
        Validator validator = Resources.initValidator(validationKey,
                             this,
                             application, request,
                             errors, page);
 
        try {
            validatorResults = validator.validate();
        } catch (ValidatorException e) {
 
        }
 
    	}
    	return errors;
 
	}
 
	 /**
     * Returns the Validation key.
     *
     * @param mapping The mapping used to select this instance
     * @param request The servlet request we are processing
     * @return validation key - the form element's name in this case
     */
    public String getValidationKey(ActionMapping mapping,
                                   HttpServletRequest request) {
 
        return mapping.getAttribute();
    }
 
} | 
Partager