Implementing AjaxBehavior with decoration

2011-02-20 Thread Nishant Neeraj
What is the easiest way to get following behavior:

1. When I click a link, a hidden DIV pops-up. The content of the DIV is
loaded via AJAX.
2. While the content is being loaded (it takes a couple of seconds), I need
to show the empty DIV with busy-spinner inside it.
3. The busy spinner eventually gets replaced by the content.
4. On clicking, anywhere other that the DIV, the div gets closed. I have JS
to do that.


I think I will have to extend AbstractDefaultAjaxBehavior and override
getAjaxCallDecorator, renderHead and getSuccessScript, may be. But I am not
able to be sure what goes where. Also, If I use simple Link or AjaxLink with
AbstractDefaultAjaxBehavior.

I am reading through these posts and a bit confused on the implementation
part

1. http://blog.jayway.com/2008/09/26/wicket-javascript-internals-dissected/
2. https://cwiki.apache.org/WICKET/calling-wicket-from-javascript.html
3.
http://javathoughts.capesugarbird.com/2008/01/wicket-13-ajax-button-with-confirmation.html


I am using Wicket 1.4.9.

Regards
Nishant


Re: Implementing AjaxBehavior with decoration

2011-02-20 Thread Igor Vaynberg
see org.apache.wicket.extensions.ajax.markup.html.AjaxLazyLoadPanel in
extensions

-igor

On Sun, Feb 20, 2011 at 4:07 AM, Nishant Neeraj
nishant.has.a.quest...@gmail.com wrote:
 What is the easiest way to get following behavior:

 1. When I click a link, a hidden DIV pops-up. The content of the DIV is
 loaded via AJAX.
 2. While the content is being loaded (it takes a couple of seconds), I need
 to show the empty DIV with busy-spinner inside it.
 3. The busy spinner eventually gets replaced by the content.
 4. On clicking, anywhere other that the DIV, the div gets closed. I have JS
 to do that.


 I think I will have to extend AbstractDefaultAjaxBehavior and override
 getAjaxCallDecorator, renderHead and getSuccessScript, may be. But I am not
 able to be sure what goes where. Also, If I use simple Link or AjaxLink with
 AbstractDefaultAjaxBehavior.

 I am reading through these posts and a bit confused on the implementation
 part

 1. http://blog.jayway.com/2008/09/26/wicket-javascript-internals-dissected/
 2. https://cwiki.apache.org/WICKET/calling-wicket-from-javascript.html
 3.
 http://javathoughts.capesugarbird.com/2008/01/wicket-13-ajax-button-with-confirmation.html


 I am using Wicket 1.4.9.

 Regards
 Nishant


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Making Ajax Download Work With Validator Messages (in FeedbackPanel)

2011-02-20 Thread eugenebalt

Guys,

I almost got the Ajax Download-with-Form Refresh to work. I followed this
example of how to do an Ajax download:
https://cwiki.apache.org/WICKET/ajax-update-and-file-download-in-one-blow.html

But there is one problem; the form has a FeedbackPanel which shows Validator
messages.

With this approach, no Validator errors get displayed if there is any error.
The errors are in fact thrown (I verify it in the console), but they are not
*shown*.

It looks like I never enter the Ajax Download's getResourceStream() and I
never enter Form onSubmit() if there are any errors, so I can't control the
FeedbackPanel from these locations. The flow stops somewhere earlier.

How do I show Validator messages in the FeedbackPanel with this approach?
Thanks.
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Making-Ajax-Download-Work-With-Validator-Messages-in-FeedbackPanel-tp3315334p3315334.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Making Ajax Download Work With Validator Messages (in FeedbackPanel)

2011-02-20 Thread eugenebalt

My code is below.

1) In Form Constructor:

