I would like to use Primefaces p:ajaxStatus for normal f:ajax requests. Or maybe there's an opensource component for status icons for normal JSF ajax requests that i can use and style it the same way as Primefaces one?
Asked
Active
Viewed 3,289 times
1
-
Related: http://stackoverflow.com/questions/3556676/jsf-status-bar-connection-status-information/ and http://stackoverflow.com/questions/7043840/jsf-2-how-show-different-ajax-status-in-same-input/ – BalusC Aug 29 '11 at 13:50
2 Answers
2
You don't really need a component. A simple piece of Javascript will do (what follows is a proof-of-concept, no ajax error handling, supports only one ajax request at a time, no special js libraries - fixes are left as an exercise for the reader):
<img id='busy' src='busy.png' style='display: none'>
<img id='notbusy' src='notbusy.png'>
<script>
var evil_global_busy = document.getElementById('busy')
var evil_global_notbusy = document.getElementById('notbusy')
jsf.ajax.addOnEvent(function(e){
if (e.status == "begin") {
evil_global_busy.style.display = '';
evil_global_notbusy.style.display = 'none';
}
if (e.status == "success") {
evil_global_busy.style.display = 'none';
evil_global_notbusy.style.display = '';
}
})
</script>

fdreger
- 12,264
- 1
- 36
- 42
1
Based on PrimeFace, covers all ajax request of the site, including the attribute 'update'
<p:ajaxStatus>
<f:facet name="start">
<h:graphicImage library="image" name="loading.gif" />
</f:facet>
<f:facet name="error">
<h:outputText value="Error. " />
</f:facet>
<f:facet name="complete">
<h:outputText value="" />
</f:facet>
</p:ajaxStatus>

wilton.beltre
- 21
- 3