[BUG]: Call to undefined method getToolbar in JCB v4.1.3-alpha4 HtmlViews #1267

Closed
opened 2025-11-02 12:04:52 +00:00 by Lemuel · 5 comments
Owner

What Happened?

I updated my JCB 4 system to the latest v4.1.3-alpha4 release and when I try accessing any area in JCB I get the following error:

0 Call to undefined method Joomla\CMS\Document\HtmlDocument::getToolbar()

# Function Location
1 () JROOT/administrator/components/com_componentbuilder/src/View/Compiler/HtmlView.php:676
2 VDM\Component\Componentbuilder\Administrator\View\Compiler\HtmlView->addToolbar() JROOT/administrator/components/com_componentbuilder/src/View/Compiler/HtmlView.php:191
3 VDM\Component\Componentbuilder\Administrator\View\Compiler\HtmlView->display() JROOT/libraries/src/MVC/Controller/BaseController.php:660
4 Joomla\CMS\MVC\Controller\BaseController->display() JROOT/administrator/components/com_componentbuilder/src/Controller/DisplayController.php:43
5 VDM\Component\Componentbuilder\Administrator\Controller\DisplayController->display() JROOT/libraries/src/MVC/Controller/BaseController.php:693

After investigating the issue, I discovered that the list views in JCB have been updated to follow the new Joomla 5+ convention, which initializes the toolbar using:

/** @var Toolbar $toolbar */
$toolbar = $this->getDocument()->getToolbar();

However, this approach is not compatible with Joomla 4, because the \Joomla\CMS\Document\Document class in Joomla 4 does not include the getToolbar() method.

As a result, this problem now affects all JCB back-end list views and all components built with JCB when running on Joomla 4.

I attempted to resolve the issue by rolling back to the latest stable Joomla 4 release. While this restored functionality in the JCB back end and the Demo 4 component, the site (front-end) views are still encountering the same error.

Steps to reproduce the Bug

Update an existing JCB 4 installation to the latest JCB 5 alpha4 release, then attempt to access any list view in the JCB backend or in a compiled component. The error will occur because the new Joomla 5+ toolbar initialization method ($this->getDocument()->getToolbar()) is not compatible with Joomla 4 and earlier.

Which Joomla version are you compiling in?

v‎4.4.14

Which PHP version are you compiling in?

v8.1

Which Joomla versions are you targeting?

v‎4.4.14

Which PHP version are you targeting?

8.1

Which Web server is JCB running on?

Apache 2.4

Which Relational Database is JCB running on?

Mysqli Latest

Which OS is JCB running on?

Ubuntu 24.04 LTS

Which JCB version are you using?

v4.1.3-alpha4

Where in JCB did this issue occur?

Joomla Components(admin_views)

On which browsers did you encounter the issue?

Firefox

Additional Comments

Compiling a component for Joomla 3 or Joomla 4 using JCB 5 results in the same error when attempting to access the compiled component after installing it on either a Joomla 3 or Joomla 4 site.

### What Happened? I updated my JCB 4 system to the latest v4.1.3-alpha4 release and when I try accessing any area in JCB I get the following error: ```0 Call to undefined method Joomla\CMS\Document\HtmlDocument::getToolbar()``` | # | Function | Location | |----|--------------------------------------------------------------------------|-------------------------------------------------------------------------------------------| | 1 | () | JROOT/administrator/components/com_componentbuilder/src/View/Compiler/HtmlView.php:676 | | 2 | VDM\Component\Componentbuilder\Administrator\View\Compiler\HtmlView->addToolbar() | JROOT/administrator/components/com_componentbuilder/src/View/Compiler/HtmlView.php:191 | | 3 | VDM\Component\Componentbuilder\Administrator\View\Compiler\HtmlView->display() | JROOT/libraries/src/MVC/Controller/BaseController.php:660 | | 4 | Joomla\CMS\MVC\Controller\BaseController->display() | JROOT/administrator/components/com_componentbuilder/src/Controller/DisplayController.php:43 | | 5 | VDM\Component\Componentbuilder\Administrator\Controller\DisplayController->display() | JROOT/libraries/src/MVC/Controller/BaseController.php:693 | After investigating the issue, I discovered that the list views in JCB have been updated to follow the new Joomla 5+ convention, which initializes the toolbar using: ```php /** @var Toolbar $toolbar */ $toolbar = $this->getDocument()->getToolbar(); ``` However, this approach is **not compatible with Joomla 4**, because the `\Joomla\CMS\Document\Document` class in Joomla 4 does **not include the `getToolbar()` method**. As a result, this problem now affects **all JCB back-end list views and all components built with JCB when running on Joomla 4**. I attempted to resolve the issue by rolling back to the latest stable Joomla 4 release. While this restored functionality in the **JCB back end** and the **Demo 4 component**, the **site (front-end) views** are still encountering the same error. ### Steps to reproduce the Bug Update an existing **JCB 4** installation to the **latest JCB 5 alpha4 release**, then attempt to access any **list view** in the JCB backend or in a **compiled component**. The error will occur because the new Joomla 5+ toolbar initialization method (`$this->getDocument()->getToolbar()`) is not compatible with Joomla 4 and earlier. ### Which Joomla version are you compiling in? v‎4.4.14 ### Which PHP version are you compiling in? v8.1 ### Which Joomla versions are you targeting? v‎4.4.14 ### Which PHP version are you targeting? 8.1 ### Which Web server is JCB running on? Apache 2.4 ### Which Relational Database is JCB running on? Mysqli Latest ### Which OS is JCB running on? Ubuntu 24.04 LTS ### Which JCB version are you using? v4.1.3-alpha4 ### Where in JCB did this issue occur? Joomla Components(admin_views) ### On which browsers did you encounter the issue? Firefox ### Additional Comments Compiling a component for **Joomla 3 or Joomla 4** using **JCB 5** results in the **same error** when attempting to access the compiled component after installing it on either a Joomla 3 or Joomla 4 site.
Lemuel added the Bug label 2025-11-02 12:04:52 +00:00
Author
Owner

