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


JavaScript form submission does not go to Button.onSubmit() method

2010-08-24 Thread Nishant Neeraj
I have a form which has a button. The processing code after submission is
written in Button.onSubmit() and Form.onSubmit() is not overridden. Now,
when I add a JavaScript confirmation asking if the user is ready to submit
the form. The JavaScript performs $('#formId').submit(). The form submission
does not take place. (page refreshes but no submission)

On debugging, I realized that  if I perform JavaScript form submission
(using  $('#formId').submit()) -- the control never goes to
Button.onSubmit(), rather it goes to only to Form.onSubmit(). So, my page
just reloads.

Is there a work-around so that if I perform $('#formId').submit() on
front-end -- the submit button's onSubmit() get called?

I would be reluctant to move code from Button.onSubmit() to Form.onSubmit()
because I have many forms where submission logic is written in
Button.onSubmit() and I may need to change those as well.

---

I am currently trying to simulate JavaScript's confirm behavior for button,
so that Button.onSubmit() get's the control when confirms the dialog. It's
here
http://stackoverflow.com/questions/3560872/returning-value-from-confirmation-dialog-using-jquery-ui-dialog

Thanks
Nishant


Re: About the Mail on this page mainly to Igor

2010-06-24 Thread Nishant Neeraj
:)

On Thu, Jun 24, 2010 at 6:14 PM, nino martinez wael <
nino.martinez.w...@gmail.com> wrote:

> if you want to go incognito just create an email address for that, like
> many
> of the other users on this list have done.
>
> -Nino
>
> 2010/6/24 midikem 
>
> >
> > Hi can u please put the mail invisible. When you search on google on your
> > mail you get all the posts from this forum, that you have posted, and i
> > dont
> > want my mail to be vissible to other people, due to spam and other
> stuffs.
> > --
> > View this message in context:
> >
> http://apache-wicket.1842946.n4.nabble.com/About-the-Mail-on-this-page-mainly-to-Igor-tp2266590p2266590.html
> > Sent from the Wicket - User 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
> >
> >
>


Http Error Page configuration causing Closing the buffer error

2010-06-22 Thread Nishant Neeraj
Hi,

I have configured http error pages as per
this[1]
document. It works fine except I see "closing the buffer error" NPE
[2](see the stack trace below), on almost all the pages.

Removing
REQUEST
ERROR
from wicket-filter tag stops the error but then error pages would not work.

Using wicket 1.4.9.

[1]
https://cwiki.apache.org/WICKET/error-pages-and-feedback-messages.html

[2]
[2010-06-22 13:17:18,375]ERROR - WicketFilter   - closing the
buffer error
java.lang.NullPointerException
at org.mortbay.jetty.Response.sendRedirect(Response.java:397)
at
org.apache.wicket.protocol.http.WebResponse.redirect(WebResponse.java:249)
at
org.apache.wicket.protocol.http.BufferedWebResponse.close(BufferedWebResponse.java:67)
at
org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:495)
at
org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:312)
at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1115)


Thanks
Nishant


Upload Max Size Exceeded: Early Warning

2010-05-23 Thread Nishant Neeraj
Hi,

I am using MultiFileUploadField to upload content and limiting size to 10MB
using form.setMaxSize(...).
It works as intended but there is one problem, the "max file-size limit
exceeded" warning comes after upload completes.

So, the issue is the user has started upload and is waiting; and at the end,
he gets this frustrating experience that size exceeded.
Is there a way to stop uploading and send a warning as soon as user starts
or at least send a warning (and stop uploading) when uploaded file crosses
the max-size limit?
I mean I just want to reduce users' waiting time if they have chosen to
upload a file bigger than permissible size for uploading.

This wasn't helpful. [1]

[1]
http://stackoverflow.com/questions/1761604/how-to-limit-upload-file-size-in-wicket

Thanks
Nishant


Re: How to give feedback in long-running operation within AjaxButton.onSubmit()?

2010-04-08 Thread Nishant Neeraj
I think you may look into this package
org.apache.wicket.extensions.ajax.markup.html.form.upload where upload
progress-bar is implemented. You may do something like this.

So, probably it sets a resource in session, Java part regularly updates the
string resource. And JS keeps on polling this resource by using the URL to
the resource provided to JS initializer and renders on UI. Anyone can
correct me, if I am wrong.