public MyForm(String id) {
super(id);

// add BeginDate/EndDate text fields: these require validation
add(new TextField(bdate, new PropertyModel(myBean, bdate))
.add(new ErrorDateValidator1())
.add(new ErrorDateValidator2()));

add(new TextField(edate, new PropertyModel(myBean, edate))  
.add(new ErrorDateValidator1())
.add(new ErrorDateValidator2()));

// add Feedback Panel
FeedbackPanel feedbackPanel = new FeedbackPanel(feedback);
feedbackPanel.setOutputMarkupId(true);
add(feedbackPanel);

// add AJAX Download object - from example
final AJAXDownload download = new AJAXDownload() { 

  @Override 
protected IResourceStream getResourceStream() {
 File f = generateFile();   
 return new FileResourceStream(f);
 }

@Override 
 protected String getFileName() { 
return report.xls; 
 } 
 };
 add(download);   // add to the form

 // add Submit AjaxButton
 add(new AjaxButton(submitButton) { 

@Override
protected void onSubmit(AjaxRequestTarget target, Form? form) {

 // Refresh Feedback Panel
 target.addComponent(form.get(feedback));

 // finally initiate the download 
 download.initiate(target); 
} 
  }); 


}


2) Form onSubmit() is blank. It never even gets this far if there is a
Validator error, and it doesn't get to the Ajax getResourceStream() either
in this case. If there are no validation errors, the download works OK. But
if there are validation messages upon submission, they must be displayed in
the Feedback Panel.
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Making-Ajax-Download-Work-With-Validator-Messages-in-FeedbackPanel-tp3315334p3315343.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Making Ajax Download Work With Validator Messages (in FeedbackPanel)

2011-02-20 Thread Igor Vaynberg
whatever you are using to submit the form with ajax has an
onError(target) method that you can override and update the feedback
panel with.

-igor

On Sun, Feb 20, 2011 at 10:24 AM, eugenebalt eugeneb...@yahoo.com wrote:

 My code is below.

 1) In Form Constructor:

    public MyForm(String id) {
        super(id);

        // add BeginDate/EndDate text fields: these require validation
        add(new TextField(bdate, new PropertyModel(myBean, bdate))
        .add(new ErrorDateValidator1())
        .add(new ErrorDateValidator2()));

        add(new TextField(edate, new PropertyModel(myBean, edate))
        .add(new ErrorDateValidator1())
        .add(new ErrorDateValidator2()));

        // add Feedback Panel
        FeedbackPanel feedbackPanel = new FeedbackPanel(feedback);
        feedbackPanel.setOutputMarkupId(true);
        add(feedbackPanel);

        // add AJAX Download object - from example
        final AJAXDownload download = new AJAXDownload() {

                  @Override
            protected IResourceStream getResourceStream() {
                 File f = generateFile();
                 return new FileResourceStream(f);
                 }

            @Override
             protected String getFileName() {
                        return report.xls;
             }
         };
         add(download);   // add to the form

         // add Submit AjaxButton
         add(new AjaxButton(submitButton) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form? form) {

             // Refresh Feedback Panel
             target.addComponent(form.get(feedback));

             // finally initiate the download
             download.initiate(target);
                        }
          });


    }


 2) Form onSubmit() is blank. It never even gets this far if there is a
 Validator error, and it doesn't get to the Ajax getResourceStream() either
 in this case. If there are no validation errors, the download works OK. But
 if there are validation messages upon submission, they must be displayed in
 the Feedback Panel.
 --
 View this message in context: 
 http://apache-wicket.1842946.n4.nabble.com/Making-Ajax-Download-Work-With-Validator-Messages-in-FeedbackPanel-tp3315334p3315343.html
 Sent from the Users forum mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Making Ajax Download Work With Validator Messages (in FeedbackPanel)

2011-02-20 Thread eugenebalt

You're the man, Igor! :)

Thanks a lot. It's working now.
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Making-Ajax-Download-Work-With-Validator-Messages-in-FeedbackPanel-tp3315334p3315433.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Making Ajax Download Work With Validator Messages (in FeedbackPanel)

2011-02-20 Thread eugenebalt

I just have one more question.

I need to put a red frame around the fields that have errors, in addition to
displaying the Feedback message. I overrode onError() and did
target.addComponent(feedbackPanel) so I'm getting the message displayed,
that part works great.

Now I just need to update the red marker around the fields with errors. How
do I do that? Thanks
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Making-Ajax-Download-Work-With-Validator-Messages-in-FeedbackPanel-tp3315334p3315454.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Making Ajax Download Work With Validator Messages (in FeedbackPanel)

2011-02-20 Thread eugenebalt

Any help with the above question? (update red/normal border around problem
fields, I need to do it manually here, I think)

