title: typo3 custom widget viewhelper
body: <p>I created a custom widget <code>viewhelper</code> for an extension which works fine in an empty typo3 8.7 installation. But when I use it on needed project with same code it causes an error: </p>
  
  <pre><code>#1289422564: initiateSubRequest() can not be called if there is no valid controller extending TYPO3\CMS\Fluid\Core\Widget\AbstractWidgetController Got "NULL" in class ...
  </code></pre>
  
  <p>Did somebody have an error like this before or does someone know what causes this type of error?</p>
  
  <pre><code>&lt;!-- This is the View List.html--&gt;
  
  
  {namespace Exhibitors = MyVendorName\MyExhibitors\ViewHelpers}
  
  &lt;ul class="second_lvl"&gt;
      &lt;Exhibitors:widget.AtoZNav objects="{feUserData}" as="filteredExhibitors" property="company"&gt;
          &lt;Exhibitors:widget.sort objects="{filteredExhibitors}" as="sortedExhibitors" property="company"&gt;
              &lt;f:for each="{filteredExhibitors}" as="feUser"&gt;
                  &lt;li class="navLink"&gt;
                      {feUser.company}&lt;br /&gt;
                      {feUser.company}
                      {feUser.www}&lt;br /&gt;
                  &lt;/li&gt;
              &lt;/f:for&gt;
          &lt;/Exhibitors:widget.sort&gt;
      &lt;/Exhibitors:widget.AtoZNav&gt;
  &lt;/ul&gt;
  &lt;f:link.action action="show"&gt;show detail page&lt;/f:link.action&gt;
  </code></pre>
  
  <hr>
  
  <pre><code>&lt;?php
  /**
   * This is the SortViewHelper
   */
  
  namespace MyVendorName\MyExhibitors\ViewHelpers\Widget;
  
  
  class SortViewHelper extends \TYPO3\CMS\Fluid\Core\Widget\AbstractWidgetViewHelper
  {
      /**
       * @param \TYPO3\CMS\Extbase\Persistence\QueryResultInterface $objects
       * @param string $as
       * @param string $property
       * @return string
       */
      public function render(\TYPO3\CMS\Extbase\Persistence\QueryResultInterface $objects, $as, $property)
      {
         return $this-&gt;initiateSubRequest();
      }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>&lt;?php
  /**
   * This is the Sort Controller
   */
  
  namespace MyVendorName\MyExhibitors\ViewHelpers\Widget\Controller;
  
  
  class SortController extends \TYPO3\CMS\Fluid\Core\Widget\AbstractWidgetController
  {
      /**
       * @var \TYPO3\CMS\Extbase\Persistence\QueryResultInterface
       */
      protected $objects;
  
      public function initializeAction()
      {
          $this-&gt;objects = $this-&gt;widgetConfiguration['objects'];
      }
  
      /**
       * @param mixed string $order
       */
      public function indexAction($order = \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING)
      {
          $order = ($order == \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING) ? \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING : \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING;
          $query = $this-&gt;objects-&gt;getQuery();
          $query-&gt;setOrderings(array($this-&gt;widgetConfiguration['property'] =&gt; $order));
          $modifiedObjects = $query-&gt;execute();
          $this-&gt;view-&gt;assign('contentArguments', array($this-&gt;widgetConfiguration['as'] =&gt; $modifiedObjects));
          $this-&gt;view-&gt;assign('order', $order);
      }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>&lt;?php
  /**
   * This is AtoZNav ViewHelper
   */
  
  namespace MyVendorName\MyExhibitors\ViewHelpers\Widget;
  
  class AtoZNavViewHelper extends \TYPO3\CMS\Fluid\Core\Widget\AbstractWidgetViewHelper
  {
      /**
       * @param \TYPO3\CMS\Extbase\Persistence\QueryResultInterface $objects
       * @param string $as
       * @param string $property
       * @return string
       */
      public function render(\TYPO3\CMS\Extbase\Persistence\QueryResultInterface $objects, $as, $property)
      {
         return $this-&gt;initiateSubRequest();
      }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>&lt;?php
  /**
   * This is the Controller
   */
  
  namespace MyVendorName\MyExhibitors\ViewHelpers\Widget\Controller;
  
  
  class AtoZNavController extends \TYPO3\CMS\Fluid\Core\Widget\AbstractWidgetController
  {
      /**
       * @var \TYPO3\CMS\Extbase\Persistence\QueryResultInterface
       */
      protected $objects;
  
      public function initializeAction()
      {
          $this-&gt;objects = $this-&gt;widgetConfiguration['objects'];
      }
  
      /**
       * @param string $char
       * @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
       */
      public function indexAction($char = '%')
      {
          $query = $this-&gt;objects-&gt;getQuery();
          $query-&gt;matching($query-&gt;like($this-&gt;widgetConfiguration['property'], $char . '%'));
          $modifiedObjects = $query-&gt;execute();
          $this-&gt;view-&gt;assign('contentArguments', array($this-&gt;widgetConfiguration['as'] =&gt; $modifiedObjects));
          $this-&gt;view-&gt;assign('letters', range('A', 'Z'));
          $this-&gt;view-&gt;assign('char', $char);
      }
  }
  </code></pre>