Topic posted September 3, 2008 by MarcSoto , last edited October 29, 2011
1945 Views, 12 Comments
Title:
Sydincation widget results
Content:
I need to understand what happens if the syndication widget does not find any relevant knowledgebase articles. Does the widget provide an indicator that 0 results were found in some sort of variable? The reason that I ask is because we would like to customize the web page the results are supposed to appear on with a customized message for that particular case.
Following function in _arss.js file does the data request. So, in onCompleteJSON callback function, you can register an event or make a method call that does business logic based on zero result set:
if(channel.item.length == 0){
//raise an event. or invoke a method.
}
RNTFeed.JSONCall = function(url, id, page_next){ var handler = RNTFeed.readers[id]; var head = document.getElementsByTagName("head").item(0); var script = document.createElement("script"); RNTFeed.readers[id].onCompleteJSON = function (channel) { if(page_next == 1) handler.channel.item = handler.channel.item.concat(channel.item); else handler.channel = channel; handler.session = handler.channel.session; handler.onFeedReady(); head.removeChild(script); return true; } script.setAttribute("type", "text/javascript"); script.setAttribute("src", url+"/callback/RNTFeed.readers["+id+"].onCompleteJSON"); head.appendChild(script); };
Would this also work if our connection to RightNow somehow got interuppted?
My company is all about planning for the worst case scenarioes, which I can't really disagree with. They want to make sure if our syndication widget goes down we'll be able to generate some code that would effectively say, "temporarily out of service: please check back later."
Server interruption will be silent and the handler function will not be called. You need to set a timer for the server response and act accordingly. I haven tested following code. But, it enables you to intercept when the server doesn't respond and/or result set is empty. Make sure that you play with the time out values and find out a reasonable timeout value for your server.
RNTFeed.JSONCall = function(url, id, page_next){
//Change 1: new variable
var statusId = id+"SUCCESS"
var handler = RNTFeed.readers[id];
var head = document.getElementsByTagName("head").item(0);
var script = document.createElement("script");
RNTFeed.readers[id].onCompleteJSON = function (channel) {
Change 2: Results 0
if(channel.item.length == 0){
//Inform your customer that no results found: raise an event. or invoke a method.
}
//Change 3: The server returned
window[statusId] = true;
head.removeChild(script);
return true;
}
script.setAttribute("type", "text/javascript");
script.setAttribute("src", url+"/callback/RNTFeed.readers["+id+"].onCompleteJSON");
//Change 4: Set timer. Make sure you play with the timer and find out best timeout seconds for your server
setTimeout(function() {
if (!window[statusId]) {
//NO RESPONSE: You can inform your user that server is not responding
}
}, 1000);
All I have left to figure out now is why Mozilla Firefox won't display the error message (IE6, IE7, and Safari it all worked). That's something that I can resolve with the stylesheets.
We put the server-check code in place, but when users hit the "back" button on their browser, it kills the webpage. In my instance, it actually crashed my entire browser. Could you direct me in figuring out what may be occuring here and a possible for it?
Without seeing your script it will be difficult for me tell what may be occuring. If you give me a link to the page and tell me what browser you are using, I wil be happy to take a look.
Internet Explorer 6 and 7 both crash on us when we use this code, only when we hit the back button. The changes I have made in the JS are between lines 247 and 287.
Thank you so much for taking a look at this. I'm stumped and feel like if I start toying around with the code I may cause a bigger problem.
if (!window[statusId]) { //NO RESPONSE: You can inform your user that server is not responding //gblError = 1; this.topics.innerHTML = "<div id='error'>The Frequently Asked Questions are currently unavailable. Please check back later.<br><br></div>"; }
It should be:
if (!window[statusId]) { //NO RESPONSE: You can inform your user that server is not responding //gblError = 1; handler.topics.innerHTML = "<div id='error'>The Frequently Asked Questions are currently unavailable. Please check back later.<br><br></div>"; }
However, this doesn't explain the back button. Make this change. If it doesn't work, create a test page that fails, and give me the link (a link to actual page that fails. Not to javascripts).
2) You are loading the widget in body tag of the page. I have never tested this scenario. I would tested as we described in the document first. Make sure that it is working properly.
Thank you so much. My team is going to run the code through the ringer now, to see if we can find any other potential hiccups, but I think you've resolved any issues.
Comment
Following function in _arss.js file does the data request. So, in onCompleteJSON callback function, you can register an event or make a method call that does business logic based on zero result set:
if(channel.item.length == 0){
//raise an event. or invoke a method.
}
RNTFeed.JSONCall = function(url, id, page_next){ var handler = RNTFeed.readers[id]; var head = document.getElementsByTagName("head").item(0); var script = document.createElement("script"); RNTFeed.readers[id].onCompleteJSON = function (channel) { if(page_next == 1) handler.channel.item = handler.channel.item.concat(channel.item); else handler.channel = channel; handler.session = handler.channel.session; handler.onFeedReady(); head.removeChild(script); return true; } script.setAttribute("type", "text/javascript"); script.setAttribute("src", url+"/callback/RNTFeed.readers["+id+"].onCompleteJSON"); head.appendChild(script); };
Be the first to rate this
|
Sign in to rate this
Would this also work if our connection to RightNow somehow got interuppted?
My company is all about planning for the worst case scenarioes, which I can't really disagree with. They want to make sure if our syndication widget goes down we'll be able to generate some code that would effectively say, "temporarily out of service: please check back later."
Be the first to rate this
|
Sign in to rate this
Douglas,
Server interruption will be silent and the handler function will not be called. You need to set a timer for the server response and act accordingly. I haven tested following code. But, it enables you to intercept when the server doesn't respond and/or result set is empty. Make sure that you play with the time out values and find out a reasonable timeout value for your server.
RNTFeed.JSONCall = function(url, id, page_next){
//Change 1: new variable
var statusId = id+"SUCCESS"
var handler = RNTFeed.readers[id];
var head = document.getElementsByTagName("head").item(0);
var script = document.createElement("script");
RNTFeed.readers[id].onCompleteJSON = function (channel) {
Change 2: Results 0
if(channel.item.length == 0){
//Inform your customer that no results found: raise an event. or invoke a method.
}
if(page_next == 1)
handler.channel.item = handler.channel.item.concat(channel.item);
else
handler.channel = channel;
handler.session = handler.channel.session;
handler.onFeedReady();
//Change 3: The server returned
window[statusId] = true;
head.removeChild(script);
return true;
}
script.setAttribute("type", "text/javascript");
script.setAttribute("src", url+"/callback/RNTFeed.readers["+id+"].onCompleteJSON");
//Change 4: Set timer. Make sure you play with the timer and find out best timeout seconds for your server
setTimeout(function() {
if (!window[statusId]) {
//NO RESPONSE: You can inform your user that server is not responding
}
}, 1000);
head.appendChild(script);
};
Average Rating:



1 rating
|
Sign in to rate this
Thank you, this worked great!
All I have left to figure out now is why Mozilla Firefox won't display the error message (IE6, IE7, and Safari it all worked). That's something that I can resolve with the stylesheets.
Thank you again.
Be the first to rate this
|
Sign in to rate this
Thanks for the update. if you encounter more issues let us know.
Be the first to rate this
|
Sign in to rate this
I have encountered an issue...
We put the server-check code in place, but when users hit the "back" button on their browser, it kills the webpage. In my instance, it actually crashed my entire browser. Could you direct me in figuring out what may be occuring here and a possible for it?
Thank you very much.
Be the first to rate this
|
Sign in to rate this
Douglas,
Without seeing your script it will be difficult for me tell what may be occuring. If you give me a link to the page and tell me what browser you are using, I wil be happy to take a look.
Be the first to rate this
|
Sign in to rate this
We have left the code that errors out on us at the site:
http://www.in.gov/cmstraining
The javascript we're using for the syndication widget is found at:
http://www.in.gov/ai/rightnow/syndication_widget_2/arss.js
Internet Explorer 6 and 7 both crash on us when we use this code, only when we hit the back button. The changes I have made in the JS are between lines 247 and 287.
Thank you so much for taking a look at this. I'm stumped and feel like if I start toying around with the code I may cause a bigger problem.
Be the first to rate this
|
Sign in to rate this
Following code is wrong:
if (!window[statusId]) { //NO RESPONSE: You can inform your user that server is not responding //gblError = 1; this.topics.innerHTML = "<div id='error'>The Frequently Asked Questions are currently unavailable. Please check back later.<br><br></div>"; }
It should be:
if (!window[statusId]) { //NO RESPONSE: You can inform your user that server is not responding //gblError = 1; handler.topics.innerHTML = "<div id='error'>The Frequently Asked Questions are currently unavailable. Please check back later.<br><br></div>"; }
However, this doesn't explain the back button. Make this change. If it doesn't work, create a test page that fails, and give me the link (a link to actual page that fails. Not to javascripts).
Be the first to rate this
|
Sign in to rate this
http://www.in.gov/cmstraining is the site we have, still using the modified code.
Our syndication widget is used in the "Top FAQs" box on the right side of the screen.
I changed the line you mentioned and did some quick testing.
When I direct the widget to point towards something that is not the appropriate server the error code works without incident.
However, when the path to the server is correct, the browser still dies when I hit the back button.
Thank you so much for you time in this.
Be the first to rate this
|
Sign in to rate this
It is extremely difficult to debug in IE7. So, here are some suggestions:
1) Comment out following line. For Mozilla this line is redundant. For IE it may cause an issue.
window[statusId] = true;
//head.removeChild(script);
2) You are loading the widget in body tag of the page. I have never tested this scenario. I would tested as we described in the document first. Make sure that it is working properly.
Average Rating:



1 rating
|
Sign in to rate this
That was the line that was killling us.
Thank you so much. My team is going to run the code through the ringer now, to see if we can find any other potential hiccups, but I think you've resolved any issues.
Thank you again.
Be the first to rate this
|
Sign in to rate this