Announcement Announcement Module
Collapse

Spring Modules forum decommissioned in favor of Spring Extensions

As the Spring Modules project has been replaced by the Spring Extensions (http://www.springsource.org/extensions) project, this forum has been decommissioned in favour of Spring Extensions one at:
http://forum.springsource.org/forumdisplay.php?f=44

Please see the Spring Extensions home page for a complete list of current projects in Java, .NET and ActionScript. You can also propose one if you want.

Cheers,
Costin Leau
SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
http://twitter.com/costinl
See more
See less
how to enable/disable button in xt ajax Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to enable/disable button in xt ajax

    Hello,

    I'm trying to enable/disable a button in my ajax handler as given below. But both cases, it is disabling the button. Any glue why is wrong here?
    If(some condition){
    SetAttributeAction action3 = new SetAttributeAction("buttonId","disabled","true");
    } else{
    SetAttributeAction action3 = new SetAttributeAction("buttonId","disabled","false");
    }

    Thanks

  • #2
    Originally posted by techluver View Post
    I'm trying to enable/disable a button in my ajax handler as given below. But both cases, it is disabling the button. Any glue why is wrong here?
    Try setting the "disabled" attribute only when you actually want to disable it; that is:

    Code:
    If(some condition){
    SetAttributeAction action3 = new SetAttributeAction("buttonId","disabled","true");
    } else{
    // do nothing
    }
    Cheers,

    Sergio B.

    Comment


    • #3
      Thanks for the reply.
      How can I enable the disabled button?

      Comment


      • #4
        techluver,

        The important thing to realise about the 'disabled' attribute is that is is a boolean attribute. This is the case from more than one point of view.

        Firstly, it is boolean because it is either on or off - no other states are supported.
        Secondly, it is boolean because, when used in HTML it doesn't need an attribute value - it is its presence/absence that determines its state, not the value, any value that is supplied is effectively ignored.
        When dealing with XHTML, a value is required (To make the markup 'well-formed' XML), but (I think) it is also ignored.

        Anyway, what Sergio was trying to say is that a button is enabled when the 'disabled' attribute is not present at all.

        I hope this clarifies things.

        Comment


        • #5
          Thanks again.
          I understand how to disable the button.
          Still I dont get the answer for enabling the disabled button thru ajax.

          Some sample code please.

          Sorry for my ignorant If this is very simple to do.

          Comment


          • #6
            Techluver,

            Sorry for misunderstanding your question.

            The issue that you have, with your current approach, is that there is no 'RemoveAttributeAction' class in the library.
            In order to implement this functionality, I'd suggest using the ExecuteJavascriptFunctionAttribute class instead.
            Using this, you can trigger the execution of a javascript function on the client side, that removes the 'disabled' attribute from the field with an id attribute of 'buttonId'.

            Code:
                    Map<String, Object> params = new HashMap<String, Object>();
                    params.put("id", "buttonId");
                    params.put("attributeName", "disabled");
                    response.addAction(new ExecuteJavascriptFunctionAction("removeAttribute", params));
            Code:
                    function removeAttribute(params){
                        var formField = document.getElementById(params["id"]);
                        if(formField != null){
                            formField.removeAttribute(params["attributeName"]);
                        }
                    }
            Admittedly, the provision of a 'RemoveAttributeAction' class would appear to be simpler and more succinct, so you should possibly submit a JIRA to request this.

            Comment


            • #7
              cool. Thanks a lot. JIRA for this : http://jira.springframework.org/browse/SEC-657
              Last edited by techluver; Apr 3rd, 2008, 07:07 AM.

              Comment


              • #8
                The JIRA entry is http: // jira.springframework.org/browse/MOD-457

                Comment

                Working...
                X