You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by John <jo...@quivinco.com> on 2014/03/15 18:03:45 UTC

an old chestnut - how to disable form inputs after submit pressed

The user presses submit the server takes a while during which submit can be pressed again.

I need to rerender the form inputs disabled and then fire the submit. How to?

John

---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com

Re: an old chestnut - how to disable form inputs after submit pressed

Posted by Lenny Primak <lp...@hope.nyc.ny.us>.
https://code.google.com/p/flowlogix/wiki/TLDisableAfterSubmit

> On Mar 15, 2014, at 12:03 PM, "John" <jo...@quivinco.com> wrote:
> 
> The user presses submit the server takes a while during which submit can be pressed again.
> 
> I need to rerender the form inputs disabled and then fire the submit. How to?
> 
> John
> 
> ---
> This email is free from viruses and malware because avast! Antivirus protection is active.
> http://www.avast.com

Re: an old chestnut - how to disable form inputs after submit pressed

Posted by John <jo...@quivinco.com>.
Thats a neat idea, thanks.

I see I have a problem in that above the form some of the data selection is not done by input fields but via eventlinks. I either have to render these out.

It seems it would be easier to trigger an unclosable modal dialog that says the server is working that disappaears when the request returns.

Any ideas how to do that on submit, perhaps another mixin?

John
  ----- Original Message ----- 
  From: Jon Williams 
  To: Tapestry users 
  Sent: Saturday, March 15, 2014 5:59 PM
  Subject: Re: an old chestnut - how to disable form inputs after submit pressed


  Wrap the input fields and other stuff into a <fieldset> and give it the
  disabled="disabled"attribute.

  Example http://jsfiddle.net/7qGHN/



  On Sat, Mar 15, 2014 at 11:28 AM, Jon Williams
  <wi...@gmail.com>wrote:

  > http://www.codehooligans.com/2006/06/04/convert-forms-to-printable-content/
  >
  >
  > On Sat, Mar 15, 2014 at 11:25 AM, John <jo...@quivinco.com> wrote:
  >
  >> that would be even better
  >>
  >> thanks for the tip
  >>   ----- Original Message -----
  >>   From: Jon Williams
  >>   To: Tapestry users
  >>   Sent: Saturday, March 15, 2014 5:21 PM
  >>   Subject: Re: an old chestnut - how to disable form inputs after submit
  >> pressed
  >>
  >>
  >>   Or do you want to toggle all the form elements to Read only after the
  >> user
  >>   clicks the submit?
  >>
  >>
  >> ---
  >> This email is free from viruses and malware because avast! Antivirus
  >> protection is active.
  >> http://www.avast.com
  >>
  >
  >


---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com

Re: an old chestnut - how to disable form inputs after submit pressed

Posted by Jon Williams <wi...@gmail.com>.
Wrap the input fields and other stuff into a <fieldset> and give it the
disabled="disabled"attribute.

Example http://jsfiddle.net/7qGHN/



On Sat, Mar 15, 2014 at 11:28 AM, Jon Williams
<wi...@gmail.com>wrote:

> http://www.codehooligans.com/2006/06/04/convert-forms-to-printable-content/
>
>
> On Sat, Mar 15, 2014 at 11:25 AM, John <jo...@quivinco.com> wrote:
>
>> that would be even better
>>
>> thanks for the tip
>>   ----- Original Message -----
>>   From: Jon Williams
>>   To: Tapestry users
>>   Sent: Saturday, March 15, 2014 5:21 PM
>>   Subject: Re: an old chestnut - how to disable form inputs after submit
>> pressed
>>
>>
>>   Or do you want to toggle all the form elements to Read only after the
>> user
>>   clicks the submit?
>>
>>
>> ---
>> This email is free from viruses and malware because avast! Antivirus
>> protection is active.
>> http://www.avast.com
>>
>
>

Re: an old chestnut - how to disable form inputs after submit pressed

Posted by Jon Williams <wi...@gmail.com>.
http://www.codehooligans.com/2006/06/04/convert-forms-to-printable-content/


On Sat, Mar 15, 2014 at 11:25 AM, John <jo...@quivinco.com> wrote:

> that would be even better
>
> thanks for the tip
>   ----- Original Message -----
>   From: Jon Williams
>   To: Tapestry users
>   Sent: Saturday, March 15, 2014 5:21 PM
>   Subject: Re: an old chestnut - how to disable form inputs after submit
> pressed
>
>
>   Or do you want to toggle all the form elements to Read only after the
> user
>   clicks the submit?
>
>
> ---
> This email is free from viruses and malware because avast! Antivirus
> protection is active.
> http://www.avast.com
>

Re: an old chestnut - how to disable form inputs after submit pressed

Posted by John <jo...@quivinco.com>.
that would be even better

thanks for the tip
  ----- Original Message ----- 
  From: Jon Williams 
  To: Tapestry users 
  Sent: Saturday, March 15, 2014 5:21 PM
  Subject: Re: an old chestnut - how to disable form inputs after submit pressed


  Or do you want to toggle all the form elements to Read only after the user
  clicks the submit?


---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com

Re: an old chestnut - how to disable form inputs after submit pressed

Posted by Jon Williams <wi...@gmail.com>.
Or do you want to toggle all the form elements to Read only after the user
clicks the submit?

Re: an old chestnut - how to disable form inputs after submit pressed

Posted by Jon Williams <wi...@gmail.com>.
You can accomplish this with a mixin

ClickOnce.java
@Import(library="context:js/clickonce.js")
public class ClickOnce {

    @Inject
    private JavaScriptSupport javaScriptSupport;

    @InjectContainer
    private ClientElement clientElement;

    @AfterRender
    public void afterRender() {

        // Tell the Tapestry.Initializer to do the initializing of a
ClickOnce, which it will do when the DOM has been
        // fully loaded.

        JSONObject spec = new JSONObject();
        spec.put("elementId", clientElement.getClientId());
        javaScriptSupport.addInitializerCall("clickonce", spec);
    }
}


clickonce.js
// A class that ignores clicks after the first one.

var ClickOnce = function(elementId) {
    this.elementId = elementId;
    alreadyClickedOnce = false;
}

$.extend(ClickOnce.prototype, {
    bind : function() {
        var id = "#"+this.elementId;
        $(id).on('click', this, function(event) {
            //prevent default events
            if (alreadyClickedOnce) {
                event.preventDefault();
            }
            alreadyClickedOnce = true;
        });
    }
});

// Extend the Tapestry.Initializer with a static method that instantiates a
ClickOnce.
Tapestry.Initializer.clickonce = function(spec) {
    new ClickOnce(spec.elementId).bind();
}


example Usage in .tml
<t:submit t:id="saveImageSubmit" value="Save image" t:mixins="clickonce"/>


On Sat, Mar 15, 2014 at 11:03 AM, John <jo...@quivinco.com> wrote:

> The user presses submit the server takes a while during which submit can
> be pressed again.
>
> I need to rerender the form inputs disabled and then fire the submit. How
> to?
>
> John
>
> ---
> This email is free from viruses and malware because avast! Antivirus
> protection is active.
> http://www.avast.com
>