Left Sidebar Icon with Direct URL

Forum rules
Please note that response time for technical support is within 3-5 business days.
Post Reply
athletechs
Posts: 8
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

mert.sincan
Posts: 5281
Joined: 29 Jun 2013, 12:38

12 Feb 2018, 07:24

I'll check and get back to you.

Regards,

mert.sincan
Posts: 5281
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

Return to “Barcelona - PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 3 guests