click-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christophe FOIRET (JIRA)" <j...@apache.org>
Subject [jira] Commented: (CLK-582) No field validation on FormTable
Date Mon, 07 Sep 2009 09:47:57 GMT

    [ https://issues.apache.org/jira/browse/CLK-582?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12752072#action_12752072
] 

Christophe FOIRET commented on CLK-582:
---------------------------------------

Find below the page test code without references to Hibernate
and the two java beans Intervenant.java et Temps.java

Html code page

<br>
<h2>$title</h2>
<br>
$formSearch
$tableInterv
$tableTps
------------------------------------------------------
Java code test page

package vdo.actedu.page;

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

import net.sf.click.Page;
import net.sf.click.control.Form;
import net.sf.click.control.Option;
import net.sf.click.control.Select;
import net.sf.click.control.Submit;
import net.sf.click.extras.control.FieldColumn;
import net.sf.click.extras.control.FormTable;
import vdo.actedu.hibernate.Atelier;
import vdo.actedu.hibernate.AtelierIntervenant;
import vdo.actedu.hibernate.AtelierTemps;
import vdo.actedu.hibernate.Intervenant;
import vdo.actedu.hibernate.Temps;

public class ZformTablePage extends Page {

	public String title = "Anomalie Form Table";
	//public String atelierId = "";

    public Form formSearch = new Form();

    public FormTable tableInterv = new FormTable();
    public FormTable tableTps = new FormTable();

    Atelier atelier = new Atelier();

    //Déclaration listes de sélection
    private Select atelierSceSelect = new Select("Atelier Source");
    private Select atelierSelect    = new Select("Atelier Cible");
    private Select intervSceSelect  = new Select("nom");
    private Select intervSelect     = new Select("id");
    private Select tempsSceSelect   = new Select();
    private Select tempsSelect      = new Select();

    //List<Atelier> ateliers = new AtelierDAO().findAll();
    List<AtelierIntervenant> intervenantsSce = null;
    List<AtelierIntervenant> intervenantsCible = null;
    List<AtelierTemps> tempsSce = null;
    List<AtelierTemps> tempsCible = null;

