Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
Ron J
PollerProcessor not triggered
April 12, 2013 7:05 AM
Answer

Ron J

Rank: Junior Member

Posts: 44

Join Date: November 18, 2012

Recent Posts

I'm trying to configure a custom PollerProcessor but I can't seem to get the processor to trigger when I send requests from my js.. I've been using the Chat portlet and this post as references: http://agile-reflections.opnworks.com/2011/07/polling-liferay-portal.html

I don't see what I'm missing, I have a very simple poller class (extends BasePollerProcessor) with log statements in my methods (i never see them).
 1
 2@Override
 3    protected void doReceive(PollerRequest req, PollerResponse res)
 4        throws Exception
 5    {
 6        log.info("doReceive invoked, request: " + req +"\r\nResponse: "+ res);
 7        JSONObject obj = JSONFactoryUtil.createJSONObject();
 8                obj.put("title", "MyTitle");
 9                res.setParameter("content", obj);
10        }


The JS: Add listener
 1 Liferay.Poller.addListener(instance._portletId, instance._onPollerUpdate, instance);
 2                       Liferay.bind(
 3                            'sessionExpired',
 4                            function(event) {
 5                                console.log("Removing poller listener");
 6                                 Liferay.Poller.removeListener(instance._portletId);
 7                                 //instance._pollExContainer.hide();
 8                            }
 9                       );

send and update functions
 1send: function(options, id) {
 2                       var instance = this;
 3                   
 4                       console.log("options:" + options + " id: " + id);
 5                      
 6                       Liferay.Poller.submitRequest(instance._portletId, options, id);
 7                  },
 8                  _onPollerUpdate: function(response, chunkId) {
 9                      console.log("Got poller update");


I do notice that there's a JSON parsing error but there's no line/file. Maybe that error prevents the request from actually being executed to my poller processor?
firebug output:
1
2options:[object Object] id: undefined
3POST http://localhost:8080/poller/send 200OK 6ms
4SyntaxError: JSON.parse: unexpected end of data


Anyone see this before?