1 2 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 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920
| package com.ancv.guide.form;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.validator.GenericValidator;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import javax.servlet.http.HttpServletRequest;
/**
* Description : Classe générique des pages de recherche
*
* Versions :
*
* 1.0 : Init
* 1.1 : pour le CV
*
* @author msoler
* @author flaugier
* @author ascavino
* @version 1.0
*/
public class SearchForm extends BaseForm
{
/**
* Le log
* @since 1.0
*/
private Log log = LogFactory.getLog( SearchForm.class.getName( ) );
/**
* champ pour la gestion de la recherche par domaine dans la page détail
* @since 1.1
*/
private String fCdDoma;
/**
* champ pour la gestion du tri de la recherche
* @since 1.1
*/
private String fCdPos;
/**
* champ pour la gestion du tri de la recherche
* @since 1.0
*/
private String fCdActv;
/**
* champ pour la gestion du tri de la recherche
* @since 1.0
*/
private String fLbOrderBy;
/**
* champ hidden pour la gestion de la pagination
* @since 1.0
*/
private String fCdPagine;
/**
* champ hidden pour la borne de début de la pagination
* @since 1.0
*/
private String fCdDebut;
/**
* champ hidden pour la borne de fin de la pagination
* @since 1.0
*/
private String fCdFin;
/**
* champ hidden pour connaître le formulaire d'origine
* @since 1.0
*/
private String fCdSearch;
/**
* Code Faml : cela permet de définir la picto du dommaine
* @since 1.0
*/
private String fCdFaml;
/**
* Code Insse
* @since 1.0
*/
private String fCdInsee;
/**
* Ville
* @since 1.0
*/
private String fLbVille;
/**
* Le code postal
* @since 1.0
*/
private String fCdPst;
/**
* Le département
* @since 1.0
*/
private String fCdDep;
/**
* L'enseigne
* @since 1.0
*/
private String fLbEnsg1;
/**
* Hébergement
* @since 1.0
*/
private String fCdHeb;
/**
* Restauration
* @since 1.0
*/
private String fCdRes;
/**
* Voyages et Transports
* @since 1.0
*/
private String fCdVoyTra;
/**
* Sports et Loisirs
* @since 1.0
*/
private String fCdSpoLoi;
/**
* Culture et Découverte
* @since 1.0
*/
private String fCdCulDec;
/**
* Avantages
* @since 1.0
*/
private String fCdAva;
/**
* Type accueil des jeunes
* @since 1.0
*/
private String fCdAccJeu;
/** DEDUT DE MODIFICATION - FEV 1320 - 17/12/2007 **/
/** Deprecated 17/12/2007 **
* Accessibilité des handicapés accompagnés
* @since 1.0
*
private String fCdAccHanAcc; */
/** Deprecated 17/12/2007 **
* Accessibilité des handicapés autonome
* @since 1.0
*
private String fCdAccHanAut; */
/**
* Label tourisme et handicap : tous
*/
private String fCdLabHanTous;
/**
* Label tourisme et handicap : moteur
*/
private String fCdLabHanMot;
/**
* Label tourisme et handicap : visuel
*/
private String fCdLabHanVis;
/**
* Label tourisme et handicap : Auditif
*/
private String fCdLabHanAud;
/**
* Label tourisme et handicap : Mental
*/
private String fCdLabHanMen;
/** FIN DE MODIFICATION **/
/**
* Type de recherche (attribut avec un rôle applicatif)
* @since 1.0
*/
private String fCdTypeRech;
/**
* Réinitialisation du formulaire
* @since 1.0
*/
public void reset( ActionMapping mapping, HttpServletRequest request )
{
if( log.isDebugEnabled( ) )
{
log.debug( "******* reset: called *******" );
}
//fCdAccHanAcc = null;
//fCdAccHanAut = null;
//fCdAccJeu = null;
//fCdAva = null;
fCdActv = null;
fCdDoma =null;
fCdFaml = null;
fCdPst = null;
}
/* public void resetHan( ActionMapping mapping, HttpServletRequest request )
{
fCdLabHanTous = null;
fCdLabHanMot = null;
fCdLabHanVis = null;
fCdLabHanAud = null;
fCdLabHanMen = null;
} */
/**
* Constructeur
* @since 1.0
*/
public SearchForm( )
{
fCdDebut = "0";
fCdFin = "4";
}
/**
* Retourne le champ 'fCdFin'
* @since 1.0
* @return
*/
public String getCdFin( )
{
return fCdFin;
}
/**
* Initialise le champ 'fdDebut'
* @since 1.0
* @param fCdDebut
*/
public void setCdFin( String CdFin )
{
fCdFin = CdFin;
}
/**
* Retourne le champ 'fCdDebut'
* @since 1.0
* @return
*/
public String getCdDebut( )
{
return fCdDebut;
}
/**
* Initialise le champ 'fdDebut'
* @since 1.0
* @param fCdDebut
*/
public void setCdDebut( String CdDebut )
{
fCdDebut = CdDebut;
}
/**
* Retourne le champ 'fCdPagine'
* @since 1.0
* @return
*/
public String getCdPagine( )
{
return fCdPagine;
}
/**
* Initialise le champ 'CdPagine'
* @since 1.0
* @param fCdPagine
*/
public void setCdPagine( String CdPagine )
{
fCdPagine = CdPagine;
}
/**
* Retourne le champ 'fCdFaml'
* @since 1.0
* @return
*/
public String getCdFaml( )
{
return fCdFaml;
}
/**
* Initialise le champ 'fCdFaml'
* @since 1.0
* @param fCdFaml
*/
public void setCdFaml( String CdFaml )
{
fCdFaml = CdFaml;
}
/**
* Retourne le champ 'fCdInsee'
* @since 1.0
* @return
*/
public String getCdInsee( )
{
return fCdInsee;
}
/**
* Initialise le champ 'fCdInsee'
* @since 1.0
* @param CdInsee
*/
public void setCdInsee( String CdInsee )
{
fCdInsee = CdInsee;
}
/**
* Retourne le champ 'fCdTypeRech'
* @since 1.0
* @return
*/
public String getCdTypeRech( )
{
return fCdTypeRech;
}
/**
* Initialise le champ 'fCdTypeRech'
* @since 1.0
* @param lbEnsg1
*/
public void setCdTypeRech( String cdTypeRech )
{
fCdTypeRech = cdTypeRech;
}
/**
* Retourne le champ 'fCdSearch'
* @since 1.0
* @return
*/
public String getCdSearch( )
{
return fCdSearch;
}
/**
* Initialise le champ 'fCdSearch'
* @since 1.0
* @param lbEnsg1
*/
public void setCdSearch( String cdSearch )
{
fCdSearch = cdSearch;
}
/**
* Retourne le champ 'fLbVille'
* @since 1.0
* @return
*/
public String getLbVille( )
{
return fLbVille;
}
/**
* Initialise le champ 'fLbVille'
* @since 1.0
* @param lbEnsg1
*/
public void setLbVille( String lbVille )
{
fLbVille = lbVille;
}
/**
* Retourne le champ 'fCdPst'
* @since 1.0
* @return
*/
public String getCdPst( )
{
return fCdPst;
}
/**
* Initialise le champ 'fcdPst'
* @since 1.0
* @param cdPst
*/
public void setCdPst( String cdPst )
{
fCdPst = cdPst;
}
/**
* Retourne le champ 'fLbDep'
* @since 1.0
* @return
*/
public String getCdDep( )
{
return fCdDep;
}
/**
* Initialise le champ 'fcddep'
* @since 1.0
* @param lbDep
*/
public void setCdDep( String cdDep )
{
fCdDep = cdDep;
}
/**
* Retourne le champ 'fLbEnsg1'
* @since 1.0
* @return
*/
public String getLbEnsg1( )
{
return fLbEnsg1;
}
/**
* Initialise le champ 'fLbEnsg1'
* @since 1.0
* @param lbEns
*/
public void setLbEnsg1( String LbEnsg1 )
{
fLbEnsg1 = LbEnsg1;
}
/**
* Retourne le champ 'fCdHeb'
* @since 1.0
* @return
*/
public String getCdHeb( )
{
return fCdHeb;
}
/**
* Initialise le champ 'fCdHeb'
* @since 1.0
* @param cdHeb
*/
public void setCdHeb( String cdHeb )
{
fCdHeb = cdHeb;
}
/**
* Retourne le champ 'fCdRes'
* @since 1.0
* @return
*/
public String getCdRes( )
{
return fCdRes;
}
/**
* Initialise le champ 'fCdRes'
* @since 1.0
* @param cdRes
*/
public void setCdRes( String cdRes )
{
fCdRes = cdRes;
}
/**
* Retourne le champ 'fCdVoyTra'
* @since 1.0
* @return
*/
public String getCdVoyTra( )
{
return fCdVoyTra;
}
/**
* Initialise le champ 'fCdVoyTra'
* @since 1.0
* @param cdVoyTra
*/
public void setCdVoyTra( String cdVoyTra )
{
fCdVoyTra = cdVoyTra;
}
/**
* Retourne le champ 'fcdSpoLoi'
* @since 1.0
* @return
*/
public String getCdSpoLoi( )
{
return fCdSpoLoi;
}
/**
* Initialise le champ 'fCdSpoLoi'
* @since 1.0
* @param cdSpoLoi
*/
public void setCdSpoLoi( String cdSpoLoi )
{
fCdSpoLoi = cdSpoLoi;
}
/**
* Retourne le champ 'fCdCulDec'
* @since 1.0
* @return
*/
public String getCdCulDec( )
{
return fCdCulDec;
}
/**
* Initialise le champ 'fCdCulDec'
* @since 1.0
* @param cdculDec
*/
public void setCdCulDec( String cdCulDec )
{
fCdCulDec = cdCulDec;
}
/**
* Retourne le champ 'fCdAva'
* @since 1.0
* @return
*/
public String getCdAva( )
{
return fCdAva;
}
/**
* Initialise le champ 'fCdAva'
* @since 1.0
* @param cdAva
*/
public void setCdAva( String cdAva )
{
fCdAva = cdAva;
}
/**
* Retourne le champ 'fCdAccJeu'
* @since 1.0
* @return
*/
public String getCdAccJeu( )
{
return fCdAccJeu;
}
/**
* Initialise le champ 'fCdAccJeu'
* @since 1.0
* @param cdAccJeu
*/
public void setCdAccJeu( String cdAccJeu )
{
fCdAccJeu = cdAccJeu;
}
/** DEBUT DE MODIFICATION - FEV1320 - 17/12/2007 **/
/**
* Initialise le champ 'fCdAccHanAcc'
* @since 1.0
* @param fCdAccHanAcc
*
public String getCdAccHanAcc( )
{
return fCdAccHanAcc;
} */
/**
* Initialise le champ 'fCdAccHanAut'
* @since 1.0
* @param fCdAccHanAut
*
public String getCdAccHanAut( )
{
return fCdAccHanAut;
} */
/**
* Initialise le champ 'fCdAccHanAcc'
* @since 1.0
* @param cdAccHanAcc
*
public void setCdAccHanAcc( String cdAccHanAcc )
{
fCdAccHanAcc = cdAccHanAcc;
} */
/**
* @param string
*
public void setCdAccHanAut( String cdAccHanAut )
{
fCdAccHanAut = cdAccHanAut;
} */
/**
* Retourne le champ 'fCdLabHanTous'
* @since 1.0
* @param fCdLabHanTous
*/
public String getCdLabHanTous( )
{
return fCdLabHanTous;
}
/**
* Initialise le champ 'fCdLabHanTous'
* @since 1.0
* @param cdLabHanTous
*/
public void setCdLabHanTous( String cdLabHanTous )
{
fCdLabHanTous = cdLabHanTous;
}
/**
* Retourne le champ 'fCdLabHanMot'
* @since 1.0
* @return
*/
public String getCdLabHanMot( )
{
return fCdLabHanMot;
}
/**
* Initialise le champ 'fCdLabHanMot'
* @since 1.0
* @param cdLabHanMot
*/
public void setCdLabHanMot( String cdLabHanMot )
{
fCdLabHanMot = cdLabHanMot;
}
/**
* Retourne le champ 'fCdLabHanVis'
* @since 1.0
* @return
*/
public String getCdLabHanVis( )
{
return fCdLabHanVis;
}
/**
* Initialise le champ 'fCdLabHanVis'
* @since 1.0
* @param cdLabHanVis
*/
public void setCdLabHanVis( String cdLabHanVis )
{
fCdLabHanVis = cdLabHanVis;
}
/**
* Retourne le champ 'fCdLabHanAud'
* @since 1.0
* @return
*/
public String getCdLabHanAud( )
{
return fCdLabHanAud;
}
/**
* Initialise le champ 'fCdLabHanAud'
* @since 1.0
* @param cdLabHanAud
*/
public void setCdLabHanAud( String cdLabHanAud )
{
fCdLabHanAud = cdLabHanAud;
}
/**
* Retourne le champ 'fCdLabHanMen'
* @since 1.0
* @return
*/
public String getCdLabHanMen( )
{
return fCdLabHanMen;
}
/**
* Initialise le champ 'fCdLabHanMen'
* @since 1.0
* @param cdLabHanMen
*/
public void setCdLabHanMen( String cdLabHanMen )
{
fCdLabHanMen = cdLabHanMen;
}
/** FIN DE MODIFICATION **/
/**
* @return
*/
public String getCdActv( )
{
return fCdActv;
}
/**
* @return
*/
public String getLbOrderBy( )
{
return fLbOrderBy;
}
/**
* @param string
*/
public void setCdActv( String CdActv )
{
fCdActv = CdActv;
}
/**
* @param string
*/
public void setLbOrderBy( String LbOrderBy )
{
fLbOrderBy = LbOrderBy;
}
/**
* @return
*/
public String getCdPos() {
return fCdPos;
}
/**
* @param string
*/
public void setCdPos(String cdPos) {
fCdPos = cdPos;
}
/**
* @return
*/
public String getCdDoma() {
return fCdDoma;
}
/**
* @param string
*/
public void setCdDoma(String cdDoma) {
fCdDoma = cdDoma;
}
/**
* @return
*/
public String getCdTitre() {
return fCdTitre;
}
/**
* @param string
*/
public void setCdTitre(String cdtitre) {
fCdTitre = cdtitre;
}
/**
* méthode de validation du formulaire
* @param mapping ActionMapping
* @param request HttpServletRequest
* @since 1.0
*/
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
log.debug("validate: called");
ActionErrors errors = super.validate(mapping, request);
if (fCdSearch.equals("searchVil.do")) {
/*******************************************************************
* Controle du formulaire
******************************************************************/
if ((!fCdPst.equals("")) && (fCdPst.length() > 0)
&& (fCdPst.length() < 5)) {
/*
* FIXME standardiser l'emplacement des requêtes, se decider
* entre les DAO et les objets métiers (à cause du côté
* fonctionnel de la recherche) ici c'est l'objet form qui le
* contient, il faudrait se décider...
*/
/*
* FIXME BUG BUG BUG, on ne devrait jamais modifier le contenu
* de ce champ dans les classes FORM
*/
fCdPst = fCdPst.concat("%");
}
/*******************************************************************
* ville et code postal
******************************************************************/
boolean bSaisieVille = !GenericValidator.isBlankOrNull(fLbVille);
boolean bSaisieCdpst = !GenericValidator.isBlankOrNull(fCdPst);
if (!bSaisieVille ^ bSaisieCdpst) {
if (bSaisieVille) {
errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(
"errors.aucunesaisie"));
} else {
errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(
"errors.tropdesaisie"));
}
}
} else if ((fCdSearch.equals("searchDep.do"))
|| (fCdSearch.equals("searchEns.do"))) {
/*******************************************************************
* controle de la sélection d'un departement
******************************************************************/
boolean bSaisieDep = !GenericValidator.isBlankOrNull(fCdDep);
if (!bSaisieDep) {
errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(
"errors.aucundep"));
}
if ((!fCdDep.equals("")) && (fCdDep.length() > 0)) {
/*
* FIXME standardiser l'emplacement des requêtes, se decider
* entre les DAO et les objets métiers (à cause du côté
* fonctionnel de la recherche) ici c'est l'objet form qui le
* contient, il faudrait se décider...
*/
fCdPst = fCdDep.concat("%");
}
}
if ((!fCdSearch.equals("resultDep.do"))
&& (!fCdSearch.equals("resultVil.do"))
&& (!fCdSearch.equals("resultIns.do"))
&& (!fCdSearch.equals("resultEns.do"))
&& (!fCdSearch.equals("searchDet.do"))
&& (!fCdSearch.equals("detail.do"))) {
fCdPagine = null;
fCdDebut = "0";
}
// translation
ActionErrors translated = translate(errors, request);
// re-génération des listes déroulantes si besoin est
generateList(translated, request);
return translated;
}
} |
Partager