no, you dont need to extend an ajaxbutton, IAjaxIndicatorAware works
on any component that has any kind of ajax behavior added to it
-igor
On Jan 30, 2008 1:34 PM, Martin Makundi
<[EMAIL PROTECTED]> wrote:
> Hi!
>
> Tnx Igor, I finally got it working after quite some wrestling.. I
> understood I must extend the AjaxButton? I shall play around with it
> some more in order to more fully understand it.
>
> However, in case someone else needs it too, my complete code and
> markup is available below for ajax busy indicator for form submit
> button.
>
> /**
> * This class TODO
> */
> public class IndicatorLogin extends WebPage {
> private static final long serialVersionUID = 1L;
> /**
> * Constructor for TODO
> */
> @SuppressWarnings("serial")
> public IndicatorLogin() {
> final Form loginForm = new Form("loginForm", new Model());
> final AjaxIndicatorContainer indicatorContainer = new
> AjaxIndicatorContainer(loginForm);
> {
> TextField userIdField = new TextField("userId", new Model());
> userIdField.setRequired(true);
> loginForm.add(userIdField);
> }
> {
> PasswordTextField passwdField = new
> PasswordTextField("password", new Model());
> passwdField.setResetPassword(false);
> loginForm.add(passwdField);
> }
> {
> final AjaxButton loginButton = new MyAjaxButton("loginButton",
> loginForm) {
> @Override
> protected void onSubmit(AjaxRequestTarget arg0, Form arg1) {
> simulateLoginTransaction();
> }
>
> public String getAjaxIndicatorMarkupId() {
> return indicatorContainer.getMarkupId();
> }
> };
> loginForm.add(loginButton);
> }
> add(new FeedbackPanel("feedback"));
> add(loginForm);
> }
>
> /**
> * This method TODO
> */
> synchronized void simulateLoginTransaction() {
> System.out.println("Transaction begin.");
> try {
> Thread.sleep(5000);
> } catch (InterruptedException e) {
> e.printStackTrace();
> }
> System.out.println("Transaction complete.");
> }
> }
>
> /**
> * This class TODO
> */
> @SuppressWarnings("serial")
> class AjaxIndicatorContainer extends WebMarkupContainer {
> /**
> * Constructor for TODO
> * @param form
> */
> public AjaxIndicatorContainer(Form form) {
> super("ajaxIndicator"); // wicket:id
> setOutputMarkupId(true);
> setMarkupId("ajaxIndicatorId"); // markup:id
> form.add(this);
> }
>
> /**
> * @see
> org.apache.wicket.Component#onComponentTag(org.apache.wicket.markup.ComponentTag)
> */
> @Override
> protected void onComponentTag(ComponentTag tag) {
> super.onComponentTag(tag);
> tag.put("src",urlFor(AbstractDefaultAjaxBehavior.INDICATOR));
> }
> }
>
> abstract class MyAjaxButton extends AjaxButton implements IAjaxIndicatorAware
> {
> /**
> * Constructor for TODO
> *
> * @param id
> * @param form
> */
> public MyAjaxButton(String id, Form form) {
> super(id, form);
> }
> };
>
>
> <html xmlns:wicket="http://wicket.sourceforge.net">
> <head>
> <title>Login form</title>
> </head>
> <body>
> <h1>Login</h1>
> <span wicket:id="feedback">Feedback messages will be here.</span>
> <form wicket:id="loginForm">
> <table border="0" cellspacing="0" cellpadding="2" align="center">
> <tr><td NOWRAP width="80" align="right">
> Username:
> </td>
> <td><input type="text" wicket:id="userId"></td></tr>
> <tr><td NOWRAP align="right">
> Password: </td><td><input type="password" wicket:id="password"></td></tr>
> <tr><td align="right">
> <img src="#" border="0" style="display:none"
> wicket:id="ajaxIndicator"/></td><td NOWRAP>
> <input type="submit" value="Sign in" wicket:id="loginButton">
> </td></tr>
> </table>
> </form>
> </body>
> </html>
>
>
> **
> Martin
>
>
> 2008/1/30, Igor Vaynberg <[EMAIL PROTECTED]>:
> > <img src="#" border="0" wicket:id="ajaxIndicatorImage"
> > id="ajaxIndicatorImage"/> should get you started :)
> >
> > the only caveat is if that image component for some reason has
> > setoutputmarkupid(true) set on it, in which case the id attr you put
> > into markup will be overwritten, to make this thing work dynamically
> > you would
> >
> > final Image image=new Image("ajxIndicatorImage", ...);
> > image.setOutputMarkupId(true);
> > image.setMarkupId('whatever-you-want-but-make-sure-its-unique');
> >
> > pass that markup id to your iajaxindicatorware component
> >
> > alternatively you can wire up the two components so the use wicket's
> > automatically generated markup id which is available via
> > component.getmarkupid() but the caveat is that it is only available
> > during render
> >
> > -igor
> >
> > class abstract mycomponent implements iajaxindicatoraware {
> > };
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]