You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Flavius <fl...@silverlion.com> on 2009/02/05 01:01:13 UTC

Using urlFor


We have functionality that needs to send an email of any changes
that occur in a record.  At first we were going to just send the
email when the transaction completes...but that will have issues
if the app is up and the mail server is down (or unreachable at the
moment).

So we're going to write the changes to the database and have
a job wake up and send the email.

I had a method that built the url on the page request, like this:

public String buildUrl(Class<? extends _BasePage> targetPageClass,
PageParameters pageParams)
	{
		String uri = urlFor(targetPageClass, pageParams).toString();
		String url = RequestUtils.toAbsolutePath(uri);		
		return url;
	}

The problem is the job won't have an IRequestCycle to access, or
even Component.  Those are the two places I found urlFor() implemented.

It's about a half dozen pages that can be linked to, so I thought of
making static strings and building them at startup.  I can then append
the params when the job runs (it's only one param, so that's easy).

I don't have an IRequestCycle when WebApplication.init() fires, though.
Is there a straight forward way of doing this that I'm missing?

Worst case scenario, I could build the urls when the record is updated and
persist it.  I'd like to avoid that, if possible.

Thanks very much.




-- 
View this message in context: http://www.nabble.com/Using-urlFor-tp21842522p21842522.html
Sent from the Wicket - User 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: Using urlFor

Posted by Flavius <fl...@silverlion.com>.

That works.  I'll do that.
Thanks Igor.


igor.vaynberg wrote:
> 
> you can mount the pages so you have well known urls to them and build
> them manually.
> 
> -igor
> 
> 

-- 
View this message in context: http://www.nabble.com/Using-urlFor-tp21842522p21852518.html
Sent from the Wicket - User 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: Using urlFor

Posted by Igor Vaynberg <ig...@gmail.com>.
you can mount the pages so you have well known urls to them and build
them manually.

-igor

On Wed, Feb 4, 2009 at 4:01 PM, Flavius <fl...@silverlion.com> wrote:
>
>
> We have functionality that needs to send an email of any changes
> that occur in a record.  At first we were going to just send the
> email when the transaction completes...but that will have issues
> if the app is up and the mail server is down (or unreachable at the
> moment).
>
> So we're going to write the changes to the database and have
> a job wake up and send the email.
>
> I had a method that built the url on the page request, like this:
>
> public String buildUrl(Class<? extends _BasePage> targetPageClass,
> PageParameters pageParams)
>        {
>                String uri = urlFor(targetPageClass, pageParams).toString();
>                String url = RequestUtils.toAbsolutePath(uri);
>                return url;
>        }
>
> The problem is the job won't have an IRequestCycle to access, or
> even Component.  Those are the two places I found urlFor() implemented.
>
> It's about a half dozen pages that can be linked to, so I thought of
> making static strings and building them at startup.  I can then append
> the params when the job runs (it's only one param, so that's easy).
>
> I don't have an IRequestCycle when WebApplication.init() fires, though.
> Is there a straight forward way of doing this that I'm missing?
>
> Worst case scenario, I could build the urls when the record is updated and
> persist it.  I'd like to avoid that, if possible.
>
> Thanks very much.
>
>
>
>
> --
> View this message in context: http://www.nabble.com/Using-urlFor-tp21842522p21842522.html
> Sent from the Wicket - User 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
>
>

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