You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by hok <iv...@gmail.com> on 2011/01/16 17:04:48 UTC
Custom error 404 page and page id-s
Hello,
I've implemented the custom error 404 page solution from
http://www.mkyong.com/wicket/how-do-configure-404-error-page-in-wicket-solution/
http://www.mkyong.com/wicket/how-do-configure-404-error-page-in-wicket-solution/
. However, I noticed some strange behavior:
There is a home page with a modal window in it, so the page is not
stateless:
public class TestPage extends WebPage {
public TestPage() {
}
@Override
protected void onInitialize() {
super.onInitialize();
add(new ModalWindow("modal_window"));
}
}
The custom error page is stateless:
public class PageNotFound extends WebPage {
public PageNotFound() {
super();
}
public PageNotFound(IModel<?> model) {
super(model);
}
public PageNotFound(PageParameters parameters) {
super(parameters);
}
}
The application class is:
public class TestApplication extends WebApplication {
public TestApplication() {
}
@Override
protected void init() {
super.init();
ICompoundRequestMapper rootRequestMapper =
getRootRequestMapperAsCompound();
rootRequestMapper.add(new MountedMapper("/home", TestPage.class));
rootRequestMapper.add(new MountedMapper("/404", PageNotFound.class));
}
@Override
public Class<? extends Page> getHomePage() {
return TestPage.class;
}
}
... and the web.xml:
<filter>
<filter-name>wicket.WicketWarp</filter-name>
<filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
<init-param>
<param-name>applicationClassName</param-name>
<param-value>org.apache.wicket.TestApplication</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>wicket.WicketWarp</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
<error-page>
<error-code>404</error-code>
<location>/404</location>
</error-page>
Since the home page is not stateless the page id is displayed also. When:
rootRequestMapper.add(new MountedMapper("/404", PageNotFound.class));
is present in the TestApplication the id of the home page is incremented by
2 each time the page is displayed (home?0, home?2, home?4..). When the error
page mapping is commented the id is incremented by 1 (as expected). From I
was able to trace in the wicket code on each request for the home page, also
a request for the error 404 custom page is made and because of this the id
is incremented by 2. Is this a normal behavior? Thanks in advance.
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Custom-error-404-page-and-page-id-s-tp3220118p3220118.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Custom error 404 page and page id-s
Posted by hok <iv...@gmail.com>.
https://issues.apache.org/jira/browse/WICKET-3340
https://issues.apache.org/jira/browse/WICKET-3340
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Custom-error-404-page-and-page-id-s-tp3220118p3220259.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Custom error 404 page and page id-s
Posted by Martin Grigorov <mg...@apache.org>.
create a quickstart and attach it to jira
thanks
On Sun, Jan 16, 2011 at 6:46 PM, hok <iv...@gmail.com> wrote:
>
> Thanks for the fast response.
> I've tried to test it with a simple test page, containing one AjaxLink:
>
> public class TestPage extends WebPage {
>
> public TestPage() {
> }
>
> @Override
> protected void onInitialize() {
> super.onInitialize();
> add(new AjaxLink<Void>("link") {
>
> private static final long serialVersionUID =
> 1135836169949178116L;
>
> @Override
> public void onClick(AjaxRequestTarget target) {
> target.appendJavascript("alert('test')");
> }
> });
> }
> }
>
> In this scenario the ajax link is working fine, but in chrome 9 the id's
> are
> always incremented with 2, while in firefox 3.6 it's a bit strange - on the
> first reload the id is incremented with 3, on the second time with 4 and
> after this on every reload the id is incremented by 1 (this is a repeated
> pattern that happens every time).
>
> I've also tried with the same page, but this time containing only a Form
> (stateful):
>
> public class TestPage extends WebPage {
>
> public TestPage() {
> }
>
> @Override
> protected void onInitialize() {
> super.onInitialize();
> add(new Form<Void>("form"));
> }
> }
>
> The result with both pages is the same, the second page doesn't have any
> links. Can those page-not-found requests that lead to the incrementing ids
> lead to a slower page load time and increased load on the server? Thanks.
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Custom-error-404-page-and-page-id-s-tp3220118p3220233.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: Custom error 404 page and page id-s
Posted by hok <iv...@gmail.com>.
Thanks for the fast response.
I've tried to test it with a simple test page, containing one AjaxLink:
public class TestPage extends WebPage {
public TestPage() {
}
@Override
protected void onInitialize() {
super.onInitialize();
add(new AjaxLink<Void>("link") {
private static final long serialVersionUID =
1135836169949178116L;
@Override
public void onClick(AjaxRequestTarget target) {
target.appendJavascript("alert('test')");
}
});
}
}
In this scenario the ajax link is working fine, but in chrome 9 the id's are
always incremented with 2, while in firefox 3.6 it's a bit strange - on the
first reload the id is incremented with 3, on the second time with 4 and
after this on every reload the id is incremented by 1 (this is a repeated
pattern that happens every time).
I've also tried with the same page, but this time containing only a Form
(stateful):
public class TestPage extends WebPage {
public TestPage() {
}
@Override
protected void onInitialize() {
super.onInitialize();
add(new Form<Void>("form"));
}
}
The result with both pages is the same, the second page doesn't have any
links. Can those page-not-found requests that lead to the incrementing ids
lead to a slower page load time and increased load on the server? Thanks.
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Custom-error-404-page-and-page-id-s-tp3220118p3220233.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Custom error 404 page and page id-s
Posted by Martin Grigorov <mg...@apache.org>.
Hi,
I guess you have some broken link in your page.
This link makes request to the server, WicketFilter ignores it, then the web
container tries to handle it but again there is nothing to serve and finally
uses /404 for this resource, and here Wicket handles it and increments the
counter.
Put a breakpoint in WicketFilter#process() and see the url for this
broken/missing resource.
See below some comments
On Sun, Jan 16, 2011 at 5:04 PM, hok <iv...@gmail.com> wrote:
>
> Hello,
> I've implemented the custom error 404 page solution from
>
> http://www.mkyong.com/wicket/how-do-configure-404-error-page-in-wicket-solution/
>
> http://www.mkyong.com/wicket/how-do-configure-404-error-page-in-wicket-solution/
> . However, I noticed some strange behavior:
>
> There is a home page with a modal window in it, so the page is not
> stateless:
>
> public class TestPage extends WebPage {
>
> public TestPage() {
> }
>
> @Override
> protected void onInitialize() {
> super.onInitialize();
>
> add(new ModalWindow("modal_window"));
> }
> }
>
>
> The custom error page is stateless:
>
> public class PageNotFound extends WebPage {
>
> public PageNotFound() {
> super();
> }
>
> public PageNotFound(IModel<?> model) {
> super(model);
> }
>
> public PageNotFound(PageParameters parameters) {
> super(parameters);
> }
> }
>
>
> The application class is:
>
> public class TestApplication extends WebApplication {
> public TestApplication() {
> }
>
> @Override
> protected void init() {
> super.init();
>
> ICompoundRequestMapper rootRequestMapper =
> getRootRequestMapperAsCompound();
> rootRequestMapper.add(new MountedMapper("/home",
> TestPage.class));
> rootRequestMapper.add(new MountedMapper("/404",
> PageNotFound.class));
>
you can use the shortcuts: mountPage("/home", TestPage.class);
> }
>
> @Override
> public Class<? extends Page> getHomePage() {
> return TestPage.class;
> }
> }
>
> ... and the web.xml:
>
> <filter>
> <filter-name>wicket.WicketWarp</filter-name>
>
> <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
> <init-param>
> <param-name>applicationClassName</param-name>
>
> <param-value>org.apache.wicket.TestApplication</param-value>
> </init-param>
> </filter>
>
> <filter-mapping>
> <filter-name>wicket.WicketWarp</filter-name>
> <url-pattern>/*</url-pattern>
> <dispatcher>REQUEST</dispatcher>
> <dispatcher>ERROR</dispatcher>
> </filter-mapping>
>
> <error-page>
> <error-code>404</error-code>
> <location>/404</location>
> </error-page>
>
> Since the home page is not stateless the page id is displayed also. When:
>
> rootRequestMapper.add(new MountedMapper("/404",
> PageNotFound.class));
>
> is present in the TestApplication the id of the home page is incremented by
> 2 each time the page is displayed (home?0, home?2, home?4..). When the
> error
> page mapping is commented the id is incremented by 1 (as expected). From I
> was able to trace in the wicket code on each request for the home page,
> also
> a request for the error 404 custom page is made and because of this the id
> is incremented by 2. Is this a normal behavior? Thanks in advance.
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Custom-error-404-page-and-page-id-s-tp3220118p3220118.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>