-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#109 added onsuccess and onerror for b:commandButton
- Loading branch information
1 parent
2c6f87f
commit 43d706d
Showing
12 changed files
with
1,099 additions
and
838 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<factorypath> | ||
<factorypathentry kind="PLUGIN" id="com.ibm.jee.annotations.processor" enabled="true" runInBatchMode="false"/> | ||
<factorypathentry kind="PLUGIN" id="com.ibm.etools.javaee.cdi.ext.ui" enabled="false" runInBatchMode="false"/> | ||
<factorypathentry kind="PLUGIN" id="com.ibm.jaxrs.annotations.processor" enabled="false" runInBatchMode="false"/> | ||
<factorypathentry kind="PLUGIN" id="org.eclipse.jst.ws.annotations.core" enabled="true" runInBatchMode="false"/> | ||
</factorypath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,173 @@ | ||
/* | ||
Copyright 2014 Riccardo Massera (TheCoder4.Eu) | ||
BootsFaces JS | ||
author: TheCoder4.eu | ||
*/ | ||
BsF={ajax:{},onSuccessCallback:{}};BsF.ajax.onevent=function(a){"complete"===a.status&&$.blockUI&&null!=$.blockUI&&$.unblockUI();"success"==a.status&&(a=a.source.id.replace(/[^a-zA-Z0-9]+/g,"_"),(a=BsF.onSuccessCallback[a])&&null!=a&&"undefined"!=typeof a&&a())};BsF.ajax.cb=function(a,c,b,d){BsF.ajax.callAjax(a,c,b,"@all",d,null)}; | ||
BsF.ajax.callAjax=function(a,c,b,d,f,h){var g=a.id,k=g.replace(/[^a-zA-Z0-9]+/g,"_"),e={};h&&(e.params="BsFEvent="+h);(b=BsF.ajax.resolveJQuery(b))&&null!=b&&(e.render=b);(d=BsF.ajax.resolveJQuery(d))&&null!=d&&(e.execute=d);e[g]=g;BsF.onSuccessCallback[k]=f&&null!=f?f:null;e.onevent=BsF.ajax.onevent;jsf.ajax.request(a,c,e);$.blockUI&&null!=$.blockUI&&$.blockUI();return!1}; | ||
BsF.ajax.resolveJQuery=function(a){if("undefined"==typeof a||null==a)return"";var c="";a=a.split(" ");for(i=0;i<a.length;i++)if(part=a[i],0==part.indexOf("@(")&&part.lastIndexOf(")")==part.length-1){var b=part.substring(2,part.length-1);(b=$(b))&&b.each(function(a,b){c+=" "+b.id})}else c+=part+" ";return c.trim()};BsF.ajax.paginate=function(a,c,b,d,f){a={execute:"@this"};a.render=f;a[d]=b;jsf.ajax.request(d,c,a);return!1}; | ||
if($.datepicker){var generateHTML_orig=$.datepicker._generateHTML;$.datepicker._generateHTML=function(){var a=generateHTML_orig.apply(this,arguments),a=a.replace(/<span\s+class='ui-icon\s+ui-icon-circle-triangle-w'\s*>[^<]+<\/span>/,'<span class="glyphicon glyphicon-chevron-left"></span>');return a=a.replace(/<span\s+class='ui-icon\s+ui-icon-circle-triangle-e'\s*>[^<]+<\/span>/,'<span class="glyphicon glyphicon-chevron-right"></span>')}} | ||
function jq(a){return"#"+a.replace(/(:|\.|\[|\]|,)/g,"\\$1")}function treeDataMapper(a){console.log(a);return a&&"undefined"!==a?a.nodeInternalId+"|#*#|"+a.text+"|#*#|"+a.state.checked+"|#*#|"+a.state.disabled+"|#*#|"+a.state.expanded+"|#*#|"+a.state.selected:""}; | ||
/*! | ||
* Copyright 2014 Riccardo Massera (TheCoder4.Eu) | ||
* BootsFaces JS | ||
* author: TheonSuccessCallbackCoder4.eu | ||
*/ | ||
|
||
BsF = {}; | ||
BsF.ajax = {}; | ||
BsF.onCompleteCallback = {}; | ||
BsF.onErrorCallback = {}; | ||
BsF.onSuccessCallback = {}; | ||
|
||
BsF.ajax.onevent = function(data) { | ||
if (data.status === 'complete') { // note that JSF confuses onSuccess and onComplete | ||
var cid = data.source.id.replace(/[^a-zA-Z0-9]+/g, '_'); | ||
if (data.responseText != null && data.responseText.indexOf("<error><error-name>") >= 0) { | ||
var f = BsF.onErrorCallback[cid]; | ||
if (f && f != null && typeof (f) != 'undefined') { | ||
f(); | ||
} | ||
} else { | ||
var f = BsF.onSuccessCallback[cid]; | ||
if (f && f != null && typeof (f) != 'undefined') { | ||
f(); | ||
} | ||
} | ||
if ($.blockUI && $.blockUI != null) { | ||
$.unblockUI(); | ||
} | ||
} | ||
if (data.status == "success") { // note that JSF confuses onSuccess and onComplete | ||
var cid = data.source.id.replace(/[^a-zA-Z0-9]+/g, '_'); | ||
var f = BsF.onCompleteCallback[cid]; | ||
if (f && f != null && typeof (f) != 'undefined') { | ||
f(); | ||
} | ||
} | ||
if (data.status == "error") { | ||
var cid = data.source.id.replace(/[^a-zA-Z0-9]+/g, '_'); | ||
var f = BsF.onErrorCallback[cid]; | ||
if (f && f != null && typeof (f) != 'undefined') { | ||
f(); | ||
} | ||
} | ||
}; | ||
BsF.ajax.cb = function(o, e, r, f) { | ||
BsF.ajax.callAjax(o, e, r, "@all", f, null); | ||
} | ||
|
||
/** | ||
* Initiates an asynchronous AJAX request. param eventType In the case of jQuery | ||
* events, JSF sends the wrong event type to the backend. The real event is put | ||
* in this parameter. | ||
*/ | ||
BsF.ajax.callAjax = function(source, event, update, execute, oncomplete, | ||
onerror, onsuccess, | ||
eventType) { | ||
var argn = arguments.length; | ||
var oid = source.id; | ||
var cid = oid.replace(/[^a-zA-Z0-9]+/g, '_'); | ||
var opts = {}; | ||
if (eventType) { | ||
opts.params = "BsFEvent=" + eventType; | ||
} | ||
|
||
update = BsF.ajax.resolveJQuery(update); | ||
if (update && update != null) { | ||
opts.render = update; | ||
} | ||
|
||
execute = BsF.ajax.resolveJQuery(execute); | ||
if (execute && execute != null) { | ||
opts.execute = execute; | ||
} | ||
opts[oid] = oid; | ||
if (oncomplete && oncomplete != null) { | ||
BsF.onCompleteCallback[cid] = oncomplete; | ||
} else { | ||
BsF.onCompleteCallback[cid] = null; | ||
} | ||
if (onerror && onerror != null) { | ||
BsF.onErrorCallback[cid] = onerror; | ||
} else { | ||
BsF.onErrorCallback[cid] = null; | ||
} | ||
if (onsuccess && onsuccess != null) { | ||
BsF.onSuccessCallback[cid] = onsuccess; | ||
} else { | ||
BsF.onSuccessCallback[cid] = null; | ||
} | ||
opts.onevent = BsF.ajax.onevent; | ||
|
||
jsf.ajax.request(source, event, opts); | ||
if ($.blockUI && $.blockUI != null) { | ||
var message = $.blockUI.defaults.message; | ||
$.blockUI(); | ||
} | ||
return false; | ||
}; | ||
|
||
BsF.ajax.resolveJQuery = function(update) { | ||
if (typeof (update) == 'undefined') | ||
return ""; | ||
if (update == null) | ||
return ""; | ||
var newUpdate = ""; | ||
var parts = update.split(" "); | ||
for (i = 0; i < parts.length; i++) { | ||
part = parts[i]; | ||
if ((part.indexOf("@(") == 0) | ||
&& (part.lastIndexOf(")") == part.length - 1)) { | ||
var jqueryexp = part.substring(2, part.length - 1); | ||
var jQueryObjects = $(jqueryexp); | ||
if (jQueryObjects) { | ||
jQueryObjects.each(function(index, element) { | ||
newUpdate += " " + element.id; | ||
}); | ||
|
||
} | ||
} else | ||
newUpdate += part + " "; | ||
} | ||
return newUpdate.trim(); | ||
}; | ||
|
||
BsF.ajax.paginate = function(o, e, v, c, r) { // Paginator ajax helper | ||
// (object, event, value, | ||
// component, render) | ||
var opts = {}; | ||
opts.execute = '@this'; | ||
opts.render = r; | ||
opts[c] = v; | ||
jsf.ajax.request(c, e, opts); | ||
return false; | ||
}; | ||
|
||
/* DatePicker Bootstrap Icon support */ | ||
if ($.datepicker) { | ||
var generateHTML_orig = $.datepicker._generateHTML; | ||
|
||
$.datepicker._generateHTML = function() { | ||
var ret = generateHTML_orig.apply(this, arguments); // alert(ret); | ||
ret = ret | ||
.replace( | ||
/<span\s+class='ui-icon\s+ui-icon-circle-triangle-w'\s*>[^<]+<\/span>/, | ||
'<span class="glyphicon glyphicon-chevron-left"></span>'); | ||
ret = ret | ||
.replace( | ||
/<span\s+class='ui-icon\s+ui-icon-circle-triangle-e'\s*>[^<]+<\/span>/, | ||
'<span class="glyphicon glyphicon-chevron-right"></span>'); | ||
return ret; | ||
}; | ||
} | ||
|
||
/* JQuery escaping utility for id's */ | ||
function jq( myid ) { | ||
return "#" + myid.replace( /(:|\.|\[|\]|,)/g, "\\$1" ); | ||
} | ||
|
||
/* tree support method to convert data object to state string */ | ||
function treeDataMapper(data) { | ||
console.log(data); | ||
var sep = "|#*#|"; | ||
if(data && data !== "undefined") { | ||
return data.nodeInternalId + sep + | ||
data.text + sep + | ||
data.state.checked + sep + | ||
data.state.disabled + sep + | ||
data.state.expanded + sep + | ||
data.state.selected; | ||
} | ||
return ""; | ||
} |
Oops, something went wrong.