Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Latest Smart GWT 2.1 Build Overwrites SectionHeaderClickHandler ID's

    I've upgraded to the latest release which was built on 03/19/10 at 3:06am. It appears to break my SectionHeaderClickHandler as the ID's I assign to my SectionStackSections are being overwritten. I use the ID's in this handler to determine which SectionStackSection was clicked, as I previously had another issue using the SectionHeaderClickEvent.getSection() value when attempting to determine which one was clicked. Here's a sample of the code:

    Code:
    public class NavigatorSectionStack extends SectionStack
    {
        private static NavigatorSectionStack instance = null;
    
        protected final String EXPANDED_IMAGE_URL = "pinned.png";
        
        protected Img smartFoldersExpandedImg;
        protected Img myCartExpandedImg;
        
        /**
         * @return
         */
        public static NavigatorSectionStack getInstance()
        {
            if (instance == null)
            {
                instance = new NavigatorSectionStack();
            }
            
            return (instance);
        }
    
        /**
         * 
         */
        private NavigatorSectionStack()
        {
            setVisibilityMode(VisibilityMode.MUTEX);
            setShowExpandControls(Boolean.FALSE);
            setWidth("100%");
            setHeight("208px");
            
             // Smart Folders section...
            smartFoldersExpandedImg = new Img(EXPANDED_IMAGE_URL, 20, 20);
            smartFoldersExpandedImg.setMargin(new Integer(2));
            smartFoldersExpandedImg.setPadding(new Integer(0));
            smartFoldersExpandedImg.setImageType(ImageStyle.NORMAL);
            smartFoldersExpandedImg.setVisible(false);
    
            imgHTML = Canvas.imgHTML("smartfolders.png");
            title = "<span>" + imgHTML + "&nbsp;Smart Folders</span>";
            final SectionStackSection smartFoldersSection = new SectionStackSection(title);
            smartFoldersSection.setID("Smart Folders");
            smartFoldersSection.setControls(smartFoldersExpandedImg);
            smartFoldersSection.setExpanded(Boolean.FALSE);
            addSection(smartFoldersSection);
    
            // My Cart section...
            myCartExpandedImg = new Img(EXPANDED_IMAGE_URL, 20, 20);
            myCartExpandedImg.setMargin(new Integer(2));
            myCartExpandedImg.setPadding(new Integer(0));
            myCartExpandedImg.setImageType(ImageStyle.NORMAL);
            myCartExpandedImg.setVisible(false);
    
            imgHTML = Canvas.imgHTML("mybasket.png");
            title = "<span>" + imgHTML + "&nbsp;My Cart</span>";
            final SectionStackSection myCartSection = new SectionStackSection(title);
            myCartSection.setID("My Cart");
            myCartSection.setControls(myCartExpandedImg);
            myCartSection.setExpanded(Boolean.FALSE);
            addSection(myCartSection);
    
            addSectionHeaderClickHandler(new SectionHeaderClickHandler()
            {
                public void onSectionHeaderClick(SectionHeaderClickEvent event)
                {
                    if (event != null)
                    {
                        event.cancel();
    
                        smartFoldersExpandedImg.setVisible(false);
                        myCartExpandedImg.setVisible(false);
    
                        if (event.getSection() != null)
                        {
                            String sectionID = event.getSection().getID();
    
                            if (sectionID != null)
                            {
                                if (sectionID.equals(smartFoldersSection.getID()))
                                {
                                    // TODO: Change header to use orange gradiants...
                                    
                                    smartFoldersExpandedImg.setVisible(true);
                                    NavigatorCanvas.getInstance().showCard("smartFolders");
                                }
                                else if (sectionID.equals(myCartSection.getID()))
                                {
                                    // TODO: Change header to use orange gradiants...
                                    
                                    myCartExpandedImg.setVisible(true);
                                    NavigatorCanvas.getInstance().showCard("myCart");
                                }
                            }
                        }
                    }
                }
            });
        }
    }

    #2
    FYI: SectionStackSection.getName() seems to work instead.

    Comment


      #3
      Hi Ccocco
      Thanks for the posts.
      Yes - there is an underlying bug here which we're fixing -- in your usage getID() on the SectionStackSection object should have returned whatever you set the ID to.

      However we've introduced the "name" attribute rather than "ID" and this is probably what you should be using going forward.

      The main difference is that, together with the 'useGlobalSectionIDs' property, ID allows you to specify the ID of the actual section header component generated to represent the SectionStackSection on the page -- in which case it would have to be unique across the page, whereas 'name' is an identifier for the Section within the SectionStack and is only required to be unique within the sections in the stack.

      So short answer: while getID() should have worked for you (and we're fixing that), go ahead and use "setName()" and "getName()"

      Comment


        #4
        Fixed in SVN.

        Comment

        Working...
        X