This feature isn't supported for now. But, you can try your case after making my changes in SentinelMenuRenderer.java
SentinelMenuRenderer.java
Code: Select all
//line 109
protected void encodeMenuItem(FacesContext context, AbstractMenu menu, MenuItem menuitem, int marginLevel) throws IOException {
...
if(disabled) {
writer.writeAttribute("href", "#", null);
writer.writeAttribute("onclick", "return false;", null);
}
else {
setConfirmationScript(context, menuitem); // Please add this line.
String onclick = menuitem.getOnclick();
if(marginLevel == 0) {
onclick = (onclick == null) ? "Sentinel.toggleSubMenu(this)" : "Sentinel.toggleSubMenu(this);" + onclick;
}
...
if(onclick != null) {
// writer.writeAttribute("onclick", onclick, null); Please remove this line and add the following codes
if(menuitem.requiresConfirmation()) {
writer.writeAttribute("data-pfconfirmcommand", onclick, null);
writer.writeAttribute("onclick", menuitem.getConfirmationScript(), "onclick");
}
else {
writer.writeAttribute("onclick", onclick, null);
}
}
} // end else
...
}
Full encodeMenuItem function;
Code: Select all
protected void encodeMenuItem(FacesContext context, AbstractMenu menu, MenuItem menuitem, int marginLevel) throws IOException {
ResponseWriter writer = context.getResponseWriter();
String title = menuitem.getTitle();
boolean disabled = menuitem.isDisabled();
String style = menuitem.getStyle();
writer.startElement("a", null);
if(title != null) writer.writeAttribute("title", title, null);
if(style != null) writer.writeAttribute("style", style, null);
if(marginLevel > 0) writer.writeAttribute("class", "marginLevel-" + marginLevel, null);
if(disabled) {
writer.writeAttribute("href", "#", null);
writer.writeAttribute("onclick", "return false;", null);
}
else {
setConfirmationScript(context, menuitem);
String onclick = menuitem.getOnclick();
if(marginLevel == 0) {
onclick = (onclick == null) ? "Sentinel.toggleSubMenu(this)" : "Sentinel.toggleSubMenu(this);" + onclick;
}
//GET
if(menuitem.getUrl() != null || menuitem.getOutcome() != null) {
String targetURL = getTargetURL(context, (UIOutcomeTarget) menuitem);
writer.writeAttribute("href", targetURL, null);
if(menuitem.getTarget() != null) {
writer.writeAttribute("target", menuitem.getTarget(), null);
}
}
//POST
else {
writer.writeAttribute("href", "#", null);
UIComponent form = ComponentUtils.findParentForm(context, menu);
if(form == null) {
throw new FacesException("MenuItem must be inside a form element");
}
String command;
if(menuitem.isDynamic()) {
String menuClientId = menu.getClientId(context);
Map<String,List<String>> params = menuitem.getParams();
if(params == null) {
params = new LinkedHashMap<String, List<String>>();
}
List<String> idParams = new ArrayList<String>();
idParams.add(menuitem.getId());
params.put(menuClientId + "_menuid", idParams);
command = menuitem.isAjax() ? buildAjaxRequest(context, menu, (AjaxSource) menuitem, form, params) : buildNonAjaxRequest(context, menu, form, menuClientId, params, true);
}
else {
command = menuitem.isAjax() ? buildAjaxRequest(context, (AjaxSource) menuitem, form) : buildNonAjaxRequest(context, ((UIComponent) menuitem), form, ((UIComponent) menuitem).getClientId(context), true);
}
onclick = (onclick == null) ? command : onclick + ";" + command;
}
if(onclick != null) {
if(menuitem.requiresConfirmation()) {
writer.writeAttribute("data-pfconfirmcommand", onclick, null);
writer.writeAttribute("onclick", menuitem.getConfirmationScript(), "onclick");
}
else {
writer.writeAttribute("onclick", onclick, null);
}
}
}
encodeMenuItemContent(context, menu, menuitem);
writer.endElement("a");
}