+ Start a Discussion
Patrick Mayer 4Patrick Mayer 4 

Using Streaming API to rerender an EnhancedList

<apex:page id="page" tabStyle="Case">

    <apex:includeScript value="{!$Resource.cometd}"/>
    <apex:includeScript value="{!$Resource.jquery}"/>
    <apex:includeScript value="{!$Resource.json2}"/>
    <apex:includeScript value="{!$Resource.jquery_cometd}"/>
    
    <script type="text/javascript">
    
        var j$ = jQuery.noConflict();
        j$(document).ready(function() {
     
            j$.cometd.init({
                url: window.location.protocol+'//'+window.location.hostname+'/cometd/28.0/',
                requestHeaders: { Authorization: 'OAuth {!$Api.Session_ID}'}
            });
    
            j$.cometd.subscribe('/topic/CaseUpdates', function(message) {
                document.getElementById('{!$Component.page.PageBlock}').style.display = 'none';
                document.getElementById('{!$Component.page.PageBlock}').style.display = 'block';
            });
       });
       
   </script>

   <apex:pageBlock id="PageBlock">

   <apex:enhancedList type="Case" height="300" rowsPerPage="10" id="AccountList" />

   </apex:pageBlock>
   

</apex:page>

I am trying to use the streaming API to rerender this list when any case is changed. I am guessing I should use some different javascript. Has anyone done this?
I have checked workbench and am seeing the notifications. Also, a secondary minor question, is there any way to put a text output or something inside of the subscribe just as a sanity check that it gets hit?
logontokartiklogontokartik
Wanted to make sure if you have created a PushTopic first for the Case Updates? and yes, you can add console.log statements inside subscribe method. 

For more details 
https://www.salesforce.com/us/developer/docs/api_streaming/index_Left.htm#CSHID=create_a_pushtopic.htm|StartTopic=Content%2Fcreate_a_pushtopic.htm|SkinName=webhelp
Patrick Mayer 4Patrick Mayer 4
It is definitely created and I see notifications in workbench, but after more testing I think that it is never hitting the subscribe function. I am confused, I even went as far to follow the a SF tutorial copy/paste verbatim and it still doesn't show in a visualforce page. I have triple checked everything from permissions to the push topic and cannot figure out why I don't receive anything.