Hi!
I got the Ajax busy indicator working with the code below, but I have
run into a new problem: the feedbackpanel does not display the
feedbacks anymore. Does anyone know what I managed to do wrong
eventually? And more importantly, how to fix the feedback panel?
**
Martin
2008/1/30, Martin Makundi <[EMAIL PROTECTED]>:
> 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);
> }
> };
>
>
> http://wicket.sourceforge.net";>
>
> Login form
>
>
> Login
> Feedback messages will be here.
>
>
>
> Username:
>
>
>
> Password:
>
> wicket:id="ajaxIndicator"/>
>
>
>
>
>
>
>
>
> **
> Martin
>
>
> 2008/1/30, Igor Vaynberg <[EMAIL PROTECTED]>:
> > > 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]