Re: WicketFilter

2009-08-30 Thread Uwe Schäfer

Igor Vaynberg schrieb:

map WicketSessionFilter in front of those servlets, you will get both
Session.get() and Session.get().getApplication(), and
Application.get()


awesome. i was not aware of this.
thanks Igor.

cu uwe

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



Re: requestParameters and %20

2009-08-30 Thread James Carman
Why would they need to write something for it when there is something in the
Java language for it?

On Sun, Aug 30, 2009 at 12:43 AM, Fernando Wermus fernando.wer...@gmail.com
 wrote:

 I thought that wicket may have some class for this situation isnt true?

 On Sat, Aug 29, 2009 at 10:45 PM, James Carman 
 jcar...@carmanconsulting.com
  wrote:

  have you tried java.net.URLDecoder?
 
  On Sat, Aug 29, 2009 at 3:43 PM, Fernando Wermus
  fernando.wer...@gmail.comwrote:
 
   I am serving a file from disk which its name is red apple.jpg.
   From html source it renders as follows
  
   img src=a/b/c/d/red apple.jpg /
  
   I found that On method getUri() and a variable into requestParameters
 the
   image name has been translated to red%20apple.jpg
  
   new URIRequestTargetUrlCodingStrategy(/ + thumbnail) {
  
   @Override public IRequestTarget decode(RequestParameters
  requestParameters)
   {
  
   try {
  
   return serveImage(getURI(requestParameters), );
  
   } catch (Exception e) {
  
   throw new WicketRuntimeException(e);
  
   }
  
   }
  
   };
  
  
   Which is the best way to manage this situation?
  
  
   Do I have just implement a method from my own converting %20 or there
 is
  a
   wicket way to do this job?
  
  
   I am using wicket 1.3.6
  
   thanks in advance
  
   --
   Fernando Wermus.
  
   www.linkedin.com/in/fernandowermus
  
 



 --
 Fernando Wermus.

 www.linkedin.com/in/fernandowermus



Sign In and returning page

2009-08-30 Thread uud ashr
Hi all,
Need help here, another wicket question.

The case is I have User Panel on all pages in my website. User Panel
contains SignIn link (if user not logged in yet), SignOut link and label of
the logged user (if the user has logged in).

Solution 1.
On SignIn link, I'm using redirectToInterceptPage(new SignInPage()) so when
sign in succeed I can call continueToOriginalDestination() so I can go to
the previous page (the returning page). I don't know this is the best
solution or not, but it's works fine until I found that SignIn link
component work using session and when session timeout the link won't work
anymore. So it only work if it was fresh page.

Solution 2
I need (maybe) to get referer url. Is there anyway to get referer url?

Or is the other solution?
Help would be appreciate.


Thanks guys,
uudashr


Re: Sign In and returning page

2009-08-30 Thread Major Péter

Hi,

Solution 1.:
you could try throw new RestartResponseAtInterceptPageException(new 
SignInPage()), maybe it's working without session (I guess it won't)


Solution 2.:
You could create a constructor which will accept a Page as a parameter, 
so you can do such thing:

throw new RestartResponseException(new SignInPage(this));
and use that parameter when the login was successful.

Regards,
Peter

uud ashr írta:

Hi all,
Need help here, another wicket question.

The case is I have User Panel on all pages in my website. User Panel
contains SignIn link (if user not logged in yet), SignOut link and label of
the logged user (if the user has logged in).

Solution 1.
On SignIn link, I'm using redirectToInterceptPage(new SignInPage()) so when
sign in succeed I can call continueToOriginalDestination() so I can go to
the previous page (the returning page). I don't know this is the best
solution or not, but it's works fine until I found that SignIn link
component work using session and when session timeout the link won't work
anymore. So it only work if it was fresh page.

Solution 2
I need (maybe) to get referer url. Is there anyway to get referer url?

Or is the other solution?
Help would be appreciate.


Thanks guys,
uudashr
  


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



Re: WicketFilter

2009-08-30 Thread Igor Vaynberg
even though it is session specific it still sets application threadlocal.

-igor

2009/8/30 Uwe Schäfer u...@thomas-daily.de:
 Igor Vaynberg schrieb:

 map WicketSessionFilter in front of those servlets, you will get both
 Session.get() and Session.get().getApplication(), and
 Application.get()

 actually, (as the name implies), this is quite session centric. my current
 use case is web services where i don´t have a session.

 subclassing WicketFilter is not too easy as well, because it does not reveal
 the application reference (private, no getter).

 this makes me do nasty reflection tricks to get it, which - while it works -
 feels even much more dirty than using the singleton approach to get an
 application reference.

 any idea, how this could be done with a cleaner approach?
 or would
 WicketFilter: protected WebApplication getApplication()
 be an alternative?

 cu uwe

 --- current nasty impl:

 �...@override
    public void doFilter(final ServletRequest request, final ServletResponse
 response, final FilterChain chain)
            throws IOException, ServletException    {
        super.doFilter(request, response, new ModifiedChain(chain,
 getApplication()));
    }

    private Application getApplication()    {
        // very very nasty
        return (Application) getFieldValue(this, webApplication);
    }

    public static Object getFieldValue(final Object obj, final String string)
    {
        // did i say nasty?
        try        {
            final Field declaredField =
 obj.getClass().getSuperclass().getDeclaredField(string);
            declaredField.setAccessible(true);
            return declaredField.get(obj);
        }
        catch (final Throwable e)        {
            throw new RuntimeException(e);
        }
    }
 }

 class ModifiedChain implements FilterChain
 {
    private FilterChain orgChain;
    private final Application application;

    public ModifiedChain(final FilterChain chain, final Application
 application)    {
        this.orgChain = chain;
        this.application = application;
    }

    public void doFilter(final ServletRequest request, final ServletResponse
 response) throws IOException,
            ServletException    {
        Application.set(this.application);
        try        {
            this.orgChain.doFilter(request, response);
        }
        finally        {
            Application.unset();
        }
    }

 }

 -
 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: WicketFilter