I was thinking of iterating over all my components and doing a
target.addComponent() on each one. That updates their border, but I can't
make all my components setOutputMarkupId(true), which is necessary for this
Ajax update.

Any thoughts on how to update the border around the problem fields with this
manual invocation? Thanks a lot for your help.
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Making-Ajax-Download-Work-With-Validator-Messages-in-FeedbackPanel-tp3315334p3315519.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: wicket tree

2011-02-20 Thread mlabs

ok well I was in fact able to override the width by placing this style on the
page:

style type=text/css
div.wicket-tree {
width: 60em !important;
}
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/wicket-tree-tp3313498p3316658.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



How to do document.write(Hello Word); in Wicket?

2011-02-20 Thread Paolo
How can I write something into the HTML page, from Java code.
A similar fast metod like in javascript to write in HTML:

document.write(Hello word);

It is userfull for conditional messagge like:

If (sum==5) { document.write(It is right!) }

or it may be userfull for an simple email antispam system, like in javascript:

document.write(irresi+stiblecam+@+gma+il.com);

Thank you.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



How discover the caller page (referer)?

2011-02-20 Thread Paolo
How can I discover the caller page (referer) of my wicket application or 
specific page?

http://en.wikipedia.org/wiki/HTTP_referrer

Thank you.
Paolo

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Just 100K per session? That would be my dream come true! (Anyone here who has tuned session size before?)

2011-02-20 Thread Eelco Hillenius
 Reading in the other thread that a session size of 100K or less
 is achievable, I'll admit defeat now: I have not been able to shrink some of
 my pages(!) to less than 200K, not to mention the sessions. Despite LDMs,
 CompoundPropertyModels, and no, there are no domain objects in there, and no
 finals.

How are you measuring this? Keep in mind that if you calculate when a
request is still processing, you might still be measuring temporary
data (e.g. for LoadableDetachableModel, you would also measure the
transientModelObject, and same for any proxies (Spring/ Guice) you
might use.

Eelco

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: How to do document.write(Hello Word); in Wicket?

2011-02-20 Thread Pedro Santos
You can use an Label with escapeModelStrings set to false

On Sun, Feb 20, 2011 at 10:35 PM, Paolo irresistible...@gmail.com wrote:

 How can I write something into the HTML page, from Java code.
 A similar fast metod like in javascript to write in HTML:

 document.write(Hello word);

 It is userfull for conditional messagge like:

 If (sum==5) { document.write(It is right!) }

 or it may be userfull for an simple email antispam system, like in
 javascript:

 document.write(irresi+stiblecam+@+gma+il.com);

 Thank you.

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




-- 
Pedro Henrique Oliveira dos Santos


Re: How to do document.write(Hello Word); in Wicket?

2011-02-20 Thread Jeremy Thomerson
On Sun, Feb 20, 2011 at 7:35 PM, Paolo irresistible...@gmail.com wrote:

 How can I write something into the HTML page, from Java code.
 A similar fast metod like in javascript to write in HTML:

 document.write(Hello word);

 It is userfull for conditional messagge like:

 If (sum==5) { document.write(It is right!) }


If this were a sum of something else dynamic on the page, it should be done
in a model because other things can change the value while on that page.
 Doing it, for instance, an AbstractReadOnlyModel would ensure that the
calculation is always current.


 or it may be userfull for an simple email antispam system, like in
 javascript:

 document.write(irresi+stiblecam+@+gma+il.com);


This makes absolutely no sense.  If you had document.write on the server
side, your example would be writing the email address out in its complete
form to be rendered on the client.

-- 
Jeremy Thomerson
http://wickettraining.com
*Need a CMS for Wicket?  Use Brix! http://brixcms.org*


Re: How discover the caller page (referer)?

2011-02-20 Thread Jeremy Thomerson
Get the http servlet request from the request, and get the referrer header.

On Sun, Feb 20, 2011 at 8:09 PM, Paolo irresistible...@gmail.com wrote:

 How can I discover the caller page (referer) of my wicket application or
 specific page?

 http://en.wikipedia.org/wiki/HTTP_referrer

 Thank you.
 Paolo

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




-- 
Jeremy Thomerson
http://wickettraining.com
*Need a CMS for Wicket?  Use Brix! http://brixcms.org*