Re: Feedback Panel and Ajax Busy Indicator

2008-01-30 Thread Martin Makundi
> and please rename arg0 to "target" :) It's a good idea to attach
> Wicket sources to your IDE (e.g. mvn -DdownloadSources=true eclipse:eclipse)
> because then this tends to happen automatically.

I have been thinking of attaching the sources... I found some example
of adding all sources of all packages in the repository. Is there a
way to limit this to e.g., specific packages? This way I can lazy-load
the sources whenever needed. And does it require some additional setup
from Eclipse (e.g., pom.xml/project properties) or will it
automatically find the existing sources from maven repository?

> > > add(new FeedbackPanel("feedback"));
> Change this to
> add(new FeedbackPanel("feedback").setOutputPlaceHolderTag(true));

I will try these and comment.
> > >   /**
> > >* This method TODO
> > >*/
> ...and it would be a good idea to cleanup code formatting
> and remove these comments...

I prefer to comment all non-private members and the template gives me a TODO...

> > > try {
> > >   Thread.sleep(5000);
> > > } catch (InterruptedException e) {
> > >   e.printStackTrace();
> > > }
> ...and fix the exception handling, throw new RuntimeException(e);

Relax, it's just mock-up-code, but yes, I completely agree with you on this ;)

**
Martin

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Feedback Panel and Ajax Busy Indicator

2008-01-30 Thread Timo Rantalaiho
On Wed, 30 Jan 2008, Martin Makundi wrote:
> 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?
...
> >   final AjaxButton loginButton = new MyAjaxButton("loginButton",
> > loginForm) {
> > @Override
> > protected void onSubmit(AjaxRequestTarget arg0, Form arg1) {
> >   simulateLoginTransaction();
> > }

In onSubmit, also call

  target.addComponent(IndicatorLogin.this.get("feedback"));

and please rename arg0 to "target" :) It's a good idea to attach
Wicket sources to your IDE (e.g. 
mvn -DdownloadSources=true eclipse:eclipse) because then 
this tends to happen automatically.

> > add(new FeedbackPanel("feedback"));

Change this to 

add(new FeedbackPanel("feedback").setOutputPlaceHolderTag(true));

> > add(loginForm);
> > }
> >
> >   /**
> >* This method TODO
> >*/

...and it would be a good idea to cleanup code formatting
and remove these comments...

> >   synchronized void simulateLoginTransaction() {
> > System.out.println("Transaction begin.");
> > try {
> >   Thread.sleep(5000);
> > } catch (InterruptedException e) {
> >   e.printStackTrace();
> > }

...and fix the exception handling, throw new RuntimeException(e);

Best wishes,
Timo

-- 
Timo Rantalaiho   
Reaktor Innovations Oyhttp://www.ri.fi/ >

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Feedback Panel and Ajax Busy Indicator

2008-01-30 Thread Martin Makundi
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]