Author: nbelaevski
Date: 2011-01-12 15:30:22 -0500 (Wed, 12 Jan 2011)
New Revision: 20974
Modified:
trunk/examples/core-demo/src/main/java/org/richfaces/demo/LogBean.java
trunk/examples/core-demo/src/main/webapp/log.xhtml
trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.js
Log:
https://issues.jboss.org/browse/RF-9138
https://issues.jboss.org/browse/RF-9025
Modified: trunk/examples/core-demo/src/main/java/org/richfaces/demo/LogBean.java
===================================================================
--- trunk/examples/core-demo/src/main/java/org/richfaces/demo/LogBean.java 2011-01-12
20:08:46 UTC (rev 20973)
+++ trunk/examples/core-demo/src/main/java/org/richfaces/demo/LogBean.java 2011-01-12
20:30:22 UTC (rev 20974)
@@ -34,6 +34,10 @@
@SessionScoped
public class LogBean {
+ private static final LogMode[] LOG_MODES = new LogMode[] {
+ LogMode.inline, LogMode.popup
+ };
+
private LogMode mode = LogMode.inline;
private Character hotkey = 'l';
@@ -54,4 +58,7 @@
this.hotkey = hotkey;
}
+ public LogMode[] getLogModes() {
+ return LOG_MODES;
+ }
}
Modified: trunk/examples/core-demo/src/main/webapp/log.xhtml
===================================================================
--- trunk/examples/core-demo/src/main/webapp/log.xhtml 2011-01-12 20:08:46 UTC (rev
20973)
+++ trunk/examples/core-demo/src/main/webapp/log.xhtml 2011-01-12 20:30:22 UTC (rev
20974)
@@ -18,8 +18,7 @@
<h:panelGrid columns="2">
<h:outputText value="Mode: "/>
<h:selectOneMenu value="#{logBean.mode}"
onchange="submit()">
- <f:selectItem itemValue="popup" />
- <f:selectItem itemValue="inline" />
+ <f:selectItems value="#{logBean.logModes}" />
</h:selectOneMenu>
<h:outputText value="Hotkey: "/>
Modified: trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.js
===================================================================
--- trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.js 2011-01-12
20:08:46 UTC (rev 20973)
+++ trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.js 2011-01-12
20:30:22 UTC (rev 20974)
@@ -233,108 +233,111 @@
richfaces.HtmlLog = richfaces.BaseComponent.extendClass(logClassMethods);
// define super class link
var $super = richfaces.HtmlLog.$super;
-}(jQuery, RichFaces));
+
+ jQuery(document).ready(function() {
+ if (typeof jsf != 'undefined') {
+ (function(jQuery, richfaces, jsf) {
-if (typeof jsf != 'undefined') {
- (function(jQuery, richfaces, jsf) {
+ //JSF log adapter
+ var identifyElement = function(elt) {
+ var identifier = '<' + elt.tagName.toLowerCase();
+ var e = jQuery(elt);
+ if (e.attr('id')) {
+ identifier += (' id=' + e.attr('id'));
+ }
+ if (e.attr('class')) {
+ identifier += (' class=' + e.attr('class'));
+ }
- //JSF log adapter
- var identifyElement = function(elt) {
- var identifier = '<' + elt.tagName.toLowerCase();
- var e = jQuery(elt);
- if (e.attr('id')) {
- identifier += (' id=' + e.attr('id'));
- }
- if (e.attr('class')) {
- identifier += (' class=' + e.attr('class'));
- }
+ identifier += ' ...>';
- identifier += ' ...>';
+ return identifier;
+ }
- return identifier;
- }
+ var formatPartialResponseElement = function(logElement, responseElement) {
+ var change = jQuery(responseElement);
- var formatPartialResponseElement = function(logElement, responseElement) {
- var change = jQuery(responseElement);
+ logElement.append("Element <b>" + responseElement.nodeName +
"</b>");
+ if (change.attr("id")) {
+ logElement.append(document.createTextNode(" for id=" +
change.attr("id")));
+ }
- logElement.append("Element <b>" + responseElement.nodeName +
"</b>");
- if (change.attr("id")) {
- logElement.append(document.createTextNode(" for id=" +
change.attr("id")));
- }
+ jQuery(document.createElement("br")).appendTo(logElement);
+ jQuery("<span
class='rf-log-entry-msg-xml'></span>").appendTo(logElement).text(change.toXML());
+ jQuery(document.createElement("br")).appendTo(logElement);
+ }
- jQuery(document.createElement("br")).appendTo(logElement);
- jQuery("<span
class='rf-log-entry-msg-xml'></span>").appendTo(logElement).text(change.toXML());
- jQuery(document.createElement("br")).appendTo(logElement);
- }
+ var formatPartialResponse = function(partialResponse) {
+ var logElement = jQuery(document.createElement("span"));
- var formatPartialResponse = function(partialResponse) {
- var logElement = jQuery(document.createElement("span"));
+ partialResponse.children().each(function() {
+ var responseElement = jQuery(this);
+ if (responseElement.is('changes')) {
+ logElement.append("Listing content of response <b>changes</b>
element:<br />");
+ responseElement.children().each(function() {
+ formatPartialResponseElement(logElement, this);
+ });
+ } else {
+ formatPartialResponseElement(logElement, this);
+ }
+ });
- partialResponse.children().each(function() {
- var responseElement = jQuery(this);
- if (responseElement.is('changes')) {
- logElement.append("Listing content of response <b>changes</b>
element:<br />");
- responseElement.children().each(function() {
- formatPartialResponseElement(logElement, this);
- });
- } else {
- formatPartialResponseElement(logElement, this);
+ return logElement;
}
- });
- return logElement;
- }
+ var jsfAjaxLogAdapter = function(data) {
+ try {
+ var log = richfaces.log;
- var jsfAjaxLogAdapter = function(data) {
- try {
- var log = richfaces.log;
+ var source = data.source;
+ var type = data.type;
- var source = data.source;
- var type = data.type;
+ var responseCode = data.responseCode;
+ var responseXML = data.responseXML;
+ var responseText = data.responseText;
- var responseCode = data.responseCode;
- var responseXML = data.responseXML;
- var responseText = data.responseText;
+ if (type != 'error') {
+ log.info("Received '" + type + "' event from " +
identifyElement(source));
- if (type != 'error') {
- log.info("Received '" + type + "' event from " +
identifyElement(source));
+ if (type == 'beforedomupdate') {
+ var partialResponse;
- if (type == 'beforedomupdate') {
- var partialResponse;
+ if (responseXML) {
+ partialResponse = jQuery(responseXML).children("partial-response");
+ }
- if (responseXML) {
- partialResponse = jQuery(responseXML).children("partial-response");
- }
+ var responseTextEntry = jQuery("<span>Server returned responseText:
</span><span
class='rf-log-entry-msg-xml'></span>").eq(1).text(responseText).end();
- var responseTextEntry = jQuery("<span>Server returned responseText:
</span><span
class='rf-log-entry-msg-xml'></span>").eq(1).text(responseText).end();
-
- if (partialResponse && partialResponse.length) {
- log.debug(responseTextEntry);
- log.info(formatPartialResponse(partialResponse));
+ if (partialResponse && partialResponse.length) {
+ log.debug(responseTextEntry);
+ log.info(formatPartialResponse(partialResponse));
+ } else {
+ log.info(responseTextEntry);
+ }
+ }
} else {
- log.info(responseTextEntry);
+ var status = data.status;
+ log.error("Received '" + type + '@' + status + "'
event from " + identifyElement(source));
+ log.error("[" + data.responseCode + "] " + data.errorName +
": " + data.errorMessage);
}
+ } catch (e) {
+ //ignore logging errors
}
- } else {
- var status = data.status;
- log.error("Received '" + type + '@' + status + "'
event from " + identifyElement(source));
- log.error("[" + data.responseCode + "] " + data.errorName +
": " + data.errorMessage);
- }
- } catch (e) {
- //ignore logging errors
- }
- };
+ };
- var eventsListener = richfaces.createJSFEventsAdapter({
- begin: jsfAjaxLogAdapter,
- beforedomupdate: jsfAjaxLogAdapter,
- success: jsfAjaxLogAdapter,
- complete: jsfAjaxLogAdapter,
- error: jsfAjaxLogAdapter
- });
+ var eventsListener = richfaces.createJSFEventsAdapter({
+ begin: jsfAjaxLogAdapter,
+ beforedomupdate: jsfAjaxLogAdapter,
+ success: jsfAjaxLogAdapter,
+ complete: jsfAjaxLogAdapter,
+ error: jsfAjaxLogAdapter
+ });
- jsf.ajax.addOnEvent(eventsListener);
- jsf.ajax.addOnError(eventsListener);
- //
- }(jQuery, RichFaces, jsf));
-};
\ No newline at end of file
+ jsf.ajax.addOnEvent(eventsListener);
+ jsf.ajax.addOnError(eventsListener);
+ //
+ }(jQuery, RichFaces, jsf));
+ };
+ });
+
+}(jQuery, RichFaces));
\ No newline at end of file