var renderTargetsReqVar;\r
+ var renderOnRecordTargetsReqVar;\r
\r
function renderTargets(doRefresh)\r
{\r
//console.log("No further updates from server requested");\r
}\r
}\r
+ \r
+ function renderOnRecordTargets(doRefresh)\r
+ {\r
+ console.log('rendering ' + renderWhileActiveclientsRecord);\r
+ var sourcecomp = document.getElementById("pz2watch:activeclientsFieldRecord");\r
+ jsf.ajax.request(sourcecomp, null,{render: renderWhileActiveclientsRecord});\r
+ if (doRefresh) {\r
+ console.log('Will do another ajax request after a timeout in order to render: pz2watch:activeclientsFieldRecord'); \r
+ renderOnRecordTargetsReqVar=setTimeout(\r
+ function() { \r
+ console.log('Making request for pz2watch:activeclientsFieldRecord');\r
+ jsf.ajax.request(sourcecomp, null,{render: "pz2watch:activeclientsFieldRecord"}); \r
+ }\r
+ ,2000);\r
+ } else {\r
+ console.log("No further updates from server requested");\r
+ jsf.ajax.request(sourcecomp, null,{render: renderWhileActiveclientsRecord});\r
+ }\r
+ }\r
+\r
\r
function windowlocationhashListener () {\r
if (trackHistory) {\r
}\r
};\r
};\r
+ \r
+ var ActiveclientsRecordListener = function () {\r
+ this.invoke = function (field) {\r
+ var updateDoc = StringtoXML(field.textContent || field.text);\r
+ var activeClientsRecordValue = (updateDoc.childNodes[0].textContent || updateDoc.childNodes[0].text);\r
+ console.log('Activeclients response for record detected: ' + activeClientsRecordValue);\r
+ clearTimeout(renderOnRecordTargetsReqVar);\r
+ if (activeClientsRecordValue > '0') {\r
+ renderOnRecordTargets(true);\r
+ } else {\r
+ console.log('Active clients is 0, final rendering');\r
+ renderOnRecordTargets(false);\r
+ }\r
+ };\r
+ };\r
+\r
\r
jsf.ajax.addOnEvent(fieldUpdateListener);\r
\r
var setUpListeners = function () {\r
//console.log("Starts tracking activeclientsField");\r
fieldListeners.addListener("pz2watch:activeclientsField", new ActiveclientsListener());\r
+ fieldListeners.addListener("pz2watch:activeclientsFieldRecord", new ActiveclientsRecordListener());\r
if (trackHistory) {\r
//console.log("Starts tracking windowlocationhash field");\r
fieldListeners.addListener("pz2watch:windowlocationhash", new StateListener());\r
\r
<cc:interface>\r
<cc:attribute name="renderWhileActiveclients"/>\r
+ <cc:attribute name="renderWhileActiveclientsRecord"/>\r
<cc:attribute name="trackHistory"/>\r
<cc:attribute name="renderOnHitoryChange"/> \r
<cc:attribute name="debug"/> \r
<script>\r
//<![CDATA[\r
var renderWhileActiveclients = "${cc.attrs.renderWhileActiveclients}";\r
+ var renderWhileActiveclientsRecord = "${cc.attrs.renderWhileActiveclientsRecord}";\r
var renderOnHistoryChange = "${cc.attrs.renderOnHistoryChange}";\r
var trackHistory = ("${cc.attrs.trackHistory}" == "true"); \r
setUpListeners();\r
<h:form id="activeclientsForm" prependId="false">\r
<h:outputText id="activeClientsLabel" value="Active clients: " style="${cc.attrs.debug == 'true' ? '' : 'display:none;'}"/> \r
<h:outputText id="activeclientsField" value="${pz2.update()}" style="${cc.attrs.debug == 'true' ? '' : 'display:none;'}"/>\r
+ <h:outputText id="activeclientsFieldRecord" value="${pz2.update('record')}" style="${cc.attrs.debug == 'true' ? '' : 'display:none;'}"/>\r
+ \r
<h:panelGrid id="errorMessages" style="${pz2.hasErrors() ? 'display: block;' : 'display: none;'}">\r
<h:dataTable value="#{pz2.configurationErrors}" var="error" cellspace="0" cellpadding="0" style="${pz2.hasConfigurationErrors() ? 'display: block; vertical-align: top;' : 'display: none;'}">\r
<h:column valign="top">\r
Pazpar2ResponseData responseObject = Pazpar2ResponseParser.getParser().getDataObject(response);\r
dataObjects.put(commandName, responseObject); \r
}\r
- return getActiveClients();\r
+ if (commands.equals("record")) {\r
+ logger.debug("Record: Active clients: "+getRecord().getActiveClients());\r
+ return getRecord().getActiveClients();\r
+ } else {\r
+ return getActiveClients();\r
+ } \r
} else {\r
logger.debug("Skipped requests for " + commands + " as there's not yet a query."); \r
resetDataObjects();\r