You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by la...@email.dk on 2005/08/16 08:30:18 UTC

Request parameters

Hi,

I was wondering if it is somehow possible to add request parameters to a
PageLink? I've written a PopupLinkRenderer to be used with a PageLink but
since the PageLink component cannot take any parameters (unlike DirectLink),
I've had to programmatically add some request parameters to the generated link 
by looking for a ? (questionmark) and if its present, simply just add a
&key=value to the string otherwise add ?key=value and so fourth...
I tried to add multiple parameters to the PageService in the 3.0.3 release,
but got an exception as only one page-name could be used as a parameter.

I'm currently using 4-beta4.


regards
--
Lars Borup Jensen


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


Re: Request parameters

Posted by Michael Henderson <mh...@mac.com>.
Hi,
    Why not create a service to allow named parameters? I see no  
reason that named parameters, presented in a Map cannot be squeezed  
and unsqueezed.

It needs 3 classes, a Service and an ILink implementation and a  
custom PageLink component

The main stumbling block is that ILink construction in a service is  
made via a method that accepts an array of service parameters and not  
a map.

Simply add API, accessible to the PageLink component that accepts a  
Map to construct an ILink.

When decoding the parameters in the service implementation you can  
stuff them into the request cycle as attributes or, if the parameters  
have
the same name as page properties use OGNL to set the properties from  
the parameters.


Mike


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


Re: Request parameters

Posted by Geoff Longman <gl...@gmail.com>.
I have a whipped up a project that implements what you need (Tap
3.0.3) . It's attached so I know it'll get to you but not to the list.
At work so I can't post it somewhere on the web.

In a nutshell I have created two new link components. RemoteLink is a
link component that will generate a link to a listener on another page
and parameters can be passed to that listener.

The other is a replacement for DirectLink. What you need to do is add
a DirectLink to the target page, specifying the listener. There is no
need to reference this one in the target pages template as it's only
used by RemoteLink.

RemoteLink obtains the target page and the DirectLink from that page.
The it used the remote DL to get the ILink. I had to make a
replacement for DirectLink as the DirectLink.java does not have

public abstract void setParameters(Object parms) which RemoteLink needs.

The zip contains all and a small example app.

enjoy.

Geoff


On 8/16/05, lars.borup@email.dk <la...@email.dk> wrote:
> Yes - and I use this in many places, but sometimes you'd want (read:I could
> really use :-) ) to add yet another request parameter to a link.
> 
> An example: I have a Page for editing a specific piece of content. I want this
> page to be opened in a seperate window (using window.open(...)) and I have
> implemented a PopupLinkRenderer wich renders this popup link. Now I want to
> instruct the page (in pageBeginRender) to reset all session persistent
> properties and I do this by adding a "&reset=true" to the request URI.
> I cannot see another way of doing so, since the properties are session persist
> (must be as the page will be submitted many times while editing the same piece
> of content, hence using session persistence for the content being edited). How
> else will I know if its a "first" time request or simply a request while editing?
> 
> I hope you get the pictures.. Kinda hard for me to explain..
> 
> regards, Lars Borup Jensen
> 
> 
> On Tue, 16 Aug 2005 08:10:32 -0400, Geoff Longman wrote
> > How would the recieving page extract the paramters? PageLink does not
> > invoke a listener on the target page.
> >
> > The way to do this would be to use a DirectLink with parameters and
> > use a listener to extract those parameters from the request cycle.
> > Then obtain the target page (cycle.getPage()), call sets on it and
> > then use cycle.activate() to transfer control to the target page.
> >
> > Geoff
> >
> > On 8/16/05, lars.borup@email.dk <la...@email.dk> wrote:
> > > Hi,
> > >
> > > I was wondering if it is somehow possible to add request parameters to a
> > > PageLink? I've written a PopupLinkRenderer to be used with a PageLink but
> > > since the PageLink component cannot take any parameters (unlike DirectLink),
> > > I've had to programmatically add some request parameters to the generated link
> > > by looking for a ? (questionmark) and if its present, simply just add a
> > > &key=value to the string otherwise add ?key=value and so fourth...
> > > I tried to add multiple parameters to the PageService in the 3.0.3 release,
> > > but got an exception as only one page-name could be used as a parameter.
> > >
> > > I'm currently using 4-beta4.
> > >
> > >
> > > regards
> > > --
> > > Lars Borup Jensen
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> > >
> > >
> >
> > --
> > The Spindle guy.           http://spindle.sf.net
> > Get help with Spindle:
> > http://lists.sourceforge.net/mailman/listinfo/spindle-user
> > Announcement Feed:
> > http://www.jroller.com/rss/glongman?catname=/Announcements
> > Feature Updates:            http://spindle.sf.net/updates
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 
> --
> Lars Borup Jensen
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


-- 
The Spindle guy.           http://spindle.sf.net
Get help with Spindle:   
http://lists.sourceforge.net/mailman/listinfo/spindle-user
Announcement Feed:    
http://www.jroller.com/rss/glongman?catname=/Announcements
Feature Updates:            http://spindle.sf.net/updates

Re: Request parameters

