You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Niklas Ekman <ni...@yahoo.com> on 2004/09/27 17:15:54 UTC

Generate URL

Hello,

I want to generate an URL to an IPage or an IExternalPage from a regular
java class. It's from a JSP project, so I don't have a request cycle that I
can use to construct a URL. And I can't use the JSP tags in Tapestry because
I have to have the URL in a variable, and not written out on the page as it
is in the taglib.

The way I do it know (for the IPage) is with a function like this:

  public static String getPageURL(HttpServletRequest request, String
pageName, String servletPath) {
    String scheme = request.getScheme();
    String host = request.getServerName();
    int port = request.getServerPort();
    String contextPath = request.getContextPath();
    
    return scheme + "://" + host + ":" + port + contextPath + servletPath +
"?service=page/" + pageName;    
  }

But that function is not very dynamic and if I want to use OGNL expressions
in a similar call to an IExternalPage I have to duplicate a lot of code from
the taglib code. Is there some other way?

Best regards,

Niklas Ekman


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Generate URL

Posted by Niklas Ekman <ni...@yahoo.com>.
That is in general what I'm doing with the basic
IPage. But with the external page with it's parameters
(prefixed with S and other things) I hoped to use some
nice, clean Tapestry technique for doing this a bit
easier. I remember that the service URL:s changed
quite a bit over the versions, and I thought that I
could eliminate that in some way.

/Niklas


--- Erik Hatcher <er...@ehatchersolutions.com> wrote:

> 
> On Sep 27, 2004, at 1:15 PM, Niklas Ekman wrote:
> > I've done that... and I discovered that the
> procedure
> > for doing the stuff is by using the dispathcer and
> > making an include on the current output. I don't
> know
> > how to use the same technique in some other way.
> 
> Woah, yeah, that is ugly.
> 
> You can ask the various services, like
> ExternalService, for the URL, 
> but you'll need some Tapestry-specific context to do
> so.
> 
> I don't have a more clever mechanism in mind at this
> point.  As long as 
> you have the base URL to your Tapestry application
> somehow, you can 
> simply append ?service=external/PageName - which
> isn't too bad of a 
> hack.
> 
> 	Erik
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> tapestry-user-help@jakarta.apache.org
> 
> 



		
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Generate URL

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Sep 27, 2004, at 1:15 PM, Niklas Ekman wrote:
> I've done that... and I discovered that the procedure
> for doing the stuff is by using the dispathcer and
> making an include on the current output. I don't know
> how to use the same technique in some other way.

Woah, yeah, that is ugly.

You can ask the various services, like ExternalService, for the URL, 
but you'll need some Tapestry-specific context to do so.

I don't have a more clever mechanism in mind at this point.  As long as 
you have the base URL to your Tapestry application somehow, you can 
simply append ?service=external/PageName - which isn't too bad of a 
hack.

	Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Generate URL

Posted by Niklas Ekman <ni...@yahoo.com>.
I've done that... and I discovered that the procedure
for doing the stuff is by using the dispathcer and
making an include on the current output. I don't know
how to use the same technique in some other way.

/Niklas


--- Erik Hatcher <er...@ehatchersolutions.com> wrote:

> Look at the source code for the taglibs :))
> 
> 	Erik
> 
> On Sep 27, 2004, at 11:15 AM, Niklas Ekman wrote:
> 
> > Hello,
> >
> > I want to generate an URL to an IPage or an
> IExternalPage from a 
> > regular
> > java class. It's from a JSP project, so I don't
> have a request cycle 
> > that I
> > can use to construct a URL. And I can't use the
> JSP tags in Tapestry 
> > because
> > I have to have the URL in a variable, and not
> written out on the page 
> > as it
> > is in the taglib.
> >
> > The way I do it know (for the IPage) is with a
> function like this:
> >
> >   public static String
> getPageURL(HttpServletRequest request, String
> > pageName, String servletPath) {
> >     String scheme = request.getScheme();
> >     String host = request.getServerName();
> >     int port = request.getServerPort();
> >     String contextPath = request.getContextPath();
> >
> >     return scheme + "://" + host + ":" + port +
> contextPath + 
> > servletPath +
> > "?service=page/" + pageName;
> >   }
> >
> > But that function is not very dynamic and if I
> want to use OGNL 
> > expressions
> > in a similar call to an IExternalPage I have to
> duplicate a lot of 
> > code from
> > the taglib code. Is there some other way?
> >
> > Best regards,
> >
> > Niklas Ekman
> >
> >
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> tapestry-user-help@jakarta.apache.org
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> tapestry-user-help@jakarta.apache.org
> 
> 



		
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail 

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Generate URL

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
Look at the source code for the taglibs :))

	Erik

On Sep 27, 2004, at 11:15 AM, Niklas Ekman wrote:

> Hello,
>
> I want to generate an URL to an IPage or an IExternalPage from a 
> regular
> java class. It's from a JSP project, so I don't have a request cycle 
> that I
> can use to construct a URL. And I can't use the JSP tags in Tapestry 
> because
> I have to have the URL in a variable, and not written out on the page 
> as it
> is in the taglib.
>
> The way I do it know (for the IPage) is with a function like this:
>
>   public static String getPageURL(HttpServletRequest request, String
> pageName, String servletPath) {
>     String scheme = request.getScheme();
>     String host = request.getServerName();
>     int port = request.getServerPort();
>     String contextPath = request.getContextPath();
>
>     return scheme + "://" + host + ":" + port + contextPath + 
> servletPath +
> "?service=page/" + pageName;
>   }
>
> But that function is not very dynamic and if I want to use OGNL 
> expressions
> in a similar call to an IExternalPage I have to duplicate a lot of 
> code from
> the taglib code. Is there some other way?
>
> Best regards,
>
> Niklas Ekman
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org