OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



non-form error handling

OJS development discussion, enhancement requests, third-party patches and plug-ins.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
The Public Knowledge Project Support Forum is moving to http://forum.pkp.sfu.ca

This forum will be maintained permanently as an archived historical resource, but all new questions should be added to the new forum. Questions will no longer be monitored on this old forum after March 30, 2015.

non-form error handling

Postby barbarah » Tue Mar 06, 2012 5:17 pm

I have a pretty general development question: what's the best way to go about capturing errors/exceptions and then ultimately displaying an error message to the user in the template/UI? I see how this is done for HTML form errors, but it's unclear how this works (or should work) for non-html-form stuff. For example, I'm implementing some convert-to-pdf functionality and want to let the user know if their document wasn't able to be converted for some reason. I can't find examples in the existing PKP codebase to use as a model. Any pointers would be really useful. Thanks!
barbarah
 
Posts: 27
Joined: Thu Mar 24, 2011 1:25 pm
Location: California Digital Library, Oakland, California

Re: non-form error handling

Postby mcrider » Tue Mar 06, 2012 9:00 pm

Hi Barbarah,

We do this in pages/manager/PluginManagementHandler::_showInstallForm() (and others) for example -- though I'm not sure why thats not a form other than its too basic to require a full-fledged form class. Its typically best to use a Form class, but otherwise thats one example of how to show errors.

Cheers,
Matt
mcrider
 
Posts: 952
Joined: Mon May 05, 2008 10:29 am
Location: Vancouver, BC

Re: non-form error handling

Postby barbarah » Wed Mar 07, 2012 11:31 am

Thanks for the quick response Matt! Do you have any working examples of functionality (ideally in OJS) that I can look at as an example?
barbarah
 
Posts: 27
Joined: Thu Mar 24, 2011 1:25 pm
Location: California Digital Library, Oakland, California

Re: non-form error handling

Postby asmecher » Wed Mar 07, 2012 11:50 am

Hi all,

For the forthcoming OMP, we're making more use of the Notifications framework and it might be useful here as well. Barbarah, have a look at pages/admin/AdminSettingsHandler.inc.php at the very end of the file:
Code: Select all
import('classes.notification.NotificationManager');
$notificationManager = new NotificationManager();
$notificationManager->createTrivialNotification($user->getId());
This creates a "Your settings were saved" message. It's not an error condition, but you may be able to use the same structures to present an error as well; have a look at the NotificationManager's API.

This applies much more to OMP than OJS, but since they both share the same lib/pkp code including the base PKPNotificationManager class, it's worth investigating.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 10015
Joined: Wed Aug 10, 2005 12:56 pm

Re: non-form error handling

Postby barbarah » Wed Mar 07, 2012 11:51 am

Cool, thanks Alec. I was hoping OMP had more exception/notification handling in place :-)
barbarah
 
Posts: 27
Joined: Thu Mar 24, 2011 1:25 pm
Location: California Digital Library, Oakland, California


Return to OJS Development

Who is online

Users browsing this forum: Bing [Bot] and 2 guests