Posted by Andreas Andreou <an...@di.uoa.gr>.
Implement IExternalPage and implement
activateExternalPage(Object[] parameters, IRequestCycle cycle),
adding code that resets your persistent properties.
Then make your PopupLinkRenderer create ExternalLinks.

During submits, the activateExternalPage method will not get called,
so your properties will not get reset.

lars.borup@email.dk wrote:

>Yes - and I use this in many places, but sometimes you'd want (read:I could
>really use :-) ) to add yet another request parameter to a link.
>
>An example: I have a Page for editing a specific piece of content. I want this
>page to be opened in a seperate window (using window.open(...)) and I have
>implemented a PopupLinkRenderer wich renders this popup link. Now I want to
>instruct the page (in pageBeginRender) to reset all session persistent
>properties and I do this by adding a "&reset=true" to the request URI.
>I cannot see another way of doing so, since the properties are session persist
>(must be as the page will be submitted many times while editing the same piece
>of content, hence using session persistence for the content being edited). How
>else will I know if its a "first" time request or simply a request while editing?
>
>I hope you get the pictures.. Kinda hard for me to explain..
>
>regards, Lars Borup Jensen
>
>
>On Tue, 16 Aug 2005 08:10:32 -0400, Geoff Longman wrote
>  
>
>>How would the recieving page extract the paramters? PageLink does not
>>invoke a listener on the target page.
>>
>>The way to do this would be to use a DirectLink with parameters and
>>use a listener to extract those parameters from the request cycle.
>>Then obtain the target page (cycle.getPage()), call sets on it and
>>then use cycle.activate() to transfer control to the target page.
>>
>>Geoff
>>
>>On 8/16/05, lars.borup@email.dk <la...@email.dk> wrote:
>>    
>>
>>>Hi,
>>>
>>>I was wondering if it is somehow possible to add request parameters to a
>>>PageLink? I've written a PopupLinkRenderer to be used with a PageLink but
>>>since the PageLink component cannot take any parameters (unlike DirectLink),
>>>I've had to programmatically add some request parameters to the generated link
>>>by looking for a ? (questionmark) and if its present, simply just add a
>>>&key=value to the string otherwise add ?key=value and so fourth...
>>>I tried to add multiple parameters to the PageService in the 3.0.3 release,
>>>but got an exception as only one page-name could be used as a parameter.
>>>
>>>I'm currently using 4-beta4.
>>>
>>>
>>>regards
>>>--
>>>Lars Borup Jensen
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>>
>>>
>>>      
>>>
>>-- 
>>The Spindle guy.           http://spindle.sf.net
>>Get help with Spindle:   
>>http://lists.sourceforge.net/mailman/listinfo/spindle-user
>>Announcement Feed:    
>>http://www.jroller.com/rss/glongman?catname=/Announcements
>>Feature Updates:            http://spindle.sf.net/updates
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>    
>>
>
>
>--
>Lars Borup Jensen
>
>
>---------------------------------------------------------------------
>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


Re: Request parameters

Posted by la...@email.dk.
Yes - and I use this in many places, but sometimes you'd want (read:I could
really use :-) ) to add yet another request parameter to a link.

An example: I have a Page for editing a specific piece of content. I want this
page to be opened in a seperate window (using window.open(...)) and I have
implemented a PopupLinkRenderer wich renders this popup link. Now I want to
instruct the page (in pageBeginRender) to reset all session persistent
properties and I do this by adding a "&reset=true" to the request URI.
I cannot see another way of doing so, since the properties are session persist
(must be as the page will be submitted many times while editing the same piece
of content, hence using session persistence for the content being edited). How
else will I know if its a "first" time request or simply a request while editing?

I hope you get the pictures.. Kinda hard for me to explain..

regards, Lars Borup Jensen


On Tue, 16 Aug 2005 08:10:32 -0400, Geoff Longman wrote
> How would the recieving page extract the paramters? PageLink does not
> invoke a listener on the target page.
> 
> The way to do this would be to use a DirectLink with parameters and
> use a listener to extract those parameters from the request cycle.
> Then obtain the target page (cycle.getPage()), call sets on it and
> then use cycle.activate() to transfer control to the target page.
> 
> Geoff
> 
> On 8/16/05, lars.borup@email.dk <la...@email.dk> wrote:
> > Hi,
> > 
> > I was wondering if it is somehow possible to add request parameters to a
> > PageLink? I've written a PopupLinkRenderer to be used with a PageLink but
> > since the PageLink component cannot take any parameters (unlike DirectLink),
> > I've had to programmatically add some request parameters to the generated link
> > by looking for a ? (questionmark) and if its present, simply just add a
> > &key=value to the string otherwise add ?key=value and so fourth...
> > I tried to add multiple parameters to the PageService in the 3.0.3 release,
> > but got an exception as only one page-name could be used as a parameter.
> > 
> > I'm currently using 4-beta4.
> > 
> > 
> > regards
> > --
> > Lars Borup Jensen
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> > 
> >
> 
> -- 
> The Spindle guy.           http://spindle.sf.net
> Get help with Spindle:   
> http://lists.sourceforge.net/mailman/listinfo/spindle-user
> Announcement Feed:    
> http://www.jroller.com/rss/glongman?catname=/Announcements
> Feature Updates:            http://spindle.sf.net/updates
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


