Left Sidebar Icon with Direct URL

Post Reply
athletechs
Posts: 4
Joined: 15 Oct 2016, 21:38

16 Jan 2018, 02:15

Hi,

On our left sidebar menu, we would like to add an icon that does not have a fly-out of subitems. Rather, when the user clicks on the main icon, they are taken directly to an URL within the application.

I've tried various options, but not getting anywhere.

Is this possible?

Thanks!
Dave

User avatar
aragorn
Posts: 2750
Joined: 29 Jun 2013, 12:38

12 Feb 2018, 07:24

I'll check and get back to you.

Regards,

User avatar
aragorn
Posts: 2750
Joined: 29 Jun 2013, 12:38

14 Feb 2018, 14:59

This structure isn't supported by pa:tab component. But, you can make the following changes in your project;

Code: Select all

//TabMenuRenderer.java
for(UIComponent child : children ){
            if(child.isRendered() && child instanceof Tab) {
                Tab tab = (Tab) child;
                writer.startElement("li", tab);
                    writer.startElement("a", tab);
                    /************* Please make the following changes (line 35) ********/
                    if(tab.getUrl() != null) {
                        writer.writeAttribute("href", tab.getUrl(), null);
                    }
                    else {
                        writer.writeAttribute("href", "#", null);
                    }
                    /*****************************************************************/
                    
                    writer.writeAttribute("class", "ripplelink tabmenuitem-link", null);
  ....
  
  //primefaces-barcelona.taglib.xml
               <attribute> /* Line 96 */
			<description></description>
			<name>url</name>
			<required>false</required>
			<type>java.lang.String</type>
		</attribute>

//Tab.java
        public enum PropertyKeys {
           icon,
           url,    /* Added this line */
           title;
           ...
        }
        public java.lang.String getUrl() {
            return (java.lang.String) getStateHelper().eval(PropertyKeys.url, null);
        }
       public void setUrl(java.lang.String _url) {
           getStateHelper().put(PropertyKeys.url, _url);
       }
       ...
       
// layout.js
        this.tabMenuNavLinks.on('click', function(e) {
            $this.sidebar.css('overflow','hidden');
            var link = $(this);
            link.parent().addClass('active-item').siblings('.active-item').removeClass('active-item');
            
            /***************** line 60 ***********/
            var href = link.attr('href');  
            if(href && href !== '#') {
                window.location.href = href;
                return;
            }
            /**********************************/
            
            $this.wrapper.addClass('layout-wrapper-menu-active');
   ...

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest