@@ -117,19 +117,23 @@ public void decode(FacesContext context, UIComponent component, String component
117
117
}
118
118
}
119
119
120
+ boolean addEventToQueue =false ;
120
121
if (component instanceof ActionSource ) {
121
122
ActionSource b = (ActionSource ) component ;
122
123
ActionListener [] actionListeners = b .getActionListeners ();
123
124
if (null != actionListeners && actionListeners .length > 0 ) {
124
- component . queueEvent ( new ActionEvent ( component )) ;
125
+ addEventToQueue = true ;
125
126
}
126
127
}
127
128
if (component instanceof ActionSource2 ) {
128
129
MethodExpression actionExpression = ((ActionSource2 ) component ).getActionExpression ();
129
130
if (null != actionExpression ) {
130
- component . queueEvent ( new ActionEvent ( component )) ;
131
+ addEventToQueue = true ;
131
132
}
132
133
}
134
+ if (addEventToQueue ) {
135
+ component .queueEvent (new ActionEvent (component ));
136
+ }
133
137
}
134
138
}
135
139
@@ -176,38 +180,39 @@ public static void generateBootsFacesAJAXAndJavaScript(FacesContext context, Cli
176
180
script += ";return false;" ;
177
181
rw .writeAttribute ("on" + defaultEvent , script , null );
178
182
}
179
- // else {
180
- // boolean generateNonAJAXCommand = false;
181
- // if (component instanceof ActionSource) {
182
- // ActionSource b = (ActionSource) component;
183
- // ActionListener[] actionListeners = b.getActionListeners();
184
- // if (null != actionListeners && actionListeners.length > 0) {
185
- // generateNonAJAXCommand = true;
186
- // }
187
- // }
188
- // if (component instanceof ActionSource2) {
189
- // MethodExpression actionExpression = ((ActionSource2) component).getActionExpression();
190
- // if (null != actionExpression) {
191
- // generateNonAJAXCommand = true;
192
- // }
193
- // }
194
- // if (generateNonAJAXCommand && component instanceof IAJAXComponent) {
195
- // // rw.writeAttribute("id", getClientId() + "_a", null);
196
- // generateOnClickHandler(context, rw, (IAJAXComponent) component);
197
- // }
198
- // }
183
+ else if (!(component instanceof CommandButton )) {
184
+ // b:navCommandLink doesn't submit the form, so we need to use AJAX
185
+ boolean generateNonAJAXCommand = false ;
186
+ if (component instanceof ActionSource ) {
187
+ ActionSource b = (ActionSource ) component ;
188
+ ActionListener [] actionListeners = b .getActionListeners ();
189
+ if (null != actionListeners && actionListeners .length > 0 ) {
190
+ generateNonAJAXCommand = true ;
191
+ }
192
+ }
193
+ if (component instanceof ActionSource2 ) {
194
+ MethodExpression actionExpression = ((ActionSource2 ) component ).getActionExpression ();
195
+ if (null != actionExpression ) {
196
+ generateNonAJAXCommand = true ;
197
+ }
198
+ }
199
+ if (generateNonAJAXCommand && component instanceof IAJAXComponent ) {
200
+ // rw.writeAttribute("id", getClientId() + "_a", null);
201
+ generateOnClickHandler (context , rw , (IAJAXComponent ) component );
202
+ }
203
+ }
199
204
200
205
}
201
206
}
202
207
203
- // private static void generateOnClickHandler(FacesContext context, ResponseWriter rw, IAJAXComponent component)
204
- // throws IOException {
205
- // StringBuilder cJS = new StringBuilder(150); // optimize int
206
- //
207
- // cJS.append(encodeClick(component)).append("return BsF.ajax.cb(this, event);");
208
- //
209
- // rw.writeAttribute("onclick", cJS.toString(), null);
210
- // }
208
+ private static void generateOnClickHandler (FacesContext context , ResponseWriter rw , IAJAXComponent component )
209
+ throws IOException {
210
+ StringBuilder cJS = new StringBuilder (150 ); // optimize int
211
+
212
+ cJS .append (encodeClick (component )).append ("return BsF.ajax.cb(this, event);" );
213
+
214
+ rw .writeAttribute ("onclick" , cJS .toString (), null );
215
+ }
211
216
212
217
private static boolean generateAJAXCallForASingleEvent (FacesContext context , ClientBehaviorHolder component ,
213
218
ResponseWriter rw , String specialEvent , String specialEventHandler , boolean isJQueryCallback ,
0 commit comments