School dropout
becomes MILLIONAIRE!
Read his NLP methods.

Monday, January 8, 2007

Task 1 - Bugs

Here are some of the bugs which I managed to workaround eventually. I don't know if they were logical errors or liferay bugs though.

Bug #1 - Polling continues after portlet removal
So my portlet would poll the server every 3 seconds via AJAX, this is great, until I remove an instance of the portlet. The AJAX component, javascript obviously, would continue even though the portlet has been removed and I was bombarded by heaps of javascript errors every 3 seconds.

Wordaround
Check for existence of a field before polling. This is a logical workaround, but I would think that it is even more logical if the javascript stops work once the portlet is removed.

Bug #2 - Wrong forwarding to "portlet_not_setup"
Did a little testing and found this bug. 4 instances of portlet, 1 previously configured. After using the configuration setup for a 2nd portlet and saving, I was greeted with a shock. All 4 portlets were forwarded to the "/portal/portlet_not_setup" page. But 2 were actually set up, so what went wrong?

Investigation
After playing around with print statements, I realised that none of the portlets were forwarded to the view page. I don't get it. Here's the "before" code snippet.

String var = getVar(req, res);

if (Validator.isNull(var)){
return mapping.findForward("/portal/portlet_not_setup");
}

req.setAttribute("var", var);

return mapping.findForward("portlet.ext.testportlet.view");


The printlns tell me that they are actually going through the right loop and if the portlet instances had "var" configured, but they were just not forwarded to the view page. Everything was just mysteriously directed to the portlet_not_setup page even though the loop was not even traversed by the particular portlets.

Workaround
Forwarding everything to "view" as a workaround now. It shouldn't be this way, but I had to make things work. Here's the "after" code:

String var = getVar(req, res);

//if (Validator.isNull(var)){
// return mapping.findForward("/portal/portlet_not_setup");
//}

req.setAttribute("var", var);

return mapping.findForward("portlet.ext.testportlet.view");


And there's now a check at the "view" page to realize the existence of the param "var", showing a message to ask for configuration if param is not found.


Any advice or comments on this, anyone?

2 comments:

Punit Pandey said...

Hi Bryan,

I saw your blog. It is very nice and informative. You also picked up the topic which really needed a blog i.e. liferay portal. I hope you will keep writing about your experiences and keep sharing it with the community.

Keep it up.

-- Punit
Portlets Blog

Bryan aka Kit said...

Thanks for the encouragement, Punit! :)