You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Dima Rzhevskiy <di...@rzhevskiy.info> on 2009/09/11 17:14:15 UTC
RequestCycle().urlFor not work
Hi !
I create simple page X1 with AjaxLink :
..
new AjaxLink("message"){
@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
CharSequence url =
getRequestCycle().urlFor(X1.class, new PageParameters());
String url2=
RequestUtils.toAbsolutePath(url.toString());
LOG.info("url="+url);
LOG.info("url2="+url2);
}
}
...
if I mount page to first level directory , for example "/x1.html"
result is correct:
url=x1.html
url2=http://localhost:8080/ctx/x1.html
if I mount page to second level directory "/x1/x2.html" result incorrect
url=../x1/x2.html
url2=http://localhost:8080/x1/x2.html
if i mount ti third level directory "/x1/x2/x3.html"
url=../../x1/x2/x3.html
url2=http://x1/x2/x3.html
Is this bug or I use API incorrectly ?
--
Rzhevskiy Dmitry
Re: RequestCycle().urlFor not work
Posted by Dima Rzhevskiy <di...@rzhevskiy.info>.
I use wicket 1.4.1, and I want send e-mail's notifications to users.
I create problem code as simple as possible: only with AjaxLink
Users of my site send internal messages. Messages will be composed in
ModalWindow. Inside AjaxButton.onSumbit method e-mail notification sent.
(Long way to carry absoluteUrl through container hierarchy).
--
Rzhevskiy Dmitry
2009/9/12 Johan Compagner <jc...@gmail.com>
> Which version of wicket do you use?
>
> Why do you need absoluut urls?
>
> On 11/09/2009, Dima Rzhevskiy <di...@rzhevskiy.info> wrote:
> > Sorry, yes, urlFor return correct result.
> > toAbsolutePath(final String relativePagePath) do not return result what I
> > expected.
> > javadoc copy/pasted from toAbsolutePath(final String requestPath, String
> > relativePagePath)...
> >
> > I undestand that it is nessesary to use toAbsolutePath(final String
> > requestPath, String relativePagePath) where requestPath nessesaty take in
> > constructor:
> >
> > public class X1 extends WebPage {
> >
> > private static final Logger LOG = LoggerFactory.getLogger(X1.class);
> >
> > public X1(final PageParameters parameters) {
> >
> > CharSequence url = getRequestCycle().urlFor(getClass().class,
> new
> > PageParameters());
> > final String outerUrl2=
> > RequestUtils.toAbsolutePath(url.toString()); //get
> > add(new AjaxLink("message"){
> > @Override
> > public void onClick(AjaxRequestTarget ajaxRequestTarget) {
> > CharSequence url =
> > getRequestCycle().urlFor(X1.class, new PageParameters());
> > String url2=
> > RequestUtils.toAbsolutePath(outerUrl2, url.toString());
> > LOG.info("url="+url);
> > LOG.info("url2="+url2);
> > }
> > });
> >
> > }
> > }
> >
> >
> > But this code look ugly..
> > Is better way of obtaining absolute url exists ?
> >
> > --
> > Rzhevskiy Dmitry
> >
> >
> > 2009/9/11 Jeremy Thomerson <je...@wickettraining.com>
> >
> >> what is incorrect about those URLs? they are relative - relative to the
> >> path you are on.
> >>
> >> --
> >> Jeremy Thomerson
> >> http://www.wickettraining.com
> >>
> >>
> >>
> >> On Fri, Sep 11, 2009 at 10:14 AM, Dima Rzhevskiy <dima@rzhevskiy.info
> >> >wrote:
> >>
> >> > Hi !
> >> >
> >> > I create simple page X1 with AjaxLink :
> >> > ..
> >> > new AjaxLink("message"){
> >> > @Override
> >> > public void onClick(AjaxRequestTarget ajaxRequestTarget) {
> >> > CharSequence url =
> >> > getRequestCycle().urlFor(X1.class, new PageParameters());
> >> > String url2=
> >> > RequestUtils.toAbsolutePath(url.toString());
> >> > LOG.info("url="+url);
> >> > LOG.info("url2="+url2);
> >> > }
> >> > }
> >> > ...
> >> > if I mount page to first level directory , for example "/x1.html"
> >> > result is correct:
> >> > url=x1.html
> >> > url2=http://localhost:8080/ctx/x1.html
> >> >
> >> > if I mount page to second level directory "/x1/x2.html" result
> incorrect
> >> > url=../x1/x2.html
> >> > url2=http://localhost:8080/x1/x2.html
> >> >
> >> > if i mount ti third level directory "/x1/x2/x3.html"
> >> > url=../../x1/x2/x3.html
> >> > url2=http://x1/x2/x3.html
> >> >
> >> > Is this bug or I use API incorrectly ?
> >> >
> >> > --
> >> >
> >> > Rzhevskiy Dmitry
> >> >
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
Re: RequestCycle().urlFor not work
Posted by Johan Compagner <jc...@gmail.com>.
Which version of wicket do you use?
Why do you need absoluut urls?
On 11/09/2009, Dima Rzhevskiy <di...@rzhevskiy.info> wrote:
> Sorry, yes, urlFor return correct result.
> toAbsolutePath(final String relativePagePath) do not return result what I
> expected.
> javadoc copy/pasted from toAbsolutePath(final String requestPath, String
> relativePagePath)...
>
> I undestand that it is nessesary to use toAbsolutePath(final String
> requestPath, String relativePagePath) where requestPath nessesaty take in
> constructor:
>
> public class X1 extends WebPage {
>
> private static final Logger LOG = LoggerFactory.getLogger(X1.class);
>
> public X1(final PageParameters parameters) {
>
> CharSequence url = getRequestCycle().urlFor(getClass().class, new
> PageParameters());
> final String outerUrl2=
> RequestUtils.toAbsolutePath(url.toString()); //get
> add(new AjaxLink("message"){
> @Override
> public void onClick(AjaxRequestTarget ajaxRequestTarget) {
> CharSequence url =
> getRequestCycle().urlFor(X1.class, new PageParameters());
> String url2=
> RequestUtils.toAbsolutePath(outerUrl2, url.toString());
> LOG.info("url="+url);
> LOG.info("url2="+url2);
> }
> });
>
> }
> }
>
>
> But this code look ugly..
> Is better way of obtaining absolute url exists ?
>
> --
> Rzhevskiy Dmitry
>
>
> 2009/9/11 Jeremy Thomerson <je...@wickettraining.com>
>
>> what is incorrect about those URLs? they are relative - relative to the
>> path you are on.
>>
>> --
>> Jeremy Thomerson
>> http://www.wickettraining.com
>>
>>
>>
>> On Fri, Sep 11, 2009 at 10:14 AM, Dima Rzhevskiy <dima@rzhevskiy.info
>> >wrote:
>>
>> > Hi !
>> >
>> > I create simple page X1 with AjaxLink :
>> > ..
>> > new AjaxLink("message"){
>> > @Override
>> > public void onClick(AjaxRequestTarget ajaxRequestTarget) {
>> > CharSequence url =
>> > getRequestCycle().urlFor(X1.class, new PageParameters());
>> > String url2=
>> > RequestUtils.toAbsolutePath(url.toString());
>> > LOG.info("url="+url);
>> > LOG.info("url2="+url2);
>> > }
>> > }
>> > ...
>> > if I mount page to first level directory , for example "/x1.html"
>> > result is correct:
>> > url=x1.html
>> > url2=http://localhost:8080/ctx/x1.html
>> >
>> > if I mount page to second level directory "/x1/x2.html" result incorrect
>> > url=../x1/x2.html
>> > url2=http://localhost:8080/x1/x2.html
>> >
>> > if i mount ti third level directory "/x1/x2/x3.html"
>> > url=../../x1/x2/x3.html
>> > url2=http://x1/x2/x3.html
>> >
>> > Is this bug or I use API incorrectly ?
>> >
>> > --
>> >
>> > Rzhevskiy Dmitry
>> >
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: RequestCycle().urlFor not work
Posted by Dima Rzhevskiy <di...@rzhevskiy.info>.
Sorry, yes, urlFor return correct result.
toAbsolutePath(final String relativePagePath) do not return result what I
expected.
javadoc copy/pasted from toAbsolutePath(final String requestPath, String
relativePagePath)...
I undestand that it is nessesary to use toAbsolutePath(final String
requestPath, String relativePagePath) where requestPath nessesaty take in
constructor:
public class X1 extends WebPage {
private static final Logger LOG = LoggerFactory.getLogger(X1.class);
public X1(final PageParameters parameters) {
CharSequence url = getRequestCycle().urlFor(getClass().class, new
PageParameters());
final String outerUrl2=
RequestUtils.toAbsolutePath(url.toString()); //get
add(new AjaxLink("message"){
@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
CharSequence url =
getRequestCycle().urlFor(X1.class, new PageParameters());
String url2=
RequestUtils.toAbsolutePath(outerUrl2, url.toString());
LOG.info("url="+url);
LOG.info("url2="+url2);
}
});
}
}
But this code look ugly..
Is better way of obtaining absolute url exists ?
--
Rzhevskiy Dmitry
2009/9/11 Jeremy Thomerson <je...@wickettraining.com>
> what is incorrect about those URLs? they are relative - relative to the
> path you are on.
>
> --
> Jeremy Thomerson
> http://www.wickettraining.com
>
>
>
> On Fri, Sep 11, 2009 at 10:14 AM, Dima Rzhevskiy <dima@rzhevskiy.info
> >wrote:
>
> > Hi !
> >
> > I create simple page X1 with AjaxLink :
> > ..
> > new AjaxLink("message"){
> > @Override
> > public void onClick(AjaxRequestTarget ajaxRequestTarget) {
> > CharSequence url =
> > getRequestCycle().urlFor(X1.class, new PageParameters());
> > String url2=
> > RequestUtils.toAbsolutePath(url.toString());
> > LOG.info("url="+url);
> > LOG.info("url2="+url2);
> > }
> > }
> > ...
> > if I mount page to first level directory , for example "/x1.html"
> > result is correct:
> > url=x1.html
> > url2=http://localhost:8080/ctx/x1.html
> >
> > if I mount page to second level directory "/x1/x2.html" result incorrect
> > url=../x1/x2.html
> > url2=http://localhost:8080/x1/x2.html
> >
> > if i mount ti third level directory "/x1/x2/x3.html"
> > url=../../x1/x2/x3.html
> > url2=http://x1/x2/x3.html
> >
> > Is this bug or I use API incorrectly ?
> >
> > --
> >
> > Rzhevskiy Dmitry
> >
>
Re: RequestCycle().urlFor not work
Posted by Jeremy Thomerson <je...@wickettraining.com>.
what is incorrect about those URLs? they are relative - relative to the
path you are on.
--
Jeremy Thomerson
http://www.wickettraining.com
On Fri, Sep 11, 2009 at 10:14 AM, Dima Rzhevskiy <di...@rzhevskiy.info>wrote:
> Hi !
>
> I create simple page X1 with AjaxLink :
> ..
> new AjaxLink("message"){
> @Override
> public void onClick(AjaxRequestTarget ajaxRequestTarget) {
> CharSequence url =
> getRequestCycle().urlFor(X1.class, new PageParameters());
> String url2=
> RequestUtils.toAbsolutePath(url.toString());
> LOG.info("url="+url);
> LOG.info("url2="+url2);
> }
> }
> ...
> if I mount page to first level directory , for example "/x1.html"
> result is correct:
> url=x1.html
> url2=http://localhost:8080/ctx/x1.html
>
> if I mount page to second level directory "/x1/x2.html" result incorrect
> url=../x1/x2.html
> url2=http://localhost:8080/x1/x2.html
>
> if i mount ti third level directory "/x1/x2/x3.html"
> url=../../x1/x2/x3.html
> url2=http://x1/x2/x3.html
>
> Is this bug or I use API incorrectly ?
>
> --
>
> Rzhevskiy Dmitry
>