Bonjour à tous,

J'ai déjà créé des widgets, mais cette fois-ci il semble que ça coince au moment du "parsing".

Je voudrais donc créer un widget qui permet de gérer des verrous et qui contient dijit.form.Button permettant de changer l'état en vérouillé/dévérouillé. Le truc tou c** quoi...

Mais j'ai l'erreur suivante :
Error undefined running custom onLoad code: This deferred has already been resolved


Petite précision, j'utilise mon widget de manière déclarative :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
<div data-dojo-type="lib.widgets.LockPanel"></div>
voici mon widget :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
dojo.provide("lib.widgets.LockPanel");
 
dojo.require("dijit._TemplatedMixin");
dojo.require("dijit._Widget");
dojo.require("dijit.form.Button");
dojo.require("dijit.Dialog");
 
dojo.require("dojo.parser");
 
dojo.declare('lib.widgets.LockPanel', [dijit._Widget, dijit._TemplatedMixin], {
	// Path to template
	templateString : dojo.cache("lib", "widgets/templates/LockPanel.html"),
	// The widget includes others widgets
	widgetsInTemplate : true,
	// properties
	usernameTag:"%username%",
	lockedMessage:"Locked by %username%.",
	unlockedMessage:"The lock is free.",
	// Events to be overridden
	onRefresh:function(){alert("refresh");},
	onLock:function(){alert("lock");},
	onUnlock:function(){alert("unlock");},
	// Methods
	reset:function(){
		this._setLocked();
	},
	postCreate:function(){
		dojo.connect(this.lockBtn, "ondijitclick", this, "onRefresh");
		dojo.connect(this.lockBtn, "ondijitclick", this, "onLock");
		dojo.connect(this.unlockBtn, "ondijitclick", this, "onUnlock");
		/**
		 * Hide the lock and unlock buttons
		 */
		this.hideLockButton();
		this.hideUnlockButton();
	},
	/**
	 * Toggle the panel to locked mode
	 * @param isLockedByCurrentUser : 
	 * @param lockedByName : the name of the user who locks.
	 */
	setLocked:function(/*boolean*/isLockedByCurrentUser, /*String*/lockedByName){
		/**
		 * If no usernameTag is given in the locked message, then just display it.
		 */
		if(null==usernameTag || usernameTag=="" || !this.lockedMessage.match(this.usernameTag)){
			this.message.innerHTML = this.lockedMessage;
		}
		/**
		 * If the lock is taken by the current user, then replace the name by "yourself".
		 */
		if(isLockedByCurrentUser){
			lockedByName = " yourself.";
		}
		/**
		 * Display the message.
		 */
		this.message.innerHTML = this.lockedMessage.replace(lockedByName);
		/**
		 * Hide the lock button
		 */
		this.hideLockButton();
		/**
		 * Hide/Show the unlock button
		 */
		if(isLockedByCurrentUser){
			this.showUnlockButton();
		}
		else{
			this.hideUnlockButton();
		}
	},
	/**
	 * Toggle the panel to unlocked mode
	 */
	setUnlocked:function(){
		this.message.innerHTML = this.unlockedMessage;
		/**
		 * Show the lock button
		 */
		this.showLockButton();
		/**
		 * Hide the unlock button
		 */
		this.hideUnlockButton();
	},
	hideLockButton:function(){
		console.log("Hiding lock button...");
		dojo.style(this.lockBtn, "display", "none");
		console.log("Lock button hidden.");
	},
	hideUnlockButton:function(){
		console.log("Hiding unlock button...");
		dojo.style(this.unlockBtn, "display", "none");
		console.log("Unlock button hidden.");
	},
	showLockButton:function(){
		dojo.style(this.lockBtn, "display", "inline");
	},
	showUnlockButton:function(){
		dojo.style(this.unlockBtn, "display", "inline");
	}
});
Et le template
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
<div>
	<input type="button" data-dojo-attach-point="refreshBtn" data-dojo-type="dijit.form.Button" data-dojo-props="label:'Refresh'"/>
	<span data-dojo-attach-point="message"></span>
	<input type="button" data-dojo-attach-point="lockBtn" data-dojo-type="dijit.form.Button" data-dojo-props="label:'Lock'"/>
	<input type="button" data-dojo-attach-point="unlockBtn" data-dojo-type="dijit.form.Button" data-dojo-props="label:'Unlock'"/>
</div>
D'où pensez-vous que peut venir l'erreur ?