2009-08-30 Thread Uwe Schäfer

Igor Vaynberg schrieb:

even though it is session specific it still sets application threadlocal.


does not work, and does not look like it would:

public void doFilter(ServletRequest request, ServletResponse response, 
FilterChain chain)

throws IOException, ServletException
{
 HttpServletRequest httpServletRequest = ((HttpServletRequest)request);
 HttpSession httpSession = httpServletRequest.getSession(false);
 if (httpSession != null)
 {
   ... // sorry, dont have one
 }
 else
 {
  log.debug(could not set Wicket session: no http session was created 
yet for {},{}, httpServletRequest.getContextPath(), 
httpServletRequest.getServerName());

 }

 try
 {
// go on with processing
chain.doFilter(request, response);
 }
 finally
 {
  Session.unset(); // was not set before in this case?
 }
}


what am i missing ?

cu uwe

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



Re: Sign In and returning page

2009-08-30 Thread uud ashr
Forget everything I say :-D and look code below:

For example:

*SomePage:*
add(new Link(signInLink) {
void onClick() {
redirectToInterceptPage(new SignInPage());
}
});

*SignInPage:*
add(new SignInForm(signInForm) {
void onSubmit() {
...
continueToOriginalPage();
}
});

Above is fine and all works, but when you leave the page to long then the
signInLink cannot be click anymore, they said page is expired. Actually I
was wrong about the session thing, the page expired because of I just
restart the server. So actually no problem even we leave the page in a long
time except we restart the server.


*Other solution*
Then I was thinking to use mount a path signIn to a SignInPage.class and
to do that I need to use BookmarkablePageLink. Even we restart the server,
the link should wor

*SomePage:*
add(new BookmarkablePageLink(signInLink, SignInPage.class));

but there is no way I can invoke redirectToInterceptPage or throw new
RestartResponseAtInterceptPageException(new SignInPage(this)) ? where should
I put those code?


Regards,
uudashr

2009/8/30 Major Péter majorpe...@sch.bme.hu

 Hi,

 Solution 1.:
 you could try throw new RestartResponseAtInterceptPageException(new
 SignInPage()), maybe it's working without session (I guess it won't)

 Solution 2.:
 You could create a constructor which will accept a Page as a parameter, so
 you can do such thing:
 throw new RestartResponseException(new SignInPage(this));
 and use that parameter when the login was successful.

 Regards,
 Peter

 uud ashr írta:

  Hi all,
 Need help here, another wicket question.

 The case is I have User Panel on all pages in my website. User Panel
 contains SignIn link (if user not logged in yet), SignOut link and label
 of
 the logged user (if the user has logged in).

 Solution 1.
 On SignIn link, I'm using redirectToInterceptPage(new SignInPage()) so
 when
 sign in succeed I can call continueToOriginalDestination() so I can go to
 the previous page (the returning page). I don't know this is the best
 solution or not, but it's works fine until I found that SignIn link
 component work using session and when session timeout the link won't work
 anymore. So it only work if it was fresh page.

 Solution 2
 I need (maybe) to get referer url. Is there anyway to get referer url?

 Or is the other solution?
 Help would be appreciate.


 Thanks guys,
 uudashr



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




How to tackle Ajax Flooding

2009-08-30 Thread Tom Wollert
Hello there,

I have a problem with my Wicket Application, which is quite Ajax heavy.
Certain ajax calls take some time as they start an import, however the
button can still be clicked and sends another ajax call (which is delayed
for quite some time). Is it possible to disable the button while the request
cycle is not complete? (I mean with wicket, or do I need to use
Javascript?). Also ajax calls are postponed as long as the channel is busy,
is it possible to deactivate this behaviour? And are there reasons why I
should not?


Re: How to tackle Ajax Flooding

2009-08-30 Thread Igor Vaynberg
you can use an ajax call decorator to disable the button via
javascript when it is clicked.

-igor

On Sun, Aug 30, 2009 at 2:55 PM, Tom Wollerttom.woll...@googlemail.com wrote:
 Hello there,

 I have a problem with my Wicket Application, which is quite Ajax heavy.
 Certain ajax calls take some time as they start an import, however the
 button can still be clicked and sends another ajax call (which is delayed
 for quite some time). Is it possible to disable the button while the request
 cycle is not complete? (I mean with wicket, or do I need to use
 Javascript?). Also ajax calls are postponed as long as the channel is busy,
 is it possible to deactivate this behaviour? And are there reasons why I
 should not?


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