2

I'm creating a new component. I have a VERY long series of steps that are being processed within a helper file (called by the controller - in the postSavHook function).

Within the controller function as well as within the helper I would like to display an update to the user as each step completes; however, I'm not exactly sure what would be the best approach.

I've tried the enqueueMessage approach, but it never fires.

I AM able to display errors when needed using the 'throw new Exception' process.

Any suggestions on how I could get something like the enqueueMessage type display but called from the controller or helper and updated several times throughout the process of a long function?

These are some things I've tried:

//this works - although it obviously stops further code processing
throw new Exception(JText::_('COM_MYCOMP_ERROR_MESSAGE_NOT_FOUND'), 972);

//this doesn't seem to work (doesn't have any effect):
$app = JApplicationCms::getInstance('administrator');
$app->enqueueMessage('My Message here', 'success');

//and neither does this:
JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_MY_COMPONENT_ALERT1',$countType),'alert');

Also, this code is running from the admin (not front-end) so it's not an issue with having the template missing the system message display area (as the default admin template has that automatically included).

3
  • From what you have described everything is happening on the Server-side and the client is just waiting for a page to come back. If the controller has called the helper file and the controller is called from a button of some sort in the admin pages then I would expect you would only receive a response, such as the enqueueMessage approach when a page is returned to the client. For you to receive 'progress' messages as far as I understand things you would need to use AJAX to call your controller and have some JS on your admin pages respond to the progress message from the helper.
    – Irata
    Jul 19 at 9:50
  • That was what I was 'afraid' of. Can anyone point me to some existing code (possibly core Joomla components or maybe some other open source project on github that implements this in Joomla) that might do something like that (i.e. AJAX) that I could view and study to understand how best to implement? Jul 19 at 14:39
  • I am still trying to implement some AJAX features in my projects but here is a starting point for what will be a lot of reading, docs.joomla.org/J3.x:Developing_an_MVC_Component/Adding_AJAX
    – Irata
    Jul 19 at 23:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.