    public ZformTablePage() {

    	//Formulaire intégrant la liste de sélection Atelier Cible
    	formSearch.setErrorsPosition("middle");
    	formSearch.setLabelAlign("right");

    	atelierSceSelect.setReadonly(true);
    	formSearch.add(atelierSceSelect);

		atelierSelect.addAll(new String[] {"","Atelier Cible 1","Atelier Cible 2","Atelier Cible
3"});
		atelierSelect.setListener(this,"onChangeAtelier");
    	atelierSelect.setAttribute("onChange","form.submit()");
    	formSearch.add(atelierSelect);

    	//Tableau listant les Intervenants de l'atelier Cible
        tableInterv.setClass("cgvo");
        tableInterv.setHoverRows(true);
    	tableInterv.getForm().setErrorsPosition("middle");
    	tableInterv.getForm().setButtonAlign("center");
    	tableInterv.getForm().setLabelAlign("right");

    	FieldColumn column = new FieldColumn("id","Intervenant Source", intervSceSelect);
        column.getField().setReadonly(true);
        tableInterv.addColumn(column);

        column = new FieldColumn("nom","Intervenant Cible", intervSelect);
        column.getField().setRequired(true);
        tableInterv.addColumn(column);

    	//Tableau listant les Temps de l'atelier Cible
        tableTps.setClass("cgvo");
        tableTps.setHoverRows(true);
    	tableTps.getForm().setErrorsPosition("middle");
    	tableTps.getForm().setButtonAlign("center");
    	tableTps.getForm().setLabelAlign("right");

    	column = new FieldColumn("id","Temps Source", tempsSceSelect);
    	column.getField().setReadonly(true);
        tableTps.addColumn(column);

        column = new FieldColumn("libelle","Temps Cible", tempsSelect);
        column.getField().setRequired(true);
        tableTps.addColumn(column);

    	//Boutons Valider et Retour liés aux TableForm
    	Submit validButton = new Submit("    Valider    ", this, "onValid");
    	validButton.setAttribute("class","button1");

    	tableTps.getForm().add(validButton);
    }

    public boolean onChangeAtelier() {

    	//Peuplement de la table des Intervenants de l'Atelier Source
    	List<Intervenant> list = new ArrayList<Intervenant>();
    	list.add(new Intervenant(1,"Interv Sce 1"));
    	list.add(new Intervenant(2,"Interv Sce 2"));
    	list.add(new Intervenant(3,"Interv Sce 3"));

    	intervSceSelect.addAll(list,"id","nom");
    	tableInterv.setRowList(list);

    	//Peuplement de la liste de sélection des Intervenants Cible
    	List<Intervenant> list2 = new ArrayList<Intervenant>();
    	list2.add(new Intervenant(1,"Interv Cible 1"));
    	list2.add(new Intervenant(2,"Interv Cible 2"));
    	list2.add(new Intervenant(3,"Interv Cible 3"));
    	intervSelect.add(new Option(0,""));
    	intervSelect.addAll(list2,"id","nom");

    	//Peuplement de la table des Temps de l'Atelier Source
    	List<Temps> list3 = new ArrayList<Temps>();
    	list3.add(new Temps(1,"Temps Sce 1"));
    	list3.add(new Temps(2,"Temps Sce 2"));

    	tempsSceSelect.addAll(list3,"id","libelle");
        tableTps.setRowList(list3);

    	//Peuplement de la liste de sélection des Temps Cible
    	List<Temps> list4 = new ArrayList<Temps>();
    	list4.add(new Temps(1,"Temps Cible 1"));
    	list4.add(new Temps(2,"Temps Cible 2"));
    	list4.add(new Temps(3,"Temps Cible 3"));
    	tempsSelect.add(new Option(0,""));
    	tempsSelect.addAll(list4,"id","libelle");

    	return true;
    }

    public void onInit() {
    	atelierSceSelect.add("Atelier Source");
    }

    public boolean onValid() {

    	if (tableInterv.getForm().isValid() && tableTps.getForm().isValid()) {

    	}
        return true;
    }
}
-------------------------------------------------------------
Intervenant Java Bean

package vdo.actedu.hibernate;

public class Intervenant  {

    private int id;
    private String nom;

    public  Intervenant() {
    }

    public  Intervenant(int id, String nom) {
    	this.id = id;
        this.nom = nom;
    }

        public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getNom() {
		return nom;
	}

	public void setNom(String nom) {
		this.nom = nom;
	}
}
---------------------------------------------------
Temps java Bean

package vdo.actedu.hibernate;

public class Temps {

    private int id ;
    private String libelle;

    public  Temps() {
    }

    public  Temps(int id, String libelle) {
        this.id = id;
        this.libelle = libelle;
    }

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getLibelle() {
		return libelle;
	}

	public void setLibelle(String libelle) {
		this.libelle = libelle;
	}
}


> No field validation on FormTable
> --------------------------------
>
>                 Key: CLK-582
>                 URL: https://issues.apache.org/jira/browse/CLK-582
>             Project: Click
>          Issue Type: Bug
>          Components: extras
>    Affects Versions: 1.5.3
>         Environment: Linux Apache mySQL
>            Reporter: Christophe FOIRET
>            Priority: Critical
>
> I built a page with a search Form and two FormTable
> When i select a value in the SelectList of the search Form, i fill the two FormTable

> Each FormTable contains a required Field
> When i click on the Valid Button, there is no control and the required fields which are
not filled are not yellow (like in your example), the page is refreshed and the two FormTable
are empty ...
> I tried this case without search Form and the control is well done ... 
> Could you give me quickly an answer to this issue, i think that the search Form disturbs
the Form Table behavior
> See the code below : 
> .htm code file 
> <br>
> <h2>$title</h2>
> <br>
> $formSearch
> $tableInterv
> $tableTps
> .java code file
> package vdo.actedu.page;
> import java.util.List;
> import net.sf.click.control.Form;
> import net.sf.click.control.Option;
> import net.sf.click.control.Select;
> import net.sf.click.control.Submit;
> import net.sf.click.control.TextField;
> import net.sf.click.extras.control.FieldColumn;
> import net.sf.click.extras.control.FormTable;
> import vdo.actedu.hibernate.Atelier;
> import vdo.actedu.hibernate.AtelierDAO;
> import vdo.actedu.hibernate.AtelierIntervenant;
> import vdo.actedu.hibernate.AtelierIntervenantDAO;
> import vdo.actedu.hibernate.AtelierTemps;
> import vdo.actedu.hibernate.AtelierTempsDAO;
> public class MoveInscriptionPage extends BorderPage {
> 	public String title = "Transfert d'inscriptions";
> 	public String atelierId = "";
>     public Form formSearch = new Form();
>     public FormTable tableInterv = new FormTable();
>     public FormTable tableTps = new FormTable();
>     Atelier atelier = new Atelier();
>     //Déclaration listes de sélection
>     private Select atelierSceSelect = new Select("atelier.libelle","Atelier Source");
>     private Select atelierSelect    = new Select("atelier.id","Atelier Cible");
>     private Select intervSceSelect  = new Select("intervenant.nom");
>     private Select intervSelect     = new Select("intervenant.id");
>     private Select tempsSceSelect   = new Select("temps.libelle");
>     private Select tempsSelect      = new Select("temps.id");
>     List<Atelier> ateliers = new AtelierDAO().findAll();
>     List<AtelierIntervenant> intervenantsSce = null;
>     List<AtelierIntervenant> intervenantsCible = null;
>     List<AtelierTemps> tempsSce = null;
>     List<AtelierTemps> tempsCible = null;
>     public MoveInscriptionPage() {
>     	//Formulaire intégrant la liste de sélection Atelier Cible
>     	formSearch.setErrorsPosition("middle");
>     	formSearch.setLabelAlign("right");
>     	atelierSceSelect.setReadonly(true);
>     	formSearch.add(atelierSceSelect);
>     	atelierSelect.add(new Option(0,""));
> 		atelierSelect.addAll(ateliers,"id","libelle");
> 		atelierSelect.setListener(this,"onChangeAtelier");
>     	atelierSelect.setAttribute("onChange","form.submit()");
>     	formSearch.add(atelierSelect);
>     	//Tableau listant les Intervenants de l'atelier Cible
>         tableInterv.setClass("cgvo");
>         tableInterv.setHoverRows(true);
>     	tableInterv.getForm().setErrorsPosition("middle");
>     	tableInterv.getForm().setButtonAlign("center");
>     	tableInterv.getForm().setLabelAlign("right");
>         FieldColumn column = new FieldColumn("intervenant.id", "Intervenant Source",
intervSceSelect);
>         column.getField().setReadonly(true);
>         tableInterv.addColumn(column);
>         column = new FieldColumn("intervenant.nom", "Intervenant Cible", intervSelect);
>         column.getField().setRequired(true);
>         tableInterv.addColumn(column);
>     	//Tableau listant les Temps de l'atelier Cible
>         tableTps.setClass("cgvo");
>         tableTps.setHoverRows(true);
>     	tableTps.getForm().setErrorsPosition("middle");
>     	tableTps.getForm().setButtonAlign("center");
>     	tableTps.getForm().setLabelAlign("right");
>     	column = new FieldColumn("temps.id", "Temps Source", tempsSceSelect);
>     	column.getField().setReadonly(true);
>         tableTps.addColumn(column);
>         column = new FieldColumn("temps.libelle", "Temps Cible", tempsSelect);
>         column.getField().setRequired(true);
>         tableTps.addColumn(column);
>     	//Boutons Valider et Retour liés aux TableForm
>     	Submit validButton = new Submit("    Valider    ", this, "onValid");
>     	validButton.setAttribute("class","button1");
>     	Submit cancelButton = new Submit("   Retour   ", this, "onCancel");
>     	cancelButton.setAttribute("class","button1");
>     	tableTps.getForm().add(validButton);
>     	tableTps.getForm().add(cancelButton);
>     }
>     public boolean onChangeAtelier() {
>     	//Peuplement de la table des Intervenants de l'Atelier Source
>         intervenantsSce = new AtelierIntervenantDAO().findByAtelierString(atelierSceSelect.getValue());
>     	intervSceSelect.addAll(intervenantsSce,"intervenant.id","intervenant.nom");
>         tableInterv.setRowList(intervenantsSce);
>     	//Peuplement de la liste de sélection des Intervenants Cible
>     	intervenantsCible = new AtelierIntervenantDAO().findByAtelier(new Integer(atelierSelect.getValue()));
>     	intervSelect.add(new Option(0,""));
>     	intervSelect.addAll(intervenantsCible,"intervenant.id","intervenant.nom");
>     	//Peuplement de la table des Temps de l'Atelier Source
>         tempsSce = new AtelierTempsDAO().findByAtelierString(atelierSceSelect.getValue());
>         tempsSceSelect.addAll(tempsSce,"temps.id","temps.libelle");
>         tableTps.setRowList(tempsSce);
>     	//Peuplement de la liste de sélection des Temps Cible
>     	tempsCible = new AtelierTempsDAO().findByAtelier(new Integer(atelierSelect.getValue()));
>     	tempsSelect.add(new Option(0,""));
>     	tempsSelect.addAll(tempsCible,"temps.id","temps.libelle");
>     	return true;
>     }
>     public void onInit() {
>     	atelierId = getContext().getRequestParameter("id");
>         //Si l'id de l'atelier est renseigné et que l'on n'est pas en Post (Bouton Enregistrer)
>         if (atelierId != null && !getContext().isPost()) {
>         	//On récupère l'atelier passé en paramètre
>         	atelier = new AtelierDAO().findById(new Integer(atelierId));
>         	//Mise en session de l'Atelier
>         	getContext().setSessionAttribute("atelier",atelier);
>         } else
>         	//On récupère l'atelier de la session
>         	atelier = (Atelier)getContext().getSessionAttribute("atelier");
>         //Mise à jour du libellé de l'Atelier Source
> 		atelierSceSelect.add(atelier.getLibelle());
>     }
>     public boolean onValid() {
>     	if (tableInterv.getForm().isValid() && tableTps.getForm().isValid()) {
>             //Transfert des Inscriptions
>     	}
>         return true;
>     }
>     public boolean onCancel() {
>             setRedirect(AdmAtelierPage.class);
>         return true;
>     }
>     public boolean onSecurityCheck() {
>         if (getContext().hasSession()) {
>             return true;
>         } else {
>             setRedirect(LoginPage.class);
>             return false;
>         }
>     }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message