--
Lars Borup Jensen


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


Re: Request parameters

Posted by Geoff Longman <gl...@gmail.com>.
How would the recieving page extract the paramters? PageLink does not
invoke a listener on the target page.

The way to do this would be to use a DirectLink with parameters and
use a listener to extract those parameters from the request cycle.
Then obtain the target page (cycle.getPage()), call sets on it and
then use cycle.activate() to transfer control to the target page.

Geoff


On 8/16/05, lars.borup@email.dk <la...@email.dk> wrote:
> Hi,
> 
> I was wondering if it is somehow possible to add request parameters to a
> PageLink? I've written a PopupLinkRenderer to be used with a PageLink but
> since the PageLink component cannot take any parameters (unlike DirectLink),
> I've had to programmatically add some request parameters to the generated link
> by looking for a ? (questionmark) and if its present, simply just add a
> &key=value to the string otherwise add ?key=value and so fourth...
> I tried to add multiple parameters to the PageService in the 3.0.3 release,
> but got an exception as only one page-name could be used as a parameter.
> 
> I'm currently using 4-beta4.
> 
> 
> regards
> --
> Lars Borup Jensen
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


-- 
The Spindle guy.           http://spindle.sf.net
Get help with Spindle:   
http://lists.sourceforge.net/mailman/listinfo/spindle-user
Announcement Feed:    
http://www.jroller.com/rss/glongman?catname=/Announcements
Feature Updates:            http://spindle.sf.net/updates

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


Re: Request parameters

Posted by la...@email.dk.
YES! - This looks exactly like what I need.. I wanna thank all for responding
so quickly - hopefully one day I'll ba able to help yet another newbie
tapestry user :-) .. 

regards, Lars Borup Jensen

On Tue, 16 Aug 2005 14:00:39 +0000 (UTC), Marcus Brito wrote
> <lars.borup <at> email.dk> writes:
> 
> > I was wondering if it is somehow possible to add request parameters to a
> > PageLink? I've written a PopupLinkRenderer to be used with a PageLink but
> > since the PageLink component cannot take any parameters
> 
> Tapestry is all about *not* figuring out URL's. You write your pages 
> using object properties, and tapestry will assemble the correct 
> URL's to reference them. The moment you start to think how to add a 
> request parameter to a tapestry URL, you've just found out that 
> something is wrong.
> 
> Are you really calling WebRequest.getParameter() on your page? If 
> yes, think about it again. Try to code it as an external page 
> (implement IExternalPage), and read the necessary parameters on 
> activateExternalPage(). Then you can just use an ExternalLink to 
> reference your page.
> 
> Something like this:
> 
> public abstract class UserPage extends BasePage implements IExternalPage
> {
>     public abstract String getUserName();
>     public abstract void setUserName(String name);
> 
>     /**
>      * Activates the user details page. The user name should be the first
>      * external parameter.
>      */
>     public void activateExternalPage(Object[] params, IRequestCycle 
> cycle)    {        setUserName((String) params[0]);    } }
> 
> And to link to the above page, you can use something like:
> 
> <a jwcid="@ExternalLink" page="UserPage" parameters="ognl:currentUser">Edit
> Profile</a>
> 
> The generated link will look somewhat like
> "http://myhost/app?service=external&page=UserPage&sp=Sjoe", but you shouldn't
> care about it. All you care is that your external page needs one 
> parameter, and that it's provided in the link.
> 
> I hope that helped,
> 
> -- Marcus Brito
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


--
Lars Borup Jensen


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


Re: Request parameters

Posted by Marcus Brito <mb...@gmail.com>.
 <lars.borup <at> email.dk> writes:

> I was wondering if it is somehow possible to add request parameters to a
> PageLink? I've written a PopupLinkRenderer to be used with a PageLink but
> since the PageLink component cannot take any parameters

Tapestry is all about *not* figuring out URL's. You write your pages using
object properties, and tapestry will assemble the correct URL's to reference
them. The moment you start to think how to add a request parameter to a tapestry
URL, you've just found out that something is wrong.

Are you really calling WebRequest.getParameter() on your page? If yes, think
about it again. Try to code it as an external page (implement IExternalPage),
and read the necessary parameters on activateExternalPage(). Then you can just
use an ExternalLink to reference your page.

Something like this:

public abstract class UserPage extends BasePage implements IExternalPage
{
    public abstract String getUserName();
    public abstract void setUserName(String name);

    /**
     * Activates the user details page. The user name should be the first
     * external parameter.
     */
    public void activateExternalPage(Object[] params, IRequestCycle cycle)
    {
        setUserName((String) params[0]);
    }
}

And to link to the above page, you can use something like:

<a jwcid="@ExternalLink" page="UserPage" parameters="ognl:currentUser">Edit
Profile</a>

The generated link will look somewhat like
"http://myhost/app?service=external&page=UserPage&sp=Sjoe", but you shouldn't
care about it. All you care is that your external page needs one parameter, and
that it's provided in the link.

I hope that helped,

-- Marcus Brito


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