Just a suggestion. I am naive to Wicket.

- Nishant

On Fri, Apr 9, 2010 at 2:25 AM, Thomas Götz  wrote:

> I fear not. As far as I understand, getAjaxCallDecorator() decorates the
> javascript with a custom script, which is executed immediately upon hitting
> the button. What I want to achieve is displaying some status messaged during
> the progress of my long-term operation ...
>
>   -Tom
>
>
> On 08.04.2010 at 20:58 Fernando Wermus wrote:
>
> > Does this resolve your problem?
> >
> > @Override
> >
> > protected IAjaxCallDecorator getAjaxCallDecorator() {
> >
> >return new AjaxCallDecorator() {
> >
> >private static final long serialVersionUID = 1L;
> >
> > @Override
> >
> > public CharSequence decorateScript(CharSequence script) {
> >
> > return YOUR JAVASCRIPT + script;
> >
> > }
> >
> >};
> >
> > }
> >
> > On Thu, Apr 8, 2010 at 3:43 PM, Thomas Götz  wrote:
> >
> >> Problem:
> >> I have an AjaxButton that triggers a long-running operation when
> clicked. I
> >> want to give feedback (in form of a javascript message) upon partial
> >> completion of the operation, therefore I am using a jQuery notifications
> >> plugin (http://www.programmingmind.com/contributions).
> >>
> >> So, what I do is the following:
> >>
> >> final Form form = new Form("form");
> >> add(form);
> >>
> >> form.add(new AjaxButton("button) {
> >>   @Override
> >>   protected void onSubmit(AjaxRequestTarget target, Form form) {
> >>   for(Object o : someList) {
> >>   // do somthing
> >>   target.appendJavascript(getJavascript());
> >>   }
> >>   target.addComponent(form);
> >>   }
> >> });
> >>
> >>
> >> ... but obviously, the Javascript messages are only display at the end
> of
> >> the complete operation (after foreach loop has finished). So my
> question:
> >> what should I do to get the messages displayed after each iteration?
> >>
> >>  -Tom
> >>
> >>
> >> -
> >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> >> For additional commands, e-mail: users-h...@wicket.apache.org
> >>
> >>
> >
> >
> > --
> > Fernando Wermus.
> >
> > www.linkedin.com/in/fernandowermus
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Re: Best Practices for Using JavaScript With Wicket

2010-04-06 Thread Nishant Neeraj
ah, great! Thanks Stefan.
This is what I was looking for.

- Nishant

On Tue, Apr 6, 2010 at 9:45 PM, Stefan Lindner  wrote:

> Hi Nishant,
>
> you should use
>
>component.setOutputMarkupId(true);
>
> this tells wicket to generate a unique markup id. You can refer to the
> generated id with
>
> component.getMerkupId();
>
> later.
>
> If you want to add some javascript to your page, you may use two different
> tricks:
>
> A: Ajax-related
> If you have an AjaxTrigger (e.g. an AjaxLink) do the following
>
>AjaxLink() {
>onClick(AjaxRequestTarget target) {
>target.appendJavaScript();
>// e.g. doSomethingWithDomelementWithId('"+
> component.getmarkupId()+ "');
>}
>}
>
> B. during page creation
> If you want to bind some javascript during page creation/HTML render time
> try this
>
>Class MyPanel extends Panel {
>...
>
>@Override
>public void renderHead(HtmlHeaderContainer container) {
>
>  container.getHeaderResponse().renderJavascriptReference( reference to your js library here>);
>
>  container.getHeaderResponse().renderOnDomReadyJavascript("soSomethingWith('"
> + getMarkupId() + "');");
>}
>}
>
> And: Please have a look at the javadocs.
>
> Stefan
>
> -Ursprüngliche Nachricht-
> Von: Nishant Neeraj [mailto:nishant.has.a.quest...@gmail.com]
> Gesendet: Dienstag, 6. April 2010 18:02
> An: users@wicket.apache.org
> Betreff: Re: Best Practices for Using JavaScript With Wicket
>
> Thanks Jeremy.
>
> I had been using component.setMarkupId(..); which is not recommended... so
> I
> was wondering what is the standard.
> I need to get hands-on JS-Wicket integration, so I was looking for a good
> organized documentation/resource (other than WIA).
>
> > So, what's the objection to using it?
>
> :) Nothing against wiQuery and I, probably, will go with wiQuery... I was
> worried if I can integrate various the plug-ins available like jNice (
> http://www.whitespace-creative.com/jquery/jNice/) and likes.
>
> Thanks for pointers.
> Nishant
>
> On Tue, Apr 6, 2010 at 4:26 AM, Jeremy Thomerson
> wrote:
>
> > >
> > > I am finding it very cumbersome to integrate JavaScript/JS-library. Can
> > > someone point to (or probably write a blog-post on :->)  the best
> > practices
> > > of integrating JS/JS-library with Wicket.
> > >
> >
> > Wicket is pretty flexible in that you can integrate your JS a dozen
> > different ways.  jQuery is especially easy to integrate with because the
> > programming model matches Wicket's fairly nicely.  The primary thing is
> > that
> > if you want to use element IDs to tie in to jQuery, you'll need to do
> this
> > from behaviors in your java code so that you get the correct ID.
> >
> >
> > >
> > > I am using JQuery but I would like to know the best approach without
> > using
> > > WiQuery or jWicket. (Unless, I have to write my own jWicket to get this
> > > done.)
> > >
> >
> > I'm not sure I understand.  wiQuery has been fairly well recognized as a
> > very nice Wicket/jQuery integration.  It has active development and a
> > helpful mailing list.  So, what's the objection to using it?  I'm not
> > saying
> > that you can't have an objection, I just wonder what it is.  It's an open
> > source project, so you can use it as a base and add your own
> functionality
> > as needed (hopefully contributing back).
> >
> > Even if you don't want to use it, you can see some of the things they are
> > doing with it - it has some very nice features, including mergin all the
> JS
> > header contributions into a common (single) resource file.
> >
> > --
> > Jeremy Thomerson
> > http://www.wickettraining.com
> >
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Re: Best Practices for Using JavaScript With Wicket

2010-04-06 Thread Nishant Neeraj
Thanks Jeremy.

I had been using component.setMarkupId(..); which is not recommended... so I
was wondering what is the standard.
I need to get hands-on JS-Wicket integration, so I was looking for a good
organized documentation/resource (other than WIA).

> So, what's the objection to using it?

:) Nothing against wiQuery and I, probably, will go with wiQuery... I was
worried if I can integrate various the plug-ins available like jNice (
http://www.whitespace-creative.com/jquery/jNice/) and likes.

Thanks for pointers.
Nishant

On Tue, Apr 6, 2010 at 4:26 AM, Jeremy Thomerson
wrote:

> >
> > I am finding it very cumbersome to integrate JavaScript/JS-library. Can
> > someone point to (or probably write a blog-post on :->)  the best
> practices
> > of integrating JS/JS-library with Wicket.
> >
>
> Wicket is pretty flexible in that you can integrate your JS a dozen
> different ways.  jQuery is especially easy to integrate with because the
> programming model matches Wicket's fairly nicely.  The primary thing is
> that
> if you want to use element IDs to tie in to jQuery, you'll need to do this
> from behaviors in your java code so that you get the correct ID.
>
>
> >
> > I am using JQuery but I would like to know the best approach without
> using
> > WiQuery or jWicket. (Unless, I have to write my own jWicket to get this
> > done.)
> >
>
> I'm not sure I understand.  wiQuery has been fairly well recognized as a
> very nice Wicket/jQuery integration.  It has active development and a
> helpful mailing list.  So, what's the objection to using it?  I'm not
> saying
> that you can't have an objection, I just wonder what it is.  It's an open
> source project, so you can use it as a base and add your own functionality
> as needed (hopefully contributing back).
>
> Even if you don't want to use it, you can see some of the things they are
> doing with it - it has some very nice features, including mergin all the JS
> header contributions into a common (single) resource file.
>
> --
> Jeremy Thomerson
> http://www.wickettraining.com
>


Best Practices for Using JavaScript With Wicket

2010-04-05 Thread Nishant Neeraj
Hi,

I am working on an application that's very rich in UI. Most of the input
validation, unless it requires back-end support, are done at UI level. There
are drag-and-drop, multiple file uploader (not the one in wicket
extensions), and customized warning message (much like Stack-overflow's top
info-panel that slides-in the page) and Tiny-MCE etc.

I am finding it very cumbersome to integrate JavaScript/JS-library. Can
someone point to (or probably write a blog-post on :->)  the best practices
of integrating JS/JS-library with Wicket.

I am using JQuery but I would like to know the best approach without using
WiQuery or jWicket. (Unless, I have to write my own jWicket to get this
done.)

Thanks
Nishant


Re: Using SetResponsePage in Session

2010-03-13 Thread Nishant Neeraj
Right. Thanks.
So, I am doing this check in my custom base page (which is extended by all
others).
I am able to redirect user to "switch accounts" page.

My initial understanding was that Session.replaceSession() or
Session.invalidateNow() + Session.bind() will reset the current session and
hence all the objects in current session. but unfortunately, it does not.

Right now, I want to start a new session on an button onClick. I'm wondering
if it's possible.
Any clue?

Thanks
- Nishant

On Sun, Mar 14, 2010 at 1:37 AM, Edward Zarecor wrote:

> I would check if the user already exists in the session, but send the
> redirect from a Page.  You can refactor the redirection code into a base
> class and extend as required.
>
> Ed.
>
> On Mar 13, 2010 2:04 PM, "Nishant Neeraj" <
> nishant.has.a.quest...@gmail.com>
> wrote:
>
> The use case is like this.
>
> You have logged-in in a browser's tab and in another tab, you click on a
> moderate-comment mail that automatically logs you in as another user, and
> takes you to the comments-moderation page of the application.
>
> Now, at this point, I want to ask the user if he wants to switch account.
> [The way Google does if you are signing-in in two tabs as different users]
>
> So, instead of comment-moderation page, I want to take user to "Do want to
> switch account?" page (if another user is already logged-in in another
> tab).
> Depending on the users decision I will either invalidate the old session
> and
> log-in as new user or will just take the user to already logged in
> session's
> home page.
>
> The thing is, I wanted to do this all the time. Whenever I am calling
> MySession.get().setUser(UserVO uvo), I want to check if there already
> exists
> a different userVO in the same session. If so, the end user must be
> notified.
>
> Thanks
> Nishant
>
> On Sat, Mar 13, 2010 at 7:24 PM, Edward Zarecor  >wrote:
>
>
> > What's the use case? Session events won't always occur within the
> > context of a RequestCycle, s...
> > -
> > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > For additional commands, e-mail: users-h...@wicket.apache.org
> >
> >
>


