Re: Unnecessary 302 redirects in Wicket 1.5

2012-06-25 Thread sylvain
Hi, 
In order to avoid redirect, we add this code in our application class :


setPageRendererProvider(new IPageRendererProvider() {   
@Override
public PageRenderer get(final RenderPageRequestHandler 
context) {
return new WebPageRenderer(context){
@Override
protected RedirectPolicy 
getRedirectPolicy() {
RedirectPolicy result;
if (!((WebRequest) 
RequestCycle.get().getRequest()).isAjax()) {
result = 
RedirectPolicy.NEVER_REDIRECT;
} else {
result = 
super.getRedirectPolicy();
}
return result;
}
};  
}
})

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Unnecessary-302-redirects-in-Wicket-1-5-tp3921623p4650219.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: Unnecessary 302 redirects in Wicket 1.5

2012-02-05 Thread TH Lim
This worked. It didn't do a POST/REDIRECT/GET when I posted from Javascript
and/or HTML Form. This solution works great because, as you mentioned, I can
use  @SpringBean and other Wicket features along side with it. Thanks.

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Unnecessary-302-redirects-in-Wicket-1-5-tp3921623p4360263.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: Unnecessary 302 redirects in Wicket 1.5

2012-02-03 Thread TH Lim
import org.apache.wicket.MarkupContainer;
import org.apache.wicket.markup.IMarkupCacheKeyProvider;
import org.apache.wicket.markup.IMarkupResourceStreamProvider;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.request.http.WebResponse;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.util.resource.IResourceStream;
import org.apache.wicket.util.resource.StringResourceStream;

public class AppLogin extends WebPage implements IMarkupCacheKeyProvider,
IMarkupResourceStreamProvider
{
public AppLogin(PageParameters params) {
setStatelessHint(true);
startAsyncProcss(params);
}

private void startAsyncProcss(PageParameters params)
{
// start asynchronous process with POSTed param
}

@Override
public String getCacheKey(MarkupContainer components, Class? aClass)
{
return null;
}

@Override
public IResourceStream getMarkupResourceStream(MarkupContainer
components, Class? aClass)
{
return new StringResourceStream(?xml version=\1.0\?ok /);
}

@Override
protected void configureResponse(WebResponse response)
{
super.configureResponse(response);
response.setContentType(text/xml);
}
}

Thanks. 

http://apache-wicket.1842946.n4.nabble.com/file/n4354074/p-r-g.png 



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Unnecessary-302-redirects-in-Wicket-1-5-tp3921623p4354074.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: Unnecessary 302 redirects in Wicket 1.5

2012-02-03 Thread Martin Grigorov
There is no code related to redirections below.

On Fri, Feb 3, 2012 at 11:06 AM, TH Lim ssh...@gmail.com wrote:
 import org.apache.wicket.MarkupContainer;
 import org.apache.wicket.markup.IMarkupCacheKeyProvider;
 import org.apache.wicket.markup.IMarkupResourceStreamProvider;
 import org.apache.wicket.markup.html.WebPage;
 import org.apache.wicket.request.http.WebResponse;
 import org.apache.wicket.request.mapper.parameter.PageParameters;
 import org.apache.wicket.util.resource.IResourceStream;
 import org.apache.wicket.util.resource.StringResourceStream;

 public class AppLogin extends WebPage implements IMarkupCacheKeyProvider,
 IMarkupResourceStreamProvider
 {
    public AppLogin(PageParameters params) {
        setStatelessHint(true);
        startAsyncProcss(params);
    }

    private void startAsyncProcss(PageParameters params)
    {
        // start asynchronous process with POSTed param
    }

    @Override
    public String getCacheKey(MarkupContainer components, Class? aClass)
    {
        return null;
    }

    @Override
    public IResourceStream getMarkupResourceStream(MarkupContainer
 components, Class? aClass)
    {
        return new StringResourceStream(?xml version=\1.0\?ok /);
    }

    @Override
    protected void configureResponse(WebResponse response)
    {
        super.configureResponse(response);
        response.setContentType(text/xml);
    }
 }

 Thanks.

 http://apache-wicket.1842946.n4.nabble.com/file/n4354074/p-r-g.png



 --
 View this message in context: 
 http://apache-wicket.1842946.n4.nabble.com/Unnecessary-302-redirects-in-Wicket-1-5-tp3921623p4354074.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




