title: Interpreting Dynamic Attribute in JSP in Hybris
body: <p>I created a dynamic attribute to handle navigation node entries' visibility in compatible with all related rules of Hybris. I was able to reach the attribute within Java code without getting any problem but I could not make JSP interpret it. <strong><em>My DynamicAttributeHandler class smoothly worked but JSP failed while reading it.</em></strong> These were the steps of the creation of the attribute:</p>
  
  <p><strong>1)items.xml</strong></p>
  
  <pre><code>&lt;attribute qualifier="navigationNodeVisibility" type="java.lang.Boolean"&gt;
         &lt;persistence type="dynamic" attributeHandler="navigationNodeVisibilityAttributeHandler"/&gt;
         &lt;modifiers read="true" write="false" search="true"/&gt;
         &lt;defaultvalue&gt;java.lang.Boolean.TRUE&lt;/defaultvalue&gt;
  &lt;/attribute&gt;
  </code></pre>
  
  <p><strong>2)NavigationNodeVisibilityAttributeHandler.java</strong></p>
  
  <pre><code>@Override
  public Boolean get(CMSNavigationNodeModel model) {
      if (model != null) {
          for(CMSNavigationEntryModel cmsNavigationEntry:model.getEntries()){
              if(cmsNavigationEntry.getItem() instanceof  CMSLinkComponentModel){
                  CategoryModel category= ((CMSLinkComponentModel)cmsNavigationEntry.getItem()).getCategory();
                  if((category.getVisibility()== null || category.getVisibility() ) &amp;&amp; ActiveProductStatus.ACTIVE == category.getActiveProductStatus()
                          &amp;&amp; ManageCategoryByDateStatus.ACTIVE == category.getManageCategoryByDateStatus()){
                      return Boolean.TRUE;
                  }
              }
          }
          return Boolean.FALSE;
      }
      return null;
  }
  </code></pre>
  
  <p></p>
  
  <p><strong>3) Registering bean</strong></p>
  
  <pre><code>&lt;bean id="navigationNodeVisibilityAttributeHandler" class="com.inomera.hybris.core.handler.NavigationNodeVisibilityAttributeHandler" /&gt;
  </code></pre>
  
  <p><strong>4) ant clean all &amp;&amp; ant updatesystem</strong></p>
  
  <p>Whenever I called it in jsp file, I had got an error like ".. An exception occurred processing JSP page .." </p>
  
  <pre><code>&lt;c:forEach items="${component.navigationNode.children}" var="cx"&gt;
      ${cx.navigationNodeVisibility}
  &lt;/c:forEach&gt;
  </code></pre>
  
  <p>Calling the attribute in this way did not throw an exception but it is necessary to use it within the for loop in my case. </p>
  
  <p><code>${component.navigationNode.children[0].navigationNodeVisibility}</code></p>
  
  <p>Any help or suggestion would be really appreciated</p>
  
  <p>Note: <code>${cx.getNavigationNodeVisibility()}</code> did throw the same JSP exception.</p>
  
  <p><strong>Edit: JSP exception example</strong></p>
  
  <pre><code>WARN  [hybrisHTTP14] [XXXXXXXXXXXX] [DefaultCMSComponentRendererRegistry] Error processing component tag. currentComponent [CategoryNavigationComponentModel (8796098036796@1)] exception: An exception occurred processing JSP page /WEB-INF/views/responsive/cms/categorynavigationcomponent.jsp at line 14
  
  11: &lt;nav id="menu" style="display: none;"&gt;
  12:         &lt;ul&gt;
  13:             &lt;c:forEach items="${component.navigationNode.children}" var="childLevel1"&gt;
  14:                 &lt;c:if test="${ childLevel1.visible eq 'true' &amp;&amp; childLevel1.navigationNodeVisibility}"&gt;
  15:                     &lt;li&gt;
  16:                         &lt;c:forEach items="${childLevel1.entries}" var="childEntry1" end="1"&gt;
  17:                             &lt;c:if test="${not empty childLevel1.children}"&gt;
  </code></pre>