We are currently in the process of decoupling the Toolbar system in JCB into version-specific classes. This will allow us to introduce new features and functionality tailored for Joomla 5 and Joomla 6, while maintaining full compatibility and stability for Joomla 4 and Joomla 3. A update implementing this new structure will be released soon.

We are currently in the process of **decoupling the Toolbar system in JCB** into **version-specific classes**. This will allow us to introduce new features and functionality tailored for **Joomla 5 and Joomla 6**, while maintaining full **compatibility and stability for Joomla 4 and Joomla 3**. A update implementing this new structure will be released soon.
Member

awesome

awesome
Author
Owner

Testing on the latest Pre-test release:
When I Compile the Demo 4 Component I get the following error:

0 Resource 'Architecture.SiteViews.J4.AddToolBar' has not been registered with the container

# Function Location
1 () JROOT/libraries/vendor/joomla/di/src/Container.php:93
2 Joomla\DI\Container->get() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Service/ArchitectureView.php:515

In the libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Service/ArchitectureView.php on line 515
The issue is:

return $container->get('Architecture.SiteViews.J' . $this->targetVersion . '.AddToolBar');

should be

return $container->get('Architecture.SiteView.J' . $this->targetVersion . '.AddToolBar');

Adding this fix resolves the issue and the component Compiles Successfully.

Testing on the latest Pre-test release: When I Compile the Demo 4 Component I get the following error: ```0 Resource 'Architecture.SiteViews.J4.AddToolBar' has not been registered with the container``` | # | Function | Location | |----|--------------------------------------------------------------------------|-------------------------------------------------------------------------------------------| | 1 | () | JROOT/libraries/vendor/joomla/di/src/Container.php:93 | | 2 | Joomla\DI\Container->get() | JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Service/ArchitectureView.php:515 | In the `libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Service/ArchitectureView.php` on line `515` The issue is: ```php return $container->get('Architecture.SiteViews.J' . $this->targetVersion . '.AddToolBar'); ``` should be ```php return $container->get('Architecture.SiteView.J' . $this->targetVersion . '.AddToolBar'); ``` Adding this fix resolves the issue and the component Compiles Successfully.
Robot referenced this issue from a commit 2025-11-05 07:09:36 +00:00
Author
Owner

This issue has been resolved in the latest alpha5 release.
The Toolbar Area in JCB has been completely refactored to maintain full legacy support for JCB 4 while introducing new enhancements and features for JCB 5+.

This issue has been resolved in the latest [alpha5](https://github.com/joomengine/pkg-component-builder/archive/refs/heads/4.x.zip) release. The Toolbar Area in JCB has been completely refactored to maintain full legacy support for JCB 4 while introducing new enhancements and features for JCB 5+.
Author
Owner

The toolbar has been successfully tested in JCB 4 and is functioning correctly across Admin, Custom Admin, and Site views. This issue is resolved and can be closed.

The toolbar has been successfully tested in JCB 4 and is functioning correctly across Admin, Custom Admin, and Site views. This issue is resolved and can be closed.
Robot referenced this issue from a commit 2026-02-18 14:57:04 +00:00
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: joomla/Component-Builder#1267