-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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



Re: Unnecessary 302 redirects in Wicket 1.5

2012-02-03 Thread TH Lim
The original constructor was

public class AppLogin extends WebPage implements IMarkupCacheKeyProvider,
IMarkupResourceStreamProvider 
 { 
public AppLogin(PageParameters params) { 
setStatelessHint(true); 
startAsyncProcss(params);  
*  throw new RestartResponseException(new PageProvider(getClass(), params),
RenderPageRequestHandler.RedirectPolicy.NEVER_REDIRECT);
*}

The additional code, in bold, caused stackoverflow exception. This page
would be invoked by JavaScript call.


--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Unnecessary-302-redirects-in-Wicket-1-5-tp3921623p4354166.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: Unnecessary 302 redirects in Wicket 1.5

2012-02-03 Thread Martin Grigorov
On Fri, Feb 3, 2012 at 12:05 PM, TH Lim ssh...@gmail.com wrote:
 The original constructor was

 public class AppLogin extends WebPage implements IMarkupCacheKeyProvider,
 IMarkupResourceStreamProvider
  {
    public AppLogin(PageParameters params) {
        setStatelessHint(true);
        startAsyncProcss(params);
 *  throw new RestartResponseException(new PageProvider(getClass(), params),
            RenderPageRequestHandler.RedirectPolicy.NEVER_REDIRECT);

This is wrong as you already found.
You need to use this code to come to this page.
I.e. from the previous page instead of using
setResponsePage(AppLogin.class) use the exception.

 *    }

 The additional code, in bold, caused stackoverflow exception. This page
 would be invoked by JavaScript call.


 --
 View this message in context: 
 http://apache-wicket.1842946.n4.nabble.com/Unnecessary-302-redirects-in-Wicket-1-5-tp3921623p4354166.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




-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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



Re: Unnecessary 302 redirects in Wicket 1.5

2012-02-03 Thread TH Lim
I tried and observed the PRG behavior as before. Even if it had worked, for
every page I need to an additional transfer page. I don't think this is a
good solution.

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Unnecessary-302-redirects-in-Wicket-1-5-tp3921623p4354302.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: Unnecessary 302 redirects in Wicket 1.5

2012-02-03 Thread TH Lim
Thanks for your help so far. It would be great if you could pass me some
hints to allow me to do some research on my own. Thanks

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Unnecessary-302-redirects-in-Wicket-1-5-tp3921623p4354785.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: Unnecessary 302 redirects in Wicket 1.5

2012-02-03 Thread Martin Grigorov
Please start over with your problem. What do you want to achieve? What
did you try? What problems did you face ?
And I'm not sure what is PRG.

On Fri, Feb 3, 2012 at 4:47 PM, TH Lim ssh...@gmail.com wrote:
 Thanks for your help so far. It would be great if you could pass me some
 hints to allow me to do some research on my own. Thanks

 --
 View this message in context: 
 http://apache-wicket.1842946.n4.nabble.com/Unnecessary-302-redirects-in-Wicket-1-5-tp3921623p4354785.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




-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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



Re: Unnecessary 302 redirects in Wicket 1.5

2012-02-03 Thread TH Lim
What I want is a very simple end point to service a POST request originated
from my JS using AJAX. What I was expecting was to do a POST and returned an
acknowledgement as response. What happened was, after the  POST request, the
browser received a HTTP 302 to redirect the browser to GET the final
response. I can see these states using the browser debugging tool. How do I
set this page to do what I was expecting?  thanks


P-R-G,  http://en.wikipedia.org/wiki/Post/Redirect/Get Post/Redirect/Get 

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Unnecessary-302-redirects-in-Wicket-1-5-tp3921623p4354872.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: Unnecessary 302 redirects in Wicket 1.5

2012-02-03 Thread Martin Grigorov
For this you don't need Wicket Page at all. Just use a normal Servlet,
fire a POST request to its URL and return whatever response you need.

On Fri, Feb 3, 2012 at 5:19 PM, TH Lim ssh...@gmail.com wrote:
 What I want is a very simple end point to service a POST request originated
 from my JS using AJAX. What I was expecting was to do a POST and returned an
 acknowledgement as response. What happened was, after the  POST request, the
 browser received a HTTP 302 to redirect the browser to GET the final
 response. I can see these states using the browser debugging tool. How do I
 set this page to do what I was expecting?  thanks


 P-R-G,  http://en.wikipedia.org/wiki/Post/Redirect/Get Post/Redirect/Get

 --
 View this message in context: 
 http://apache-wicket.1842946.n4.nabble.com/Unnecessary-302-redirects-in-Wicket-1-5-tp3921623p4354872.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




-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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



Re: Unnecessary 302 redirects in Wicket 1.5

2012-02-03 Thread TH Lim
I could use a servlet. I thought I could easily setup a Wicket page to do
something similar. Since I have @SpringBean ready to load services and DAOs.
I was almost there. Just that I couldn't get the NEVER_REDIRECT directive
work on a per page basis instead of global. 


--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Unnecessary-302-redirects-in-Wicket-1-5-tp3921623p4355044.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: Unnecessary 302 redirects in Wicket 1.5

2012-02-03 Thread Serban.Balamaci
Hi Lim,
What about using an AbstractResource instead for serving the xml.

You can do something like:
@Override
protected ResourceResponse newResourceResponse(Attributes attributes) {
final ResourceResponse response = new ResourceResponse();

PageParameters requestParams = attributes.getParameters();
response.setLastModified(Time.now());
response.disableCaching();
response.setContentType(text/xml);
response.setTextEncoding(UTF-8);

response.setWriteCallback(new WriteCallback() {
@Override
public void writeData(final Attributes attributes) {
attributes.getResponse().write(xml..);
}
});

response.setContentDisposition(ContentDisposition.INLINE);
return response.
 }

And you have all the benefits wicket like @SpringBean available, access to
wicket session, etc.

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Unnecessary-302-redirects-in-Wicket-1-5-tp3921623p4355660.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: Unnecessary 302 redirects in Wicket 1.5

2012-02-02 Thread TH Lim
Is it possible to set the redirect feature localized to a page instead of
every page? There are 2 out 10 pages I don't want to redirect. Thanks

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Unnecessary-302-redirects-in-Wicket-1-5-tp3921623p4351160.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: Unnecessary 302 redirects in Wicket 1.5

2012-02-02 Thread Martin Grigorov
On Thu, Feb 2, 2012 at 1:27 PM, TH Lim ssh...@gmail.com wrote:
 Is it possible to set the redirect feature localized to a page instead of
 every page? There are 2 out 10 pages I don't want to redirect. Thanks

Experiment with new RestartResponseException(new
PageProvider(YourPage.class, PageParameters),
RedirectPolicy.NEVER_REDIRECT)


 --
 View this message in context: 
 http://apache-wicket.1842946.n4.nabble.com/Unnecessary-302-redirects-in-Wicket-1-5-tp3921623p4351160.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




-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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



Re: Unnecessary 302 redirects in Wicket 1.5

2012-02-02 Thread TH Lim
I have compilation error with this statement. Any help here would be great.
And I suppose I put this line of code at the end of my web page constructor,
right?


Martin Grigorov-4 wrote
 
 On Thu, Feb 2, 2012 at 1:27 PM, TH Lim lt;sshark@gt; wrote:
 Is it possible to set the redirect feature localized to a page instead of
 every page? There are 2 out 10 pages I don't want to redirect. Thanks
 
 Experiment with new RestartResponseException(new
 PageProvider(YourPage.class, PageParameters),
 RedirectPolicy.NEVER_REDIRECT)
 




--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Unnecessary-302-redirects-in-Wicket-1-5-tp3921623p4353522.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: Unnecessary 302 redirects in Wicket 1.5

2012-02-02 Thread TH Lim
The compilation error was my fault. I tried and it didn't work. Probably I
missed something. What I did was throw the RestartResponseException at the
end of the said page and StackOverflowException was thrown, quite obvious to
me what has happened. With my limited knowledge of Wicket internal working
mechanism, I think RestartResponseException was not the right solution. What
I understood was a page accepted a request, redirected the request to a page
targeted by the exception. it basically worked like P-R-G.

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Unnecessary-302-redirects-in-Wicket-1-5-tp3921623p4353854.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: Unnecessary 302 redirects in Wicket 1.5

2012-02-02 Thread Martin Grigorov
Can you share your code so we can take a look and help you ?

On Fri, Feb 3, 2012 at 9:04 AM, TH Lim ssh...@gmail.com wrote:
 The compilation error was my fault. I tried and it didn't work. Probably I
 missed something. What I did was throw the RestartResponseException at the
 end of the said page and StackOverflowException was thrown, quite obvious to
 me what has happened. With my limited knowledge of Wicket internal working
 mechanism, I think RestartResponseException was not the right solution. What
 I understood was a page accepted a request, redirected the request to a page
 targeted by the exception. it basically worked like P-R-G.

 --
 View this message in context: 
 http://apache-wicket.1842946.n4.nabble.com/Unnecessary-302-redirects-in-Wicket-1-5-tp3921623p4353854.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




-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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



Unnecessary 302 redirects in Wicket 1.5

2011-10-20 Thread Илья Нарыжный
Hello,

Could you please explain for what reason wicket for every page redirects
users to some other page by 302 code?
For example from /home user will be redirected to /home?1 etc.
It seems quite strange and I think, that this is much more strange for
Search Engines.
I found solution how to optimize for SE here:
http://apache-wicket.1842946.n4.nabble.com/Removing-jsessionid-in-wicket-1-5-td3891735.html
But it looks strange even for common users. Can I disable this feature for
common users?

P.S. I found some mentions that this is because page is not stateless. But
it's not so reasonable for me, because:
1) In wicket 1.4 all works great without this feature
2) Other web frameworks, which I know, don't use 302 code and everthing is
working
For me it looks as a bug.

