You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Robert Haycock <Ro...@mediasurface.com> on 2005/09/23 15:27:38 UTC
Building url's with parameters
Hi,
I'm trying to create a URL to put into some javascript (opening a new
window). I have a javascript function which takes a url and opens a
window with the url passed in. In my component I have a 'getUrl' method
which looks like this:
> public String getContributorUrl(IItemEntry item)
> {
> String[] params = {item.toString()};
> String[] context = {"newwindow"};
> EngineServiceLink url = new
EngineServiceLink(this.getPage().getRequestCycle(),
> "page", context, params,
true);
> return url.getURL();
> }
Where "newwindow" is the component I'm trying to open in a new window.
This 'getUrl' method is called in the .page file so the resulting HTML
looks something like:
<... ondblclick="openWin('/mwc/app?service=page/newwindow&sp=43382');"
....>
Problem is the parameters aren't passed to the new component. newwindow
extends BasePage. newwindow has the following:
> public void validate(IRequestCycle cycle)
> {
> Object[] params = cycle.getServiceParameters();
Problem is that params is null. How can I create a link with parameters
to stick in some javascript?
Rob.
Re: Building url's with parameters
Posted by Ron Piterman <rp...@gmx.net>.
Inject the service tapestry.utl.LinkFactory
create an ILink and get the absolute URl from it.
http://jakarta.apache.org/tapestry/tapestry/hivedocs/module/tapestry.url.html
http://jakarta.apache.org/tapestry/tapestry/apidocs/org/apache/tapestry/services/LinkFactory.html
ציטוט Robert Haycock:
> Hi,
>
>
>
> I'm trying to create a URL to put into some javascript (opening a new
> window). I have a javascript function which takes a url and opens a
> window with the url passed in. In my component I have a 'getUrl' method
> which looks like this:
>
>
>
>
>> public String getContributorUrl(IItemEntry item)
>
>
>> {
>
>
>> String[] params = {item.toString()};
>
>
>> String[] context = {"newwindow"};
>
>
>> EngineServiceLink url = new
>
> EngineServiceLink(this.getPage().getRequestCycle(),
>
>
>> "page", context, params,
>
> true);
>
>
>> return url.getURL();
>
>
>> }
>
>
>
>
> Where "newwindow" is the component I'm trying to open in a new window.
> This 'getUrl' method is called in the .page file so the resulting HTML
> looks something like:
>
>
>
> <... ondblclick="openWin('/mwc/app?service=page/newwindow&sp=43382');"
> ....>
>
>
>
> Problem is the parameters aren't passed to the new component. newwindow
> extends BasePage. newwindow has the following:
>
>
>
>
>> public void validate(IRequestCycle cycle)
>
>
>> {
>
>
>> Object[] params = cycle.getServiceParameters();
>
>
>
>
> Problem is that params is null. How can I create a link with parameters
> to stick in some javascript?
>
>
>
> Rob.
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Building url's with parameters
Posted by Ron Piterman <rp...@gmx.net>.
PS: for the parameter names, use ServiceConstants class.
ציטוט Robert Haycock:
> Hi,
>
>
>
> I'm trying to create a URL to put into some javascript (opening a new
> window). I have a javascript function which takes a url and opens a
> window with the url passed in. In my component I have a 'getUrl' method
> which looks like this:
>
>
>
>
>> public String getContributorUrl(IItemEntry item)
>
>
>> {
>
>
>> String[] params = {item.toString()};
>
>
>> String[] context = {"newwindow"};
>
>
>> EngineServiceLink url = new
>
> EngineServiceLink(this.getPage().getRequestCycle(),
>
>
>> "page", context, params,
>
> true);
>
>
>> return url.getURL();
>
>
>> }
>
>
>
>
> Where "newwindow" is the component I'm trying to open in a new window.
> This 'getUrl' method is called in the .page file so the resulting HTML
> looks something like:
>
>
>
> <... ondblclick="openWin('/mwc/app?service=page/newwindow&sp=43382');"
> ....>
>
>
>
> Problem is the parameters aren't passed to the new component. newwindow
> extends BasePage. newwindow has the following:
>
>
>
>
>> public void validate(IRequestCycle cycle)
>
>
>> {
>
>
>> Object[] params = cycle.getServiceParameters();
>
>
>
>
> Problem is that params is null. How can I create a link with parameters
> to stick in some javascript?
>
>
>
> Rob.
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Building url's with parameters
Posted by Kent Tong <ke...@cpttm.org.mo>.
Robert Haycock <Robert.Haycock <at> mediasurface.com> writes:
> Problem is the parameters aren't passed to the new component. newwindow
> extends BasePage. newwindow has the following:
>
> > public void validate(IRequestCycle cycle)
>
> > {
>
> > Object[] params = cycle.getServiceParameters();
>
> Problem is that params is null. How can I create a link with parameters
> to stick in some javascript?
You should let your page implement IExternalPage and use the
"external" service to get the link. The "page" service doesn't
support parameters for the page.
--
Author of a book for learning Tapestry (http://www.agileskills2.org/EWDT)
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org