Page 1 of 1

Bug: pa:tabMenu > pa:tab 'rendered' attribute broken

Posted: 30 Mar 2017, 14:16
by Smurfs
Hi,

I need to control rendering of menu tabs based on user permissions but have hit a snag when setting tab rendered property to false...

Code: Select all

<pa:tab title="Tab title" rendered="false">
.

The snag is that although the tab icon is not rendered as expected, when selecting the next rendered tab the hidden tab title is displayed. Furthermore the remaining tabs become associated with the following tab's content. This is actually easier to see in action than to explain, so to replicate modify atlantis-1.0.0.war demo and change line 11 of WEB-INF\menu.xhtml to

Code: Select all

<pa:tab icon="fa fa-cube" title="Features" rendered="false">
and see for yourself.

The work around is to ignore the rendered attribute and wrap pa:tab with

Code: Select all

<c:if test="..."><pa:tab icon="fa fa-cube" title="Features">...</pa:tab></c:if>
but this is not ideal! Please fix.

Thanks, Andrew

Re: Bug: pa:tabMenu > pa:tab 'rendered' attribute broken

Posted: 03 Apr 2017, 10:05
by aragorn
Fixed for next version; https://github.com/primefaces/atlantis/issues/9

You can add the following code to TabMenuRenderer.java;

Code: Select all

writer.startElement("div", tabMenu);
writer.writeAttribute("class", "layout-tabmenu-contents", null);
for(int i = 0; i < children.size(); i++) {
   Tab tab = (Tab) children.get(i); 
   
   if(tab.isRendered()) { // line 59. PLEASE ADD THIS CHECK.
      ...
   }
}
writer.endElement("div");
        
writer.endElement("div");

...

Re: Bug: pa:tabMenu > pa:tab 'rendered' attribute broken

Posted: 05 Apr 2017, 14:38
by Smurfs
Thanks!

Re: Bug: pa:tabMenu > pa:tab 'rendered' attribute broken

Posted: 06 Apr 2017, 10:57
by aragorn
You're welcome!