eliot.textes.impression.Application = function () {
- var Clazz = Ext.extend(Ext.util.Observable, {
+ var Clazz = Ext.extend(Ext.util.Observable, {
- constructor:function () {
+ constructor:function () {
- this.attente();
- },
+ this.attente();
+ },
+
+ attente:function () {
+ var task = {
+ scope:this,
+ run:function () {
+
+ Ext.Ajax.request({
+ url:eliot.textes.impression.Constantes.urlGetStatus,
+ params:{demandeId:eliot.textes.impression.Modele.demandeId},
+ success:function (response, request) {
+
+ var reponse = Ext.decode(response.responseText);
+
+
+ if (reponse.statut == eliot.textes.impression.Constantes.TERMINEE) {
+
+ this.finPreparationPdf();
+ }
+
+ if (reponse.statut == 'ERREUR') {
+
+ this.erreurImpression(reponse.message);
+ }
+ },
+ scope:this,
+ failure:function () {
+ eliot.textes.Messages.showErreur(
+ eliot.textes.Modele.message.ajoutDemandeImpressionErreur
+ );
+ }
+ });
- attente:function () {
- var task = {
- scope:this,
- run:function () {
-
- Ext.Ajax.request({
- url:eliot.textes.impression.Constantes.urlGetStatus,
- params:{demandeId:eliot.textes.impression.Modele.demandeId},
- success:function (response, request) {
-
- var reponse = Ext.decode(response.responseText);
-
- if (reponse.statut == eliot.textes.impression.Constantes.TERMINEE) {
-
- this.finPreparationPdf();
- }
- },
- scope:this,
- failure:function () {
- eliot.textes.Messages.showErreur(
- eliot.textes.Modele.message.ajoutDemandeImpressionErreur
- );
- }
- });
-
- },
- interval:2000
- };
-
- this.runner = new Ext.util.TaskRunner();
- this.tache = this.runner.start(task);
},
+ interval:2000
+ };
+
+ this.runner = new Ext.util.TaskRunner();
+ this.tache = this.runner.start(task);
+ },
+
+ finPreparationPdf:function () {
+ this.runner.stop(this.tache);
+
+ var url = eliot.textes.impression.Constantes.urlPdf +
+ "?id=" +
+ eliot.textes.impression.Modele.demandeId;
+
+ document.location.href = url;
+ },
+
- finPreparationPdf:function () {
- this.runner.stop(this.tache);
+ erreurImpression:function (message) {
+ this.runner.stop(this.tache);
- var url = eliot.textes.impression.Constantes.urlPdf +
- "?id=" +
- eliot.textes.impression.Modele.demandeId;
+ var url = eliot.textes.impression.Constantes.urlDirecteErreur +
+ '?message=' + message;
- document.location.href = url;
- }
+ document.location.href = url;
+ }
- });
+ });
- return new Clazz();
+ return new Clazz();
}();
\ No newline at end of file