On Wed, Jan 21, 2015 at 1:07 PM, George Christman <gchrist...@cardaddy.com>
wrote:

> On Wed, Jan 21, 2015 at 3:16 PM, Kalle Korhonen
> <kalle.o.korho...@gmail.com> wrote:
> > On Tue, Jan 20, 2015 at 1:03 PM, George Christman <
> gchrist...@cardaddy.com>
> > wrote:
> >> So I just took a look at the tapestry code and I'm not seeing anyway
> >> to work around it unless I want to build my own links which I'd rather
> >> not do because of my use of the url rewriter.
> >> Tap code line 113
> >>
> https://github.com/apache/tapestry-5/blob/5.4-beta-26/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/LinkSourceImpl.java
> >> How do you work around this?
> > You are right George. Ever since the loopback reset listeners was put it
> in
> > (for T5.3), the LinkSource.createPageRenderLink(...) doesn't anymore work
> > outside request context (e.g. in a scheduled job). You should instead use
> > the linkEncoder directly (as in the implementation for
> > createPageRenderLink):
> >
> Just seen this, is there any chance we could fix this issue so that we
> don't need to write the cumbersome code below every time? I'm actually
> surprised I'm the first to discover this. We send out a lot of
> reminder emails etc at work via a cron job which would require this
> and I also need it to work for my own project. Should I create a bug
> in jira?
> >
>

Somebody's gotta be the first one. I guess many of the existing
installations are still not using the more recent versions of T5. But I
agree, it might be worth fixing so go ahead and open an issue.


> >         PageRenderRequestParameters parameters = new
> > PageRenderRequestParameters(canonical, new ArrayEventContext(
> >                 typeCoercer, context), loopback);
> >         Link link = linkEncoder.createPageRenderLink(parameters);
>
> One last thing before we move on from this issue, what is the
> canonical? Would that be the Page.class.getName() ? and I'm assuming
> context is just my url context values?
>

Take another look at the source you pointed to yourself, but: String
canonical = resolver.canonicalizePageName(pageName);

Kalle


>> On Tue, Jan 20, 2015 at 11:14 AM, George Christman
> >> <gchrist...@cardaddy.com> wrote:
> >> >  Still no success in getting this to work. I've contributed the
> Hostname
> >> etc.
> >> >
> >> > configuration.add(SymbolConstants.HOSTNAME, "localhost");
> >> >         configuration.add(SymbolConstants.HOSTPORT, "8080");
> >> >         configuration.add(SymbolConstants.HOSTPORT_SECURE, "false");
> >> >
> >> > And a simple test which fails with the same error.
> >> >
> >> > private void testTask() {
> >> >         periodicExecutor.addJob(new IntervalSchedule(3000),
> >> >                 "Data Validation1", new Runnable() {
> >> >             @Override
> >> >             public void run() {
> >> >                 System.out.println("test");
> >> >                 try {
> >> >
> >> > System.out.println(linkSource.createPageRenderLink(Index.class));
> >> >                 } catch (Exception ex) {
> >> >                     System.out.println("ex " + ex);
> >> >                 }
> >> >             }
> >> >         });
> >> >     }
> >> >
> >> > On Tue, Jan 20, 2015 at 7:41 AM, George Christman
> >> > <gchrist...@cardaddy.com> wrote:
> >> >> So toAbsolute is the code calling the request and the cause of this
> >> >> exception? I'm assuming your referring to me contributing those
> values
> >> to my
> >> >> appmodule. Once I contribute those values, would toAbsolute use those
> >> values
> >> >> instead of the request? Just trying to understand the issue a little
> bit
> >> >> better. Thanks Kalle.
> >> >>
> >> >> On Jan 20, 2015 4:44 AM, "Kalle Korhonen" <
> kalle.o.korho...@gmail.com>
> >> >> wrote:
> >> >>>
> >> >>> On Tue, Jan 20, 2015 at 1:23 AM, George Christman
> >> >>> <gchrist...@cardaddy.com>
> >> >>> wrote:
> >> >>>
> >> >>> > I'm using T5 beta-25 and I have the following code and I'm
> noticing
> >> >>> > when the scheduler fires off my service, my PageRenderLinkSource
> does
> >> >>> > not work. If I manually fire it off through the admin with an
> >> >>> > actionlink, it works without issue.
> >> >>> > I'm seeing the following exception
> >> >>> > java.lang.NullPointerException: Unable to delegate method
> invocation
> >> >>> > to property 'request' of <Proxy for
> >> >>> > RequestGlobals(org.apache.tapestry5.services.RequestGlobals)>,
> >> because
> >> >>> > the property is null.
> >> >>> > Any idea why this isn't working?
> >> >>> >
> >> >>>
> >> >>> Naturally, you don't have a request to work with when you are
> executing
> >> >>> from a cron job. But if you just want to generate links, you don't
> >> need to
> >> >>> and you shouldn't use the request values. Contribute HOSTNAME,
> HOSTPORT
> >> >>> and
> >> >>> HOSTPORT_SECURE and you can generate absolute urls without
> resorting to
> >> >>> reading the values from the request.
> >> >>>
> >> >>> Kalle
> >> >>>
> >> >>>
> >> >>>
> >> >>> >
> >> >>> >
> ---------------------------------------------------------------------
> >> >>> > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> >> >>> > For additional commands, e-mail: users-h...@tapestry.apache.org
> >> >>> >
> >> >>> >
> >> >
> >> >
> >> >
> >> > --
> >> > George Christman
> >> > CEO
> >> > www.CarDaddy.com
> >> > P.O. Box 735
> >> > Johnstown, New York
> >>
> >>
> >>
> >> --
> >> George Christman
> >> CEO
> >> www.CarDaddy.com
> >> P.O. Box 735
> >> Johnstown, New York
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> >> For additional commands, e-mail: users-h...@tapestry.apache.org
> >>
> >>
>
>
>
> --
> George Christman
> CEO
> www.CarDaddy.com
> P.O. Box 735
> Johnstown, New York
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>

Reply via email to