Thanks,

Ilia


Re: Unnecessary 302 redirects in Wicket 1.5

2011-10-20 Thread Deniz Oğuz
I think redirect is performed as a solution to double post problem. You can
disable it from RequestCycleSetting by setting it to One Pass Render.

On Thu, Oct 20, 2011 at 1:53 PM, Илья Нарыжный phan...@ydn.ru wrote:

 Hello,

 Could you please explain for what reason wicket for every page redirects
 users to some other page by 302 code?
 For example from /home user will be redirected to /home?1 etc.
 It seems quite strange and I think, that this is much more strange for
 Search Engines.
 I found solution how to optimize for SE here:

 http://apache-wicket.1842946.n4.nabble.com/Removing-jsessionid-in-wicket-1-5-td3891735.html
 But it looks strange even for common users. Can I disable this feature
 for
 common users?

 P.S. I found some mentions that this is because page is not stateless. But
 it's not so reasonable for me, because:
 1) In wicket 1.4 all works great without this feature
 2) Other web frameworks, which I know, don't use 302 code and everthing is
 working
 For me it looks as a bug.

 Thanks,

 Ilia



Re: Unnecessary 302 redirects in Wicket 1.5

2011-10-20 Thread Martin Grigorov
Another problem is that without ?3 if your user reloads the page (F5)
Wicket wont know which page instance to re-render and will create a
new instance of the page. I.e. the state will be lost.
In Wicket 1.4 ?wicket:interface=0:0:bla:1: is used to keep the page id.

If you don't want this special parameter then you should keep the page
stateless. I.e. everytime a new instance will be created and no state
is preserved.

On Thu, Oct 20, 2011 at 3:07 PM, Deniz Oğuz denizo...@gmail.com wrote:
 I think redirect is performed as a solution to double post problem. You can
 disable it from RequestCycleSetting by setting it to One Pass Render.

 On Thu, Oct 20, 2011 at 1:53 PM, Илья Нарыжный phan...@ydn.ru wrote:

 Hello,

 Could you please explain for what reason wicket for every page redirects
 users to some other page by 302 code?
 For example from /home user will be redirected to /home?1 etc.
 It seems quite strange and I think, that this is much more strange for
 Search Engines.
 I found solution how to optimize for SE here:

 http://apache-wicket.1842946.n4.nabble.com/Removing-jsessionid-in-wicket-1-5-td3891735.html
 But it looks strange even for common users. Can I disable this feature
 for
 common users?

 P.S. I found some mentions that this is because page is not stateless. But
 it's not so reasonable for me, because:
 1) In wicket 1.4 all works great without this feature
 2) Other web frameworks, which I know, don't use 302 code and everthing is
 working
 For me it looks as a bug.

 Thanks,

 Ilia





-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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