Announcement

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

    SectionStackSection getID() is null

    Hello,

    this function has changed with SmartGWT 2.3:
    Code:
        /**
         * Title to show for the section
         *
         * @return String
         */
        public String getTitle()  {
            if(stack == null || !stack.isDrawn()) {
                return getAttributeAsString("title");
            } else {
                return stack.getSection(getID()).getAttribute("title");
            }
        }
    It was
    Code:
        public String getTitle()  {
            return getAttributeAsString("title");
        }

    On an already drawn stack and sections we call getTitle(), but getID() returns null resulting in an error. We don't set IDs ourselves.


    Calling getTitle() on a not yet drawn stack is OK.

    SmartGWT 2.3 2010-08-09

    #2
    This has been fixed. Please pick up the next nightly build.

    Sanjiv

    Comment


      #3
      Thanks Sanjiv. Will check tomorrow.

      Comment


        #4
        Oops, the error was still there.
        But I found the cause: the section was set with a setName which contains a space.
        Would be great to get this rule enforced somehow at compile time.

        Though it's still a bit of a mystery why the name has effect on the getTitle.

        Here's a repro:
        Code:
        VLayout result = new VLayout();
        
        final SectionStack stack = new SectionStack();
        SectionStackSection section1 = new SectionStackSection("My title");
        section1.setName("contains a space which results in nullpointer during getTitle");
        section1.setExpanded(true);
        stack.setSections(section1);
        
        Button b = new Button("Click me");
        b.addClickHandler(new ClickHandler() {
        	
        	public void onClick(ClickEvent event) {
        		StringBuilder allTitles = new StringBuilder();
        		for (SectionStackSection section : stack.getSections()) {
        			allTitles.append(section.getTitle()).append(' ');
        		}
        		SC.say(allTitles.toString());
        	}
        });
        
        
        result.setMembers(stack, b);

        Comment


          #5
          Hi, previous cause was a mistake. I only tested without setting setName. getTitle still throws a nullpointer when setting setName - even without spaces in the name.

          Comment


            #6
            Hi Levi
            This should be fixed in our next nightly build.
            Let us know if you continue to have problems with it

            Thanks

            Comment


              #7
              Hi Paul,

              tested with 2010-09-01 build and the 3 following cases all work:

              Code:
              section1.setName("contains a space which results in nullpointer during getTitle");
              
              section1.setName("name");
              
              //section1.setName("name");
              thanks for the fix!

              Comment


                #8
                Hello,

                I've got some trouble setting a title of a SectionStackSection after it has been created.

                I got it working by not using the setTitle() as in code with getName() but with getID() as such:

                Code:
                stack.setSectionTitle(section.getID(), newTitle);
                SmartGWT EE SC_SNAPSHOT-2011-01-25

                class SectionStackSection :
                Code:
                    /**
                     * Title to show for the section
                     *
                     * @param title title Default value is null
                     */
                    public void setTitle(String title) {
                        if(stack == null || !stack.isDrawn()) {
                            setAttribute("title", title);
                        } else {
                            stack.setSectionTitle(getName(), title);
                        }
                    }

                What should be the correct way?
                I tried setting a hard setName("name") on the section, but that didn't help.

                Comment


                  #9
                  This API should be working. Here's a simple test case where it works as expected:
                  Code:
                      @Override
                      public void onModuleLoad() {
                             final SectionStackSection s1 = new SectionStackSection();
                             s1.setTitle("initial title");
                             
                             Button b = new Button();
                             b.setTitle("change SS title");
                             b.addClickHandler(new ClickHandler() {
                              
                                  @Override
                                  public void onClick(ClickEvent event) {
                                      s1.setTitle("NEW TITLE" + new Date().getTime());
                                  }
                             });
                             
                             s1.setItems(b);
                             
                             SectionStack stack = new SectionStack();
                             stack.setWidth100();
                             stack.setHeight100();
                             stack.setSections(s1);
                             
                             stack.draw();
                          
                      }
                  There must be something about the way your section stack is defined that is causing it to behave differently. Can you try boiling it down to a simple test case like the one above that we can run on our end to see the problem?

                  Thanks
                  Isomorphic Software

                  Comment


                    #10
                    I haven't tried this in a standalone case yet, but I print out the section.getSectionStack().isDrawn() and isVisible().
                    - When the title has been set OK, I see drawn==true and visible==true

                    - When the title has not been set, I see drawn==false and visible==true.


                    After setting the title, I call section.setExpanded(true). And also in the 2nd case, the section is not expanded.

                    I'll try figuring out if this piece of code really isn't executed before the stack has been drawn, but since visible==true, it's already been added to its parent, which should haven been drawn already.

                    Comment

                    Working...
                    X