Announcement

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

    Button Click

    GWT Buttons have the method click (), which fires off all the click handlers as if the button had been clicked. I thought action () would be the equivalent for SMART GWT buttons, but all it does for me is throw an exception.

    What is the accepted way to tell a Button (and, for that matter, a ButtonItem) to fire off its click handlers?

    (Why do I ask? Because in GWT I have an EnterButton class that fires off the button whenever one of the widgets it is monitoring has an Enter typed in it, and I'd like to make a class that does the same for Smart GWT.)

    TIA,

    Greg

    #2
    Instead of trying to call the click handler, call the method the click handler calls.

    Comment


      #3
      How would I do that, when I'm defining a single Class that extends Button, and will be used in many different places?

      Comment


        #4
        Originally posted by Isomorphic
        Instead of trying to call the click handler, call the method the click handler calls.
        With GWT, I do that by calling click (), and hte button acts as if it's been clicked. What is the equivalent for SmartGWT?

        Comment


          #5
          The create your own click() method on the subclass and put the code you currently have in the clickHandler there and both your outside trigger and the handler call click().

          As implied earlier there is no click() method to trigger an SGWT button handler.

          Comment


            #6
            "The code I have in the Click Handler" is whatever click listeners were attached to the button by the current code. It's a class I use in many different places, as a drop in replacement for a normal button.

            Since SGWT Button can't support that, I guess I'll stick with the GWT Button.

            Comment


              #7
              Don't mix core GWT and SmartGWT components - see FAQ.

              This is a pretty trivial factoring issue that you should have no trouble figuring out. Note that it's a cleaner pattern in most cases to have a button invoke a reusable action rather than directly contain business logic.

              Comment

              Working...
              X