Re: Using SetResponsePage in Session

2010-03-13 Thread Nishant Neeraj
The use case is like this.

You have logged-in in a browser's tab and in another tab, you click on a
moderate-comment mail that automatically logs you in as another user, and
takes you to the comments-moderation page of the application.

Now, at this point, I want to ask the user if he wants to switch account.
[The way Google does if you are signing-in in two tabs as different users]

So, instead of comment-moderation page, I want to take user to "Do want to
switch account?" page (if another user is already logged-in in another tab).
Depending on the users decision I will either invalidate the old session and
log-in as new user or will just take the user to already logged in session's
home page.

The thing is, I wanted to do this all the time. Whenever I am calling
MySession.get().setUser(UserVO uvo), I want to check if there already exists
a different userVO in the same session. If so, the end user must be
notified.

Thanks
Nishant

On Sat, Mar 13, 2010 at 7:24 PM, Edward Zarecor wrote:

> What's the use case?  Session events won't always occur within the
> context of a RequestCycle, say, expiry.
>
> Even If the use case is related to a request something like this might
> be cleaner:
>
> YourPage
>
>  if (getYourApp().getYourSession().isWhatever())
>   {
>  RequestCycle.get().setRedirect(true);
>  RequestCycle.get().setResponsePage(SomePage.class);
>   } else { 
>
> Ed.
>
> On Sat, Mar 13, 2010 at 7:06 AM, Nishant Neeraj
>  wrote:
> > Hi,
> >
> > In my custom session, I have a method which, on certain condition, wants
> to
> > redirect the request to some page, other than the original.
> > This is what I am doing, in the method:
> >
> > RequestCycle.get().setRedirect(true);
> > RequestCycle.get().setResponsePage(SomePage.class);
> >
> > But the response continues to land on the originally requested page
> > requested page.
> >
> > Is there any way to do this without invalidating the session?
> >
> > Thanks
> > Nishant
> >
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Using SetResponsePage in Session

2010-03-13 Thread Nishant Neeraj
Hi,

In my custom session, I have a method which, on certain condition, wants to
redirect the request to some page, other than the original.
This is what I am doing, in the method:

RequestCycle.get().setRedirect(true);
RequestCycle.get().setResponsePage(SomePage.class);

But the response continues to land on the originally requested page
requested page.

Is there any way to do this without invalidating the session?

Thanks
Nishant


Re: Wicket Session Management

2010-03-09 Thread Nishant Neeraj
Ok, I got the answer.

"Wicket tries to be as stateless as long as possible, I believe it takes
some hints from how your pages are built to know if it needs to keep a
Session around for longer than a Request." [1]

[1] http://basementcoders.com/?p=65&cpage=1

Thanks
Nishant

On Tue, Mar 9, 2010 at 11:53 PM, Nishant Neeraj <
nishant.has.a.quest...@gmail.com> wrote:

> Hi,
>
> I have a registration system where, when you request for registration, you
> are mailed a URL with unique-key as parameter. When user clicks the link, he
> lands on a page where I am setting his UserVO object in session. This page
> has another BookmarkablePageLink that points to the user's profile setup
> page.
>
> Now, when the user clicks the link to profile setup page, I find that
> session object has changed... there is no UserVO, plus session's hashCode
> and session toString() value is different from the one for the previous
> page.
>
> Can anyone provide a clue? Or is it possible for a request originating from
> one page can have different session?
>
> Thanks
> Nishant
>


Wicket Session Management

2010-03-09 Thread Nishant Neeraj
Hi,

I have a registration system where, when you request for registration, you
are mailed a URL with unique-key as parameter. When user clicks the link, he
lands on a page where I am setting his UserVO object in session. This page
has another BookmarkablePageLink that points to the user's profile setup
page.

Now, when the user clicks the link to profile setup page, I find that
session object has changed... there is no UserVO, plus session's hashCode
and session toString() value is different from the one for the previous
page.

Can anyone provide a clue? Or is it possible for a request originating from
one page can have different session?

Thanks
Nishant


UploadProgressBar and AjaxSubmitButton

2010-02-24 Thread Nishant Neeraj
Hi,

I am trying show UploadProgressBar while the form submission is done by
AjaxSubmitButton / Link. The problem is, I do not see progress bar when I
use AjaxSubmitButton (it works with regular form submission button).

I have set setRenderBodyOnly(false) for the progress bar and added it to
ajax target of the button.

In all cases file gets uploaded successfully.

Any pointer? Anything that I am missing here?

Regards,
Nishant


Re: URL Encoding strategy

2010-02-20 Thread Nishant Neeraj
Thanks Erik. I guess, I'll go with sevlet filter approach for now.

However, I'll be looking for your blog post. If possible, post the link to
the article in this thread when you're done.

Thanks again.
Nishant

On Sat, Feb 20, 2010 at 6:40 PM, Erik van Oosten wrote:

> Hi Nishant,
>
> This is tricky stuff.
>
> Here is some information:
> http://old.nabble.com/How-to-catch-unknown-%28not-mounted%29-URLs--td14949092.html
> Another approach is to do redirects from a servlet filter.
>
> If you have a couple of days of patience I'll have finished a blog article
> on it, with example code to make it a lot easier from within Wicket.
>
> Regards,
>Erik.
>
>
> Op 20-02-10 11:07, Nishant Neeraj wrote:
>
>> Hi,
>>
>> I wanted to apply URL encoding strategy to application context root but I
>> cant mount empty string because it throws exception at start-up.
>> Is there a work around to this?
>>
>> Regards
>> Nishant
>>
>>
>
> --
> Posted from my SMTP compliant software.
> Erik van Oosten
> http://www.day-to-day-stuff.blogspot.com/
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


URL Encoding strategy

2010-02-20 Thread Nishant Neeraj
Hi,

I wanted to apply URL encoding strategy to application context root but I
cant mount empty string because it throws exception at start-up.
Is there a work around to this?

Regards
Nishant