users@woodstock.java.net

RE: RE: Submit and disable a button

From: Vijaya Bhaskar Tsaliki <vijayabhaskar.t_at_sonata-software.com>
Date: Mon, 13 Oct 2008 14:25:36 +0530

Hi,

I have used the following to disable submit button and show
work-in-progress image. It is working well.

// Button
<webuijsf:button actionExpression="#{BackBean.button_action}"
id="button" onClick="setTimeout('showWorkInProgress()', 1)"
text="Submit"/>

// Initially show blank image
<webuijsf:image id="image1" url="/resources/images/blankImage.gif"/>

// JS function called on button click.
function showWorkInProgress(){
  var domNode =document.getElementById("form1:button ")
  domNode.setProps({disabled : true});
  domNode =document.getElementById("form1:image1")
 
domNode.setAttribute("src","/AppName/resources/images/inProgress.gif");
}

Hope this helps.

Regards,
Vijay


-----Original Message-----
From: Stefan Bley [mailto:stefan.bley_at_saxsys.de]
Sent: Friday, October 10, 2008 2:51 PM
To: users_at_woodstock.dev.java.net
Subject: RE: Submit and disable a button


Hi Steffen,

unfortunately it is not that easy. The form is submitted, but you don't
end
in your button's action listener.
Here is a solution to this problem. I found the important line in the
glassfish admin console sources and... it works! :-)

function submitAndDisable(button, msg) {
    button.setProps({disabled: true, value: msg});
    button.form.action += "?" + button.name + "=" +
encodeURI(button.value);
// important line
    button.form.submit();
    return true;
}

<webuijsf:button id="btnLogin"
actionExpression="#{Login.handleBtnLogin}"
onClick="submitAndDisable(this, 'Please wait...');" text="Login" />


IOLAUS wrote:
>
> Hi Stefan,
>
> To disable the Button and submit the form after press is easy. See the
TLD
> Doc about that or try the code until this text.
>
>
> // Write this code in your Button onClick method.
> "btnLogin" call the id of your Button
>
> domNode=document.getElementById("form1:btnLogin");
> domNode.setProps({disabled:true});
>

-- 
View this message in context:
http://www.nabble.com/Submit-and-disable-a-button-tp16322463p19914888.ht
ml
Sent from the Project Woodstock - Users mailing list archive at
Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_woodstock.dev.java.net
For additional commands, e-mail: users-help_at_woodstock.dev.java.net