You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@click.apache.org by easydoor958 <ch...@valdoise.fr> on 2011/04/28 16:17:09 UTC

ActionButton seems not working with Apache Click 2.3.0

When i put in a search form an ActionButton which allows user to clear values in 
the fields to reset criterias. 
I put this code 
ActionButton clearButton = new ActionButton("Effacer les critères", this, 
"onClear"); 
... 
    public boolean onClear() { 
        formSearch.clearValues(); 
        return true; 
    } 
and when i click on the button, nothing happens 

I change ActionButton by an ActionLink and it works well ! Why ?


Re: ActionButton seems not working with Apache Click 2.3.0

Posted by easydoor95 <ch...@valdoise.fr>.
Hi Bob, 
I explained in the first post my problem, 
Malcom asked me to put the source code
There is no possibility in this forum to upload files 
so i put the source in the second post
My first question is simple, isn't it ?


Re: ActionButton seems not working with Apache Click 2.3.0

Posted by Bob Schellink <sa...@gmail.com>.
I doubt you'll get a reply by simply posting your entire page as is.
You need to respect peoples time by making sure you post a resonable
example, stipulating exactly what you need and what you don't
understand.

Bob

On Fri, Apr 29, 2011 at 11:15 AM, easydoor958
<ch...@valdoise.fr> wrote:
> Here the source code
>
> package vdo.archeo.page;
>
> import java.util.ArrayList;
> import java.util.List;
>
> import org.apache.click.control.ActionLink;
> import org.apache.click.control.Form;
> import org.apache.click.control.Label;
> import org.apache.click.control.Option;
> import org.apache.click.control.Select;
> import org.apache.click.control.Submit;
> import org.apache.click.control.TextField;
> import org.apache.click.extras.control.AutoCompleteTextField;
> import org.apache.click.extras.control.PageSubmit;
> import org.apache.click.extras.control.RegexField;
> import org.apache.click.util.Bindable;
>
> import vdo.archeo.hibernate.AgglocomDAO;
> import vdo.archeo.hibernate.Biblio;
> import vdo.archeo.hibernate.BiblioDAO;
> import vdo.archeo.hibernate.CantonDAO;
> import vdo.archeo.hibernate.Commune;
> import vdo.archeo.hibernate.CommuneDAO;
> import vdo.archeo.hibernate.DatationDAO;
> import vdo.archeo.hibernate.OccupationDAO;
> import vdo.archeo.hibernate.Site;
> import vdo.archeo.hibernate.SiteDAO;
> import vdo.archeo.hibernate.TerritoireDAO;
> import vdo.archeo.hibernate.TypapprocheDAO;
> import vdo.archeo.hibernate.TypsiteDAO;
> import vdo.archeo.hibernate.Utilisateur;
>
> @SuppressWarnings("serial")
> public class SearchSitesPage extends BorderPage {
>
>        @Bindable protected String title = "Carte Archéologique du Val d'Oise";
>        @Bindable protected Form formSearch = new Form();
>        @Bindable protected Site site = new Site();
>        @Bindable protected int sizeListe = 0 ;
>
>        private List<Site> sites = null;
>
>        private Select typsiteSelect     = new Select("type","Type de site");
>        private Select territoireSelect  = new
> Select("territoire","Territoire");
>        private Select cantonSelect      = new Select("canton","Canton");
>        private Select agglocomSelect    = new
> Select("agglocom","Agglo/Communes");
>        private Select datationSelect    = new Select("datation","Datation");
>        private Select occupationSelect  = new
> Select("occupation","Occupation");
>        private Select typapprocheSelect = new Select("typapproche.id","Type
> d'approche");
>        private RegexField numero        = new RegexField("numero","N°
> Site",15);
>        private TextField datation2 = new TextField("datation2","2ème
> Datation",25);
>        private TextField lieudit   = new TextField("lieudit","Lieu dit",25);
>        private TextField adresse   = new TextField("adresse","Adresse",25);
>        private TextField nom       = new TextField("nom","Nom usuel",25);
>        private TextField motcle1    = new TextField("motcle1","Mots clés
> Immobilier",25);
>        private TextField motcle2    = new TextField("motcle2","Mots clés
> Mobilier",25);
>        private TextField motcle3    = new TextField("description","Mots clés
> Description",25);
>        private TextField conserv   = new TextField("conserv","Lieu de
> conservation",25);
>        private TextField titulaire = new
> TextField("operation.auteur","Titulaire",25);
>        private TextField annee     = new
> TextField("operation.annee","Année",10);
>
>        private AutoCompleteTextField commune = new
> AutoCompleteTextField("commune.libCommune","Commune",30) {
>
>                public List<String> getAutoCompleteList(String criteria) {
>                List<Commune> communes = new
> CommuneDAO().findByLibLike(criteria);
>
>                List<String> libCommunes = new ArrayList<String>();
>
>                for (Commune commune : communes) {
>                                libCommunes.add(commune.getLibCommune());
>                        }
>                return libCommunes;
>            }
>         };
>
>        private AutoCompleteTextField refBiblio = new
> AutoCompleteTextField("biblio.reference","Vedette Biblio",40) {
>
>                 public List<String> getAutoCompleteList(String criteria) {
>                 List<Biblio> biblios = new BiblioDAO().findByRefLike(criteria);
>
>                 List<String> references = new ArrayList<String>();
>
>                 for (Biblio biblio : biblios) {
>                                references.add(biblio.getReference());
>                 }
>                 return references;
>            }
>         };
>
>        private String nomSearch = "";
>        private String typsiteSearch   = "";
>        private String datationSearch  = "";
>        private String datation2Search = "";
>        private String terrSearch      = "";
>        private String canSearch       = "";
>        private String comSearch       = "";
>        private String occupSearch     = "";
>        private String numSearch       = "";
>        private String lieuditSearch   = "";
>        private String adresseSearch   = "";
>        private String refBiblioSearch = "";
>        private String motcle1Search   = "";
>        private String motcle2Search   = "";
>        private String motcle3Search   = "";
>        private String conservSearch   = "";
>        private String anneeSearch     = "";
>        private String tituSearch      = "";
>        private String typappSearch    = "";
>        private String agglocomSearch  = "";
>
>    public SearchSitesPage() {
>
>        //Formulaire de recherche
>        formSearch.setColumns(3);
>        formSearch.setButtonAlign("center");
>        formSearch.setLabelAlign("left");
>        formSearch.setLabelsPosition("top");
>
>                //Territoire
>                formSearch.add(territoireSelect);
>
>                //Canton
>                formSearch.add(cantonSelect);
>
>                //Commune
>                commune.setMaxLength(50);
>
> commune.setAttribute("onfocus","this.value=this.value.toUpperCase();");
>        formSearch.add(commune);
>
>                //Agglomération de communes
>                formSearch.add(agglocomSelect);
>
>                //N° de site
>        numero.setMaxLength(10);
>        numero.setMinLength(4);
>        //numero.setPattern(patternNumero);
>        formSearch.add(numero);
>
>        //Nom usuel
>        nom.setMaxLength(50);
>        formSearch.add(nom);
>
>                //Lieu dit
>        lieudit.setMaxLength(50);
>        formSearch.add(lieudit);
>
>                //Adresse
>        adresse.setMaxLength(50);
>        formSearch.add(adresse,2);
>
>                //Mots clés Immobilier
>                motcle1.setMaxLength(50);
>        formSearch.add(motcle1);
>
>                //Mots clés Mobilier
>                motcle2.setMaxLength(50);
>        formSearch.add(motcle2);
>
>                //Mots clés Description
>                motcle3.setMaxLength(50);
>        formSearch.add(motcle3);
>
>        //Label Mot clés
>        Label label = new Label("<i>Les mot clés multiples doivent être séparés
> par une virgule</i>");
>        formSearch.add(label,3);
>
>                //Datation
>                formSearch.add(datationSelect);
>
>                //Datation2
>        datation2.setMaxLength(50);
>        formSearch.add(datation2);
>
>        //Année
>                annee.setMaxLength(20);
>        formSearch.add(annee);
>
>                //Type de site
>                formSearch.add(typsiteSelect);
>
>                //Occupation
>                formSearch.add(occupationSelect);
>
>        //Type d'approche
>        formSearch.add(typapprocheSelect);
>
>        //Titulaire
>                titulaire.setMaxLength(50);
>        formSearch.add(titulaire);
>
>        //Vedette Biblio
>        refBiblio.setMaxLength(50);
>        formSearch.add(refBiblio);
>
>        //Lieu de conservation
>        conserv.setMaxLength(50);
>        formSearch.add(conserv,2);
>
>        Submit searchButton = new Submit(" Rechercher ");
>        searchButton.setAttribute("class","button");
>        formSearch.add(searchButton);
>
>        //ActionButton clearButton = new ActionButton("Effacer les critères",
> this, "onClear");
>        ActionLink clearLink = new ActionLink("Effacer les critères", this,
> "onClear");
>        //clearLink.setAttribute("class","button");
>        formSearch.add(clearLink);
>
>        Submit printButton = new PageSubmit("Sites par Commune",
> SitesCommunePage.class);
>        printButton.setAttribute("class","button");
>        formSearch.add(printButton);
>    }
>
>    public void buildSelects() {
>        typsiteSelect.add(new Option(0,"TYPE"));
>        typsiteSelect.addAll(new TypsiteDAO().findAll(),"id","libelle");
>
>                datationSelect.add(new Option(0,"DATATION"));
>                datationSelect.addAll(new
> DatationDAO().findAll(),"id","libelle");
>
>                occupationSelect.add(new Option(0,"OCCUPATION"));
>                occupationSelect.addAll(new
> OccupationDAO().findAll(),"libelle","libelle");
>
>                territoireSelect.add(new Option(0,"TERRITOIRE"));
>                territoireSelect.addAll(new
> TerritoireDAO().findAll(),"numTerritoire","libTerritoire");
>
>        typapprocheSelect.add(new Option(0,"TYPE APPROCHE"));
>        typapprocheSelect.addAll(new TypapprocheDAO().findAll(),"id","libelle");
>
>        agglocomSelect.add(new Option(0,"AGGLO/COMMUNES"));
>        agglocomSelect.addAll(new
> AgglocomDAO().findAll(),"numAgglocom","libAgglocom");
>
>                cantonSelect.add(new Option(0,"CANTON"));
>                cantonSelect.addAll(new
> CantonDAO().findAll(),"numCanton","libCanton");
>    }
>
>    public boolean onClear() {
>        formSearch.clearValues();
>        return true;
>    }
>
>    public void onInit() {
>
>        super.onInit();
>
>        buildSelects();
>
>        if (getContext().hasSessionAttribute("utilisateur"))
>                        utilisateur =
> (Utilisateur)getContext().getSessionAttribute("utilisateur");
>
>        if (!utilisateur.getRole().equals("Utilisateur")) {
>                Submit addButton = new PageSubmit("Ajouter un Site",
> AddSitePage.class);
>                addButton.setAttribute("class","button");
>                formSearch.add(addButton);
>        }
>    }
>
>    public void onSearch() {
>
>        nomSearch       = nom.getValue().trim();
>        typsiteSearch   = typsiteSelect.getValue();
>        datationSearch  = datationSelect.getValue();
>        datation2Search = datation2.getValue().trim();
>        terrSearch      = territoireSelect.getValue();
>        canSearch       = cantonSelect.getValue();
>        comSearch       = commune.getValue();
>        occupSearch     = occupationSelect.getValue();
>        numSearch       = numero.getValue().trim();
>        lieuditSearch   = lieudit.getValue().trim();
>        adresseSearch   = adresse.getValue().trim();
>        refBiblioSearch = refBiblio.getValue().trim();
>        motcle1Search    = motcle1.getValue().trim();
>        motcle2Search    = motcle2.getValue().trim();
>        motcle3Search    = motcle3.getValue().trim();
>        conservSearch   = conserv.getValue().trim();
>        anneeSearch     = annee.getValue().trim();
>        tituSearch      = titulaire.getValue().trim();
>        typappSearch    = typapprocheSelect.getValue();
>        agglocomSearch  = agglocomSelect.getValue();
>
>        //Mise en session des critères renseignés si recherche
>        if (getContext().isPost()) {
>
>            if (typsiteSearch.equals("0"))  typsiteSearch  = "";
>                if (datationSearch.equals("0")) datationSearch = "";
>            if (terrSearch.equals("0"))     terrSearch     = "";
>            if (canSearch.equals("0"))      canSearch      = "";
>                //if (comSearch.equals("0"))    comSearch      = "";
>                if (occupSearch.equals("0"))    occupSearch    = "";
>                if (typappSearch.equals("0"))   typappSearch   = "";
>                if (agglocomSearch.equals("0")) agglocomSearch = "";
>
>            getContext().setSessionAttribute("nom",nomSearch);
>            getContext().setSessionAttribute("typsite",typsiteSearch);
>            getContext().setSessionAttribute("datation",datationSearch);
>            getContext().setSessionAttribute("datation2",datation2Search);
>            getContext().setSessionAttribute("territoire",terrSearch);
>            getContext().setSessionAttribute("canton",canSearch);
>            getContext().setSessionAttribute("commune",comSearch);
>            getContext().setSessionAttribute("occupation",occupSearch);
>            getContext().setSessionAttribute("numero",numSearch);
>            getContext().setSessionAttribute("lieudit",lieuditSearch);
>            getContext().setSessionAttribute("adresse",adresseSearch);
>            getContext().setSessionAttribute("refBiblio",refBiblioSearch);
>            getContext().setSessionAttribute("motcle1",motcle1Search);
>            getContext().setSessionAttribute("motcle2",motcle2Search);
>            getContext().setSessionAttribute("motcle3",motcle3Search);
>            getContext().setSessionAttribute("conserv",conservSearch);
>            getContext().setSessionAttribute("annee",anneeSearch);
>            getContext().setSessionAttribute("titulaire",tituSearch);
>            getContext().setSessionAttribute("typapp",typappSearch);
>            getContext().setSessionAttribute("agglocom",agglocomSearch);
>        }
>        //Récupération des critères de recherche en session s'ils existent
>        else {
>                if (getContext().hasSessionAttribute("nom")) {
>                        nomSearch =
> (String)getContext().getSessionAttribute("nom");
>                        nom.setValue(nomSearch);
>                }
>                if (getContext().hasSessionAttribute("typsite")) {
>                        typsiteSearch =
> (String)getContext().getSessionAttribute("typsite");
>                        typsiteSelect.setValue(typsiteSearch);
>                } else typsiteSearch = "";
>                if (getContext().hasSessionAttribute("datation")) {
>                        datationSearch =
> (String)getContext().getSessionAttribute("datation");
>                        datationSelect.setValue(datationSearch);
>                } else datationSearch = "";
>                if (getContext().hasSessionAttribute("datation2")) {
>                        datation2Search =
> (String)getContext().getSessionAttribute("datation2");
>                        datation2.setValue(datation2Search);
>                } else datation2Search = "";
>                if (getContext().hasSessionAttribute("territoire")) {
>                        terrSearch =
> (String)getContext().getSessionAttribute("territoire");
>                        territoireSelect.setValue(terrSearch);
>                } else terrSearch = "";
>                if (getContext().hasSessionAttribute("canton")) {
>                        canSearch =
> (String)getContext().getSessionAttribute("canton");
>                        //communeSelect.setValue(comSearch);
>                        cantonSelect.setValue(canSearch);
>                } else canSearch = "";
>                if (getContext().hasSessionAttribute("commune")) {
>                        comSearch =
> (String)getContext().getSessionAttribute("commune");
>                        //communeSelect.setValue(comSearch);
>                        commune.setValue(comSearch);
>                } else comSearch = "";
>                if (getContext().hasSessionAttribute("occupation")) {
>                        occupSearch =
> (String)getContext().getSessionAttribute("occupation");
>                        occupationSelect.setValue(occupSearch);
>                } else occupSearch = "";
>                if (getContext().hasSessionAttribute("numero")) {
>                        numSearch =
> (String)getContext().getSessionAttribute("numero");
>                        numero.setValue(numSearch);
>                }
>                if (getContext().hasSessionAttribute("lieudit")) {
>                        lieuditSearch =
> (String)getContext().getSessionAttribute("lieudit");
>                        lieudit.setValue(lieuditSearch);
>                }
>                if (getContext().hasSessionAttribute("adresse")) {
>                        adresseSearch =
> (String)getContext().getSessionAttribute("adresse");
>                        adresse.setValue(adresseSearch);
>                }
>                if (getContext().hasSessionAttribute("refBiblio")) {
>                        refBiblioSearch =
> (String)getContext().getSessionAttribute("refBiblio");
>                        refBiblio.setValue(refBiblioSearch);
>                }
>                if (getContext().hasSessionAttribute("motcle1")) {
>                        motcle1Search =
> (String)getContext().getSessionAttribute("motcle1");
>                        motcle1.setValue(motcle1Search);
>                }
>                if (getContext().hasSessionAttribute("motcle2")) {
>                        motcle2Search =
> (String)getContext().getSessionAttribute("motcle2");
>                        motcle2.setValue(motcle2Search);
>                }
>                if (getContext().hasSessionAttribute("motcle3")) {
>                        motcle3Search =
> (String)getContext().getSessionAttribute("motcle3");
>                        motcle3.setValue(motcle3Search);
>                }
>                if (getContext().hasSessionAttribute("conserv")) {
>                        conservSearch =
> (String)getContext().getSessionAttribute("conserv");
>                        conserv.setValue(conservSearch);
>                }
>                if (getContext().hasSessionAttribute("annee")) {
>                        anneeSearch =
> (String)getContext().getSessionAttribute("annee");
>                        annee.setValue(anneeSearch);
>                }
>                if (getContext().hasSessionAttribute("titulaire")) {
>                        tituSearch =
> (String)getContext().getSessionAttribute("titulaire");
>                        titulaire.setValue(tituSearch);
>                }
>                if (getContext().hasSessionAttribute("typapp")) {
>                        typappSearch =
> (String)getContext().getSessionAttribute("typapp");
>                        typapprocheSelect.setValue(typappSearch);
>                } else typappSearch = "";
>                if (getContext().hasSessionAttribute("agglocom")) {
>                        agglocomSearch =
> (String)getContext().getSessionAttribute("agglocom");
>                        agglocomSelect.setValue(agglocomSearch);
>                } else agglocomSearch = "";
>        }
>    }
>
>    public void onPost() {
>        onSearch();
>
>                sites = new SiteDAO().findByCriteria(nomSearch, typsiteSearch,
> datationSearch, datation2Search, terrSearch, canSearch,
>                                 agglocomSearch, comSearch, occupSearch,
> numSearch, lieuditSearch, adresseSearch,
>                                 refBiblioSearch, motcle1Search, motcle2Search,
> motcle3Search,conservSearch, anneeSearch, tituSearch, typappSearch);
>
>                sizeListe = sites.size();
>
>                if (sites.isEmpty())
>                        formSearch.setError("<strong>Aucun site ne correspond à
> votre recherche</strong>");
>                else {
>                        //Mise en session de la liste des Sites
>                        getContext().setSessionAttribute("sites",sites);
>
>                        //Redirection vers la liste des sites
>                        setRedirect(SitesPage.class);
>                }
>        }
>
>    public void onGet() {
>        onSearch();
>    }
>
>    public boolean onSecurityCheck() {
>
>        if (getContext().hasSession())
>            return true;
>        else {
>            setRedirect(LoginPage.class);
>            return false;
>        }
>    }
> }
>
>
>
>
>

Re: ActionButton seems not working with Apache Click 2.3.0

Posted by easydoor958 <ch...@valdoise.fr>.
Here the source code

package vdo.archeo.page;

import java.util.ArrayList;
import java.util.List;

import org.apache.click.control.ActionLink;
import org.apache.click.control.Form;
import org.apache.click.control.Label;
import org.apache.click.control.Option;
import org.apache.click.control.Select;
import org.apache.click.control.Submit;
import org.apache.click.control.TextField;
import org.apache.click.extras.control.AutoCompleteTextField;
import org.apache.click.extras.control.PageSubmit;
import org.apache.click.extras.control.RegexField;
import org.apache.click.util.Bindable;

import vdo.archeo.hibernate.AgglocomDAO;
import vdo.archeo.hibernate.Biblio;
import vdo.archeo.hibernate.BiblioDAO;
import vdo.archeo.hibernate.CantonDAO;
import vdo.archeo.hibernate.Commune;
import vdo.archeo.hibernate.CommuneDAO;
import vdo.archeo.hibernate.DatationDAO;
import vdo.archeo.hibernate.OccupationDAO;
import vdo.archeo.hibernate.Site;
import vdo.archeo.hibernate.SiteDAO;
import vdo.archeo.hibernate.TerritoireDAO;
import vdo.archeo.hibernate.TypapprocheDAO;
import vdo.archeo.hibernate.TypsiteDAO;
import vdo.archeo.hibernate.Utilisateur;

@SuppressWarnings("serial")
public class SearchSitesPage extends BorderPage {

	@Bindable protected String title = "Carte Archéologique du Val d'Oise";
	@Bindable protected Form formSearch = new Form();
  	@Bindable protected Site site = new Site();
  	@Bindable protected int sizeListe = 0 ;
  	
  	private List<Site> sites = null;

	private Select typsiteSelect     = new Select("type","Type de site");
	private Select territoireSelect  = new 
Select("territoire","Territoire");
	private Select cantonSelect      = new Select("canton","Canton");
	private Select agglocomSelect    = new 
Select("agglocom","Agglo/Communes");
	private Select datationSelect    = new Select("datation","Datation");
	private Select occupationSelect  = new 
Select("occupation","Occupation");
	private Select typapprocheSelect = new Select("typapproche.id","Type 
d'approche");
	private RegexField numero        = new RegexField("numero","N° 
Site",15);
	private TextField datation2 = new TextField("datation2","2ème 
Datation",25);
	private TextField lieudit   = new TextField("lieudit","Lieu dit",25);
	private TextField adresse   = new TextField("adresse","Adresse",25);
	private TextField nom       = new TextField("nom","Nom usuel",25);
	private TextField motcle1    = new TextField("motcle1","Mots clés 
Immobilier",25);
	private TextField motcle2    = new TextField("motcle2","Mots clés 
Mobilier",25);
	private TextField motcle3    = new TextField("description","Mots clés 
Description",25);
	private TextField conserv   = new TextField("conserv","Lieu de 
conservation",25);
	private TextField titulaire = new 
TextField("operation.auteur","Titulaire",25);
	private TextField annee     = new 
TextField("operation.annee","Année",10);

 	private AutoCompleteTextField commune = new 
AutoCompleteTextField("commune.libCommune","Commune",30) {
  	    
 		public List<String> getAutoCompleteList(String criteria) {
  	    	List<Commune> communes = new 
CommuneDAO().findByLibLike(criteria);

  	    	List<String> libCommunes = new ArrayList<String>();
  	    	
  	    	for (Commune commune : communes) {
  	 			libCommunes.add(commune.getLibCommune());
  	 		}
  	    	return libCommunes;
  	    }
  	 };
  	 
	private AutoCompleteTextField refBiblio = new 
AutoCompleteTextField("biblio.reference","Vedette Biblio",40) {
   	     
		 public List<String> getAutoCompleteList(String criteria) {
   	    	 List<Biblio> biblios = new BiblioDAO().findByRefLike(criteria);

   	    	 List<String> references = new ArrayList<String>();
   	    	
   	    	 for (Biblio biblio : biblios) {
   	 			references.add(biblio.getReference());
   	    	 }
   	    	 return references;
   	    }
   	 };
  	 
 	private String nomSearch = "";
 	private String typsiteSearch   = "";
 	private String datationSearch  = "";
 	private String datation2Search = "";
 	private String terrSearch      = "";
 	private String canSearch       = "";
 	private String comSearch       = "";
 	private String occupSearch     = "";
 	private String numSearch       = "";
 	private String lieuditSearch   = "";
 	private String adresseSearch   = "";
 	private String refBiblioSearch = "";
 	private String motcle1Search   = "";
 	private String motcle2Search   = "";
 	private String motcle3Search   = "";
 	private String conservSearch   = "";
 	private String anneeSearch     = "";
 	private String tituSearch      = "";
 	private String typappSearch    = "";
 	private String agglocomSearch  = "";

    public SearchSitesPage() {

    	//Formulaire de recherche
    	formSearch.setColumns(3);
    	formSearch.setButtonAlign("center");
    	formSearch.setLabelAlign("left");
    	formSearch.setLabelsPosition("top");

		//Territoire
		formSearch.add(territoireSelect);

		//Canton
		formSearch.add(cantonSelect);

		//Commune
		commune.setMaxLength(50);
		
commune.setAttribute("onfocus","this.value=this.value.toUpperCase();");
        formSearch.add(commune);
        
		//Agglomération de communes
		formSearch.add(agglocomSelect);
        
		//N° de site
    	numero.setMaxLength(10);
    	numero.setMinLength(4);
    	//numero.setPattern(patternNumero);
    	formSearch.add(numero);
    	
    	//Nom usuel
    	nom.setMaxLength(50);
    	formSearch.add(nom);

		//Lieu dit
    	lieudit.setMaxLength(50);
    	formSearch.add(lieudit);

		//Adresse
     	adresse.setMaxLength(50);
    	formSearch.add(adresse,2);
    	
		//Mots clés Immobilier
		motcle1.setMaxLength(50);
    	formSearch.add(motcle1);
    	
		//Mots clés Mobilier
		motcle2.setMaxLength(50);
    	formSearch.add(motcle2);
    	
		//Mots clés Description
		motcle3.setMaxLength(50);
    	formSearch.add(motcle3);
    	
    	//Label Mot clés
    	Label label = new Label("<i>Les mot clés multiples doivent être séparés 
par une virgule</i>");
    	formSearch.add(label,3);
    	
		//Datation
		formSearch.add(datationSelect);

		//Datation2
    	datation2.setMaxLength(50);
    	formSearch.add(datation2);
    	
    	//Année
		annee.setMaxLength(20);
    	formSearch.add(annee);
    	
		//Type de site
		formSearch.add(typsiteSelect);
 
		//Occupation
		formSearch.add(occupationSelect);	
    	
    	//Type d'approche
    	formSearch.add(typapprocheSelect);
    	
    	//Titulaire
		titulaire.setMaxLength(50);
    	formSearch.add(titulaire);    	
    	
    	//Vedette Biblio
    	refBiblio.setMaxLength(50);
        formSearch.add(refBiblio);
        
    	//Lieu de conservation
    	conserv.setMaxLength(50);
        formSearch.add(conserv,2);

    	Submit searchButton = new Submit(" Rechercher ");
    	searchButton.setAttribute("class","button");
    	formSearch.add(searchButton);

       	//ActionButton clearButton = new ActionButton("Effacer les critères", 
this, "onClear");
        ActionLink clearLink = new ActionLink("Effacer les critères", this, 
"onClear");
    	//clearLink.setAttribute("class","button");
    	formSearch.add(clearLink);
    	
    	Submit printButton = new PageSubmit("Sites par Commune", 
SitesCommunePage.class);    	
    	printButton.setAttribute("class","button");
    	formSearch.add(printButton);
    }

    public void buildSelects() {
    	typsiteSelect.add(new Option(0,"TYPE"));
    	typsiteSelect.addAll(new TypsiteDAO().findAll(),"id","libelle");

		datationSelect.add(new Option(0,"DATATION"));
		datationSelect.addAll(new 
DatationDAO().findAll(),"id","libelle");

		occupationSelect.add(new Option(0,"OCCUPATION"));
		occupationSelect.addAll(new 
OccupationDAO().findAll(),"libelle","libelle");

		territoireSelect.add(new Option(0,"TERRITOIRE"));
		territoireSelect.addAll(new 
TerritoireDAO().findAll(),"numTerritoire","libTerritoire");
		
    	typapprocheSelect.add(new Option(0,"TYPE APPROCHE"));
    	typapprocheSelect.addAll(new TypapprocheDAO().findAll(),"id","libelle");
    	
    	agglocomSelect.add(new Option(0,"AGGLO/COMMUNES"));
    	agglocomSelect.addAll(new 
AgglocomDAO().findAll(),"numAgglocom","libAgglocom");

		cantonSelect.add(new Option(0,"CANTON"));
		cantonSelect.addAll(new 
CantonDAO().findAll(),"numCanton","libCanton");   
    }    

    public boolean onClear() {
        formSearch.clearValues();
        return true;
    }
       
    public void onInit() {

        super.onInit();

        buildSelects(); 
        
        if (getContext().hasSessionAttribute("utilisateur"))
			utilisateur = 
(Utilisateur)getContext().getSessionAttribute("utilisateur");
        
        if (!utilisateur.getRole().equals("Utilisateur")) {
    		Submit addButton = new PageSubmit("Ajouter un Site", 
AddSitePage.class);
        	addButton.setAttribute("class","button");
        	formSearch.add(addButton);
        }
    }

    public void onSearch() {

    	nomSearch       = nom.getValue().trim();
        typsiteSearch   = typsiteSelect.getValue();
        datationSearch  = datationSelect.getValue();
        datation2Search = datation2.getValue().trim();
        terrSearch      = territoireSelect.getValue();
        canSearch       = cantonSelect.getValue();
        comSearch       = commune.getValue();
        occupSearch     = occupationSelect.getValue();
        numSearch       = numero.getValue().trim();
        lieuditSearch   = lieudit.getValue().trim();
        adresseSearch   = adresse.getValue().trim();
        refBiblioSearch = refBiblio.getValue().trim();
        motcle1Search    = motcle1.getValue().trim();
        motcle2Search    = motcle2.getValue().trim();
        motcle3Search    = motcle3.getValue().trim();
        conservSearch   = conserv.getValue().trim();
        anneeSearch     = annee.getValue().trim();
        tituSearch      = titulaire.getValue().trim();
        typappSearch    = typapprocheSelect.getValue();
        agglocomSearch  = agglocomSelect.getValue();

        //Mise en session des critères renseignés si recherche
        if (getContext().isPost()) {

            if (typsiteSearch.equals("0"))  typsiteSearch  = "";
        	if (datationSearch.equals("0")) datationSearch = "";
            if (terrSearch.equals("0"))     terrSearch     = "";
            if (canSearch.equals("0"))      canSearch      = "";
        	//if (comSearch.equals("0"))    comSearch      = "";
        	if (occupSearch.equals("0"))    occupSearch    = "";
        	if (typappSearch.equals("0"))   typappSearch   = "";
        	if (agglocomSearch.equals("0")) agglocomSearch = "";

            getContext().setSessionAttribute("nom",nomSearch);
            getContext().setSessionAttribute("typsite",typsiteSearch);
            getContext().setSessionAttribute("datation",datationSearch);
            getContext().setSessionAttribute("datation2",datation2Search);
            getContext().setSessionAttribute("territoire",terrSearch);
            getContext().setSessionAttribute("canton",canSearch);
            getContext().setSessionAttribute("commune",comSearch);
            getContext().setSessionAttribute("occupation",occupSearch);
            getContext().setSessionAttribute("numero",numSearch);
            getContext().setSessionAttribute("lieudit",lieuditSearch);
            getContext().setSessionAttribute("adresse",adresseSearch);
            getContext().setSessionAttribute("refBiblio",refBiblioSearch);
            getContext().setSessionAttribute("motcle1",motcle1Search);
            getContext().setSessionAttribute("motcle2",motcle2Search);
            getContext().setSessionAttribute("motcle3",motcle3Search);
            getContext().setSessionAttribute("conserv",conservSearch);
            getContext().setSessionAttribute("annee",anneeSearch);
            getContext().setSessionAttribute("titulaire",tituSearch);
            getContext().setSessionAttribute("typapp",typappSearch);
            getContext().setSessionAttribute("agglocom",agglocomSearch);
        }
        //Récupération des critères de recherche en session s'ils existent
        else {
        	if (getContext().hasSessionAttribute("nom")) {
        		nomSearch = 
(String)getContext().getSessionAttribute("nom");
        		nom.setValue(nomSearch);
        	}
        	if (getContext().hasSessionAttribute("typsite")) {
        		typsiteSearch = 
(String)getContext().getSessionAttribute("typsite");
        		typsiteSelect.setValue(typsiteSearch);
        	} else typsiteSearch = "";
        	if (getContext().hasSessionAttribute("datation")) {
        		datationSearch = 
(String)getContext().getSessionAttribute("datation");
        		datationSelect.setValue(datationSearch);
        	} else datationSearch = "";
        	if (getContext().hasSessionAttribute("datation2")) {
        		datation2Search = 
(String)getContext().getSessionAttribute("datation2");
        		datation2.setValue(datation2Search);
        	} else datation2Search = "";
        	if (getContext().hasSessionAttribute("territoire")) {
        		terrSearch = 
(String)getContext().getSessionAttribute("territoire");
        		territoireSelect.setValue(terrSearch);
        	} else terrSearch = "";
        	if (getContext().hasSessionAttribute("canton")) {
        		canSearch = 
(String)getContext().getSessionAttribute("canton");
        		//communeSelect.setValue(comSearch);
        		cantonSelect.setValue(canSearch);
        	} else canSearch = "";
        	if (getContext().hasSessionAttribute("commune")) {
        		comSearch = 
(String)getContext().getSessionAttribute("commune");
        		//communeSelect.setValue(comSearch);
        		commune.setValue(comSearch);
        	} else comSearch = "";
        	if (getContext().hasSessionAttribute("occupation")) {
        		occupSearch = 
(String)getContext().getSessionAttribute("occupation");
        		occupationSelect.setValue(occupSearch);
        	} else occupSearch = "";
        	if (getContext().hasSessionAttribute("numero")) {
        		numSearch = 
(String)getContext().getSessionAttribute("numero");
        		numero.setValue(numSearch);
        	}
        	if (getContext().hasSessionAttribute("lieudit")) {
        		lieuditSearch = 
(String)getContext().getSessionAttribute("lieudit");
        		lieudit.setValue(lieuditSearch);
        	}
        	if (getContext().hasSessionAttribute("adresse")) {
        		adresseSearch = 
(String)getContext().getSessionAttribute("adresse");
        		adresse.setValue(adresseSearch);
        	}
        	if (getContext().hasSessionAttribute("refBiblio")) {
        		refBiblioSearch = 
(String)getContext().getSessionAttribute("refBiblio");
        		refBiblio.setValue(refBiblioSearch);
        	}
        	if (getContext().hasSessionAttribute("motcle1")) {
        		motcle1Search = 
(String)getContext().getSessionAttribute("motcle1");
        		motcle1.setValue(motcle1Search);
        	}
        	if (getContext().hasSessionAttribute("motcle2")) {
        		motcle2Search = 
(String)getContext().getSessionAttribute("motcle2");
        		motcle2.setValue(motcle2Search);
        	}
        	if (getContext().hasSessionAttribute("motcle3")) {
        		motcle3Search = 
(String)getContext().getSessionAttribute("motcle3");
        		motcle3.setValue(motcle3Search);
        	}
        	if (getContext().hasSessionAttribute("conserv")) {
        		conservSearch = 
(String)getContext().getSessionAttribute("conserv");
        		conserv.setValue(conservSearch);
        	}
        	if (getContext().hasSessionAttribute("annee")) {
        		anneeSearch = 
(String)getContext().getSessionAttribute("annee");
        		annee.setValue(anneeSearch);
        	}
        	if (getContext().hasSessionAttribute("titulaire")) {
        		tituSearch = 
(String)getContext().getSessionAttribute("titulaire");
        		titulaire.setValue(tituSearch);
        	}
        	if (getContext().hasSessionAttribute("typapp")) {
        		typappSearch = 
(String)getContext().getSessionAttribute("typapp");
        		typapprocheSelect.setValue(typappSearch);
        	} else typappSearch = "";
        	if (getContext().hasSessionAttribute("agglocom")) {
        		agglocomSearch = 
(String)getContext().getSessionAttribute("agglocom");
        		agglocomSelect.setValue(agglocomSearch);
        	} else agglocomSearch = "";
        }
    }
    
    public void onPost() {
    	onSearch();
    	
		sites = new SiteDAO().findByCriteria(nomSearch, typsiteSearch, 
datationSearch, datation2Search, terrSearch, canSearch, 
				 agglocomSearch, comSearch, occupSearch, 
numSearch, lieuditSearch, adresseSearch, 
				 refBiblioSearch, motcle1Search, motcle2Search, 
motcle3Search,conservSearch, anneeSearch, tituSearch, typappSearch);		
		
		sizeListe = sites.size();        

		if (sites.isEmpty()) 
			formSearch.setError("<strong>Aucun site ne correspond à 
votre recherche</strong>");
		else {
			//Mise en session de la liste des Sites
			getContext().setSessionAttribute("sites",sites);

			//Redirection vers la liste des sites
			setRedirect(SitesPage.class);
		}
	}
    
    public void onGet() {
    	onSearch();
    } 

    public boolean onSecurityCheck() {

        if (getContext().hasSession())
            return true;
        else {
            setRedirect(LoginPage.class);
            return false;
        }
    }
}





Re: ActionButton seems not working with Apache Click 2.3.0

Posted by Malcolm Edgar <ma...@gmail.com>.
Hi,

You will need to provide more information to get any assistance.  Can
you include the page source.

regards Malcolm Edgar

On Fri, Apr 29, 2011 at 12:17 AM, easydoor958
<ch...@valdoise.fr> wrote:
> When i put in a search form an ActionButton which allows user to clear values in
> the fields to reset criterias.
> I put this code
> ActionButton clearButton = new ActionButton("Effacer les critères", this,
> "onClear");
> ...
>    public boolean onClear() {
>        formSearch.clearValues();
>        return true;
>    }
> and when i click on the button, nothing happens
>
> I change ActionButton by an ActionLink and it works well ! Why ?
>
>

Re: ActionButton seems not working with Apache Click 2.3.0

Posted by easydoor958 <ch...@valdoise.fr>.
Gilberto recognizes there is a problem ...
Is anyone has an idea to solve this one ? it becomes urgent for me !



Re: ActionButton seems not working with Apache Click 2.3.0

Posted by Gilberto <gi...@gmail.com>.
On Mon, May 2, 2011 at 7:17 AM, easydoor958
<ch...@valdoise.fr>wrote:

> Hi Gilberto,
>
> Nothing changes if i add addControl(clearButton);
>
> With Eclipse Debugger, the program pointer doesn't reach the onClear()
> method
> that's why it doesn't work ...
>
> If I change this line
> ActionButton clearButton  = new ActionButton("Effacer les critères", this,
> "onClear");
> by this one
>

I think you are right! Now I can see that has something incoherent with
ActionButton:
-- it represents <input type="button"/> [1]
-- but it can't be added to the form, because the docs advice [2]

Well, one more question: is the ActionButton a form's attribute or not?[3]

Regards,

Gilberto

[1] http://www.htmlcodetutorial.com/forms/_INPUT_TYPE_BUTTON.html
[2]
http://click.apache.org/docs/click-api/org/apache/click/control/ActionButton.html
[3] http://dl.dropbox.com/u/9093640/form.htm |
http://dl.dropbox.com/u/9093640/FormPage.java

Re: ActionButton seems not working with Apache Click 2.3.0

Posted by easydoor958 <ch...@valdoise.fr>.
Hi Gilberto,

Nothing changes if i add addControl(clearButton);

With Eclipse Debugger, the program pointer doesn't reach the onClear() method
that's why it doesn't work ...

If I change this line 
ActionButton clearButton  = new ActionButton("Effacer les critères", this, 
"onClear");
by this one 
Button clearButton  = new Submit("Effacer les critères", this, "onClear");
it works  !!! but finally i don't want to implement this solution in my case ...

Why this behavior ? Please help me !





Re: ActionButton seems not working with Apache Click 2.3.0

Posted by Gilberto <gi...@gmail.com>.
On Thu, Apr 28, 2011 at 11:17 AM, easydoor958 <christophe.foiret@valdoise.fr
> wrote:

> When i put in a search form an ActionButton which allows user to clear
> values in
> the fields to reset criterias.
> I put this code
> ActionButton clearButton = new ActionButton("Effacer les critères", this,
> "onClear");
> ...
>    public boolean onClear() {
>        formSearch.clearValues();
>        return true;
>    }
> and when i click on the button, nothing happens
>
> I change ActionButton by an ActionLink and it works well ! Why ?
>
> Taking the note from here:
http://click.apache.org/docs/click-api/org/apache/click/control/ActionButton.html
<quote>
Please Note do not add ActionButton instances to the Form object, as the GET
request it generates will never be processed by the Form, and in turn the
Form will not invoke the ActionButton's onProcess() method.
</quote>

So, you need do this: addControl(clearButton);

Hth,

Gilberto