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
| /**
*
*/
package pagecode;
import com.ibm.etools.webservice.context.Context;
import com.ibm.faces.component.html.HtmlScriptCollector;
import javax.faces.application.FacesMessage;
import javax.faces.component.html.HtmlForm;
import javax.faces.component.html.HtmlInputText;
import controller.CtrlApplication;
import javax.faces.event.ValueChangeEvent;
import javax.faces.context.FacesContext;
import java.lang.Object;
import java.util.Date;
import java.util.GregorianCalendar;
import javax.faces.component.UIComponent;
import javax.faces.component.UIInput;
import javax.faces.component.html.HtmlMessage;
import com.ibm.faces.component.html.HtmlCommandExButton;
import javax.servlet.http.*;
/**
* @author csicilia
*
*/
public class NewRecord extends PageCodeBase {
protected HtmlScriptCollector scriptCollector1;
protected HtmlForm form1;
protected HtmlInputText app_id1;
protected CtrlApplication ctrlApps;
protected HtmlMessage message1;
protected HtmlInputText app_code1;
protected HtmlInputText app_lib1;
protected HtmlInputText app_strdate1;
protected HtmlInputText app_enddate1;
protected HtmlCommandExButton button1;
protected HtmlCommandExButton button2;
protected HtmlScriptCollector getScriptCollector1() {
if (scriptCollector1 == null) {
scriptCollector1 = (HtmlScriptCollector) findComponentInRoot("scriptCollector1");
}
return scriptCollector1;
}
protected HtmlForm getForm1() {
if (form1 == null) {
form1 = (HtmlForm) findComponentInRoot("form1");
}
return form1;
}
protected HtmlInputText getApp_id1() {
if (app_id1 == null) {
app_id1 = (HtmlInputText) findComponentInRoot("app_id1");
}
return app_id1;
}
public String doButton2Action() {
// Entrez le code Java qui s'exécute lorsque le composant est cliqué
// TODO: Renvoyez la sortie qui correspond à une règle de navigation
return "retour";
}
public String doButton1Action() {
// Entrez le code Java qui s'exécute lorsque le composant est cliqué
getCtrlApps().insertRecord();
return "retour";}
//}
/**
* @managed-bean true
*/
protected CtrlApplication getCtrlApps() {
if (ctrlApps == null) {
ctrlApps = (CtrlApplication) getManagedBean("ctrlApps");
}
return ctrlApps;
}
/**
* @managed-bean true
*/
protected void setCtrlApps(CtrlApplication ctrlApps) {
this.ctrlApps = ctrlApps;
}
public void valideId(){
//getCtrlApps().validateid(app_id1);
}
protected HtmlMessage getMessage1() {
if (message1 == null) {
message1 = (HtmlMessage) findComponentInRoot("message1");
}
return message1;
}
protected HtmlInputText getApp_code1() {
if (app_code1 == null) {
app_code1 = (HtmlInputText) findComponentInRoot("app_code1");
}
return app_code1;
}
protected HtmlInputText getApp_lib1() {
if (app_lib1 == null) {
app_lib1 = (HtmlInputText) findComponentInRoot("app_lib1");
}
return app_lib1;
}
protected HtmlInputText getApp_strdate1() {
if (app_strdate1 == null) {
app_strdate1 = (HtmlInputText) findComponentInRoot("app_strdate1");
}
return app_strdate1;
}
protected HtmlInputText getApp_enddate1() {
if (app_enddate1 == null) {
app_enddate1 = (HtmlInputText) findComponentInRoot("app_enddate1");
}
return app_enddate1;
}
protected HtmlCommandExButton getButton1() {
if (button1 == null) {
button1 = (HtmlCommandExButton) findComponentInRoot("button1");
}
return button1;
}
protected HtmlCommandExButton getButton2() {
if (button2 == null) {
button2 = (HtmlCommandExButton) findComponentInRoot("button2");
}
return button2;
}
public boolean verifdate(){
GregorianCalendar a =new GregorianCalendar();
GregorianCalendar b =new GregorianCalendar();
a.setTime((Date)getCtrlApps().getApplication().getApp_strdate().getTime());
b.setTime((Date)getCtrlApps().getApplication().getApp_enddate().getTime());
if(a.getTime().before(b.getTime()))
return true;
return false;
}
public void handleApp_enddate1Validate(FacesContext facescontext,
UIComponent component, Object object)
throws javax.faces.validator.ValidatorException {
// Tapez ici le code Java servant à la validation
// void validate(FacesContext facescontext, UIComponent component, Object object) throws ValidatorException
if(object!=null){
FacesMessage msg= new FacesMessage("Erreur!!la date de fin est inférieure à la date de début");
GregorianCalendar debut =new GregorianCalendar();
debut.setTime((Date)getApp_strdate1().getValue());
GregorianCalendar fin = new GregorianCalendar();
fin.setTime((Date) object);
if(debut.after(fin)){
facescontext.addMessage(component.getClientId(facescontext), msg);
((UIInput)component).setValid(false);
}
}
}
public void handleApp_strdate1Validate(FacesContext facescontext,
UIComponent component, Object object)
throws javax.faces.validator.ValidatorException {
FacesMessage msg = new FacesMessage("Date inférieure à la date du jour!!!");
GregorianCalendar date=new GregorianCalendar();
GregorianCalendar date2= new GregorianCalendar();
date.setTime((Date) object);
if(date.getTime().before(date2.getTime())){
facescontext.addMessage(getApp_strdate1().getClientId(facescontext), msg);
((UIInput)component).setValid(false);
}
}
} |
Partager