3

I have a sectionStack where sections are added dynamically and I have added a handler to the section stack.

When a sectionStack section is clicked I want to get the id or the contents of the section clicked . How can I do this?

Jama A.
  • 15,680
  • 10
  • 55
  • 88
Ekata
  • 259
  • 2
  • 7
  • 21

1 Answers1

1

SectionStackSection has the methods

String getID()

which will return a string.

please see JavaDoc

If you want to get the currently selected SectionStackSection then you should add a SectionHeaderClickHandler via

public HandlerRegistration addSectionHeaderClickHandler(SectionHeaderClickHandler handler)

to the SectionStack. The SectionHeaderClickEvent will give you the method getSection()

please see SectionHeaderClickEvent

Martin
  • 584
  • 3
  • 12
  • But how do you know which SectionStackSection's method for getting the ID has to be called? The event source for the click event is the SectionStack object when I tried to accomplish this. – devrys Sep 24 '12 at 19:04
  • Sry missunderstood your question. As far as I know there is no direct way of getting this information. The indirect way is to use addSectionHeaderClickHandler and go from there. I will edit my answer. – Martin Sep 24 '12 at 20:08
  • Martin thank you :) i tried tht method but it doesnt fit in my case as the sectionStack sections are added dynamically – Ekata Sep 25 '12 at 03:43
  • Please provide some code. Have you added the SectionStack or the SectionStackSections dynamically? Anyhow it should still work, why does it not work? But remember that the ID is optional so you might have to provide the id manually (not sure about this). – Martin Sep 25 '12 at 06:01
  • Wouldn't it be possible to add a ClickHandler to the content of the SectionStackSection that returns its parent widget getID() ? – devrys Sep 25 '12 at 06:43
  • 1
    @RaynCGN I am confused with what is actually wanted here. This might be due to all these odd wordings of SmartGWT. Anyhow, if a tab is clicked a SectionHeaderClickEvent is fired. This event provides a method GetSection which will give you the SectionStackSection. The SectionStackSection provides a method getSectionStack which will give you the SectionStack. Now you have all sections that you could possibly want. I need you or Ekata to be more specific. – Martin Sep 25 '12 at 06:53