You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Stephan Windmüller <st...@cs.tu-dortmund.de> on 2009/07/07 12:13:33 UTC

Replacement for DataSqueezer

Hello!

There is a page in my current project for which I want to pass an object
between the requests and maintain it's state, but it should not be
displayed. Also I do not want to store the data in the session, so
putting it in a hidden field seems the best option.

Unfortunately I am unable to find a standard way for tapestry which
generates the streamed data needed by ValueEncoder. The wiki tells about
DataSqueezer[0] but that seems quite outdated. The persistence guide[1]
mentions a "client strategy" which allows "an extra hidden field in each
form" but I do not know how to force hidden fields instead of URL encoding.

Can anyone tell me how to use the Hidden component the right way?

TIA
 Stephan

[0] http://wiki.apache.org/tapestry/DataSqueezer
[1] http://tapestry.formos.com/nightly/tapestry5/guide/persist.html

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


Changing Sort on Grid Column

Posted by Jonathan O'Connor <ni...@eircom.net>.
Hi,
I have a Grid with a string column displaying a date. I want this column 
to be of String type because of my automatic code to generate a CSV file 
from the grid. However, if I sort the column, it is sorted using 
alphabetic ordering, thus 25-12-2001 comes after 01-01-2009.

Is there a way to change this? From what I can see the GridSortModel 
provides a ColumnSort enum, but I can't see how to supply a comparator. 
Is this possible?

As a workaround, I can leave the column as a Date, and then supply a 
overridden myDatecell block. But I will also have to modify my CSV 
generator.

Ciao,
Jonathan

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


Re: Replacement for DataSqueezer

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Tue, 07 Jul 2009 17:04:51 -0300, Stephan Windmüller  
<wi...@white-hawk.de> escreveu:

> I am using a navigation component which inserts ActionLinks into the
> page. These may be responsible for creating URL parameters.
> Is there a way to exclude these links

 From what I could see from the source code, client persistence will only  
change event URLs, not page ones.

> or force form submission for the values?

Just don't use EventLinks/ActionLinks in your page, use forms instead.

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

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


Re: Replacement for DataSqueezer

Posted by Stephan Windmüller <wi...@white-hawk.de>.
Thiago H. de Paula Figueiredo wrote:

>> But IIRC the setting @Persist("client") produced URL parameters
>> instead of hidden fields. How can I force the latter?
> Hidden fields cannot be used by links (unless you use Javascript to copy  
> their value to the URL), just forms. One possible solution is to not use  
> links for action events, just form submissions in that page.

I am using a navigation component which inserts ActionLinks into the
page. These may be responsible for creating URL parameters.

Is there a way to exclude these links or force form submission for the
values?

Regards
 Stephan

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


Re: Replacement for DataSqueezer

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Tue, 07 Jul 2009 15:10:21 -0300, Stephan Windmüller  
<st...@cs.tu-dortmund.de> escreveu:

> Keeping the data in the session would break tabbed browsing.

I agree. There are other solutions (conversations). Search the mailing  
list archives to find some people doing this in Tapestry.

> Thank you for your effort. :)

You're welcome!

> It is the same page, sorry if my first mail was misleading.

No problem. :)

> But IIRC the
> setting @Persist("client") produced URL parameters instead of hidden
> fields. How can I force the latter?

Hidden fields cannot be used by links (unless you use Javascript to copy  
their value to the URL), just forms. One possible solution is to not use  
links for action events, just form submissions in that page.

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

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


Re: Replacement for DataSqueezer

Posted by Stephan Windmüller <st...@cs.tu-dortmund.de>.
Thiago H. de Paula Figueiredo schrieb:

>> ValueEncoder does not need streamed data if it can obtain the object
>> from an identifier. But the data I am using is not stored anywhere so
>> the only way I see is streaming the data and reconstructing the objects.
>> Currently I am using Xstream for this.
> In your case, isn't serializing and deserializing objects all the time
> worse than keeping them in the session?

Keeping the data in the session would break tabbed browsing.

The page I am talking about it for administrators only, so load and
traffic are not the problem here.

> And don't forget that most browsers don't accept very long URLs. I
> don't know their URL limit, though.

That's why I wanted to use hidden fields in my form.

>> Form submission is the way I want it to do. The passed values should be
>> stored in a Hidden-component so that they are submitted with the form.
> I've just tested and read the sources of the client persistence,
> something I've never used before. :)

Thank you for your effort. :)

> @Persist works in a single page. Thus, as long as you stay in the same
> page, @Persist("client") works when you submit a form (Tapestry
> automatically adds the hidden field) and even in links that point to
> the same page (including event URLs).

It is the same page, sorry if my first mail was misleading. But IIRC the
setting @Persist("client") produced URL parameters instead of hidden
fields. How can I force the latter?

Regards
 Stephan

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


Re: Replacement for DataSqueezer

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, Jul 7, 2009 at 11:03 AM, Stephan
Windmüller<st...@cs.tu-dortmund.de> wrote:
> What happens when a user disabled cookies?

Good point. :)

> ValueEncoder does not need streamed data if it can obtain the object
> from an identifier. But the data I am using is not stored anywhere so
> the only way I see is streaming the data and reconstructing the objects.
> Currently I am using Xstream for this.

In your case, isn't serializing and deserializing objects all the time
worse than keeping them in the session?
And don't forget that most browsers don't accept very long URLs. I
don't know their URL limit, though.

> Form submission is the way I want it to do. The passed values should be
> stored in a Hidden-component so that they are submitted with the form.

I've just tested and read the sources of the client persistence,
something I've never used before. :)
@Persist works in a single page. Thus, as long as you stay in the same
page, @Persist("client") works when you submit a form (Tapestry
automatically adds the hidden field) and even in links that point to
the same page (including event URLs). Summary: all you need is to do
is to add @Persist("client") to your field, but it doesn't work across
pages. As far as I can see, Tapestry doesn't support what you want of
of the box.

You can code your own solution. Tapestry has a hook that allows you to
change links generated by it, so you can add any information you want
to the URLs.
Implement the LinkCreationListener interface (say,
MyLinkCreationListener) then add this to your AppModule:

    public MyLinkCreationListener
buildMyLinkCreationListener(LinkCreationHub linkCreationHub,

@Autobuild MyLinkCreationListener listener)
    {
        linkCreationHub.addListener(listener);

        return service;
    }

This code was adapted from Tapestry sources and was not tested, but I
guess it should give you a hint on how to implement what you want. ;)

-- 
Thiago

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


Re: Replacement for DataSqueezer

Posted by Stephan Windmüller <st...@cs.tu-dortmund.de>.
Thiago H. de Paula Figueiredo schrieb:

>> There is a page in my current project for which I want to pass an object
>> between the requests and maintain it's state, but it should not be
>> displayed. Also I do not want to store the data in the session, so
>> putting it in a hidden field seems the best option.
> What about cookies? They are accessed in Tapestry through the Cookies service.

What happens when a user disabled cookies?

>> Unfortunately I am unable to find a standard way for tapestry which
>> generates the streamed data needed by ValueEncoder.
> I'm not following you here. ValueEncoder does not need streamed data.
> It just does mapping between object and a string representation of it
> and vice-versa. This mapping is implemented by you. If the given
> object has a primary key field, it's the easiest solution.

ValueEncoder does not need streamed data if it can obtain the object
from an identifier. But the data I am using is not stored anywhere so
the only way I see is streaming the data and reconstructing the objects.
Currently I am using Xstream for this.

>> The persistence guide[1]
>> mentions a "client strategy" which allows "an extra hidden field in each
>> form" but I do not know how to force hidden fields instead of URL encoding.
> AFAIK, it's impossible to do what you want this way. How would you
> pass parameters from one page to another without using the session,
> cookies, form submission or information in the URL?

Form submission is the way I want it to do. The passed values should be
stored in a Hidden-component so that they are submitted with the form.
But I do not know how to store the data in a standard way.

Regards
 Stephan

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


Re: Replacement for DataSqueezer

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, Jul 7, 2009 at 7:13 AM, Stephan
Windmüller<st...@cs.tu-dortmund.de> wrote:
> Hello!

Hi!

> There is a page in my current project for which I want to pass an object
> between the requests and maintain it's state, but it should not be
> displayed. Also I do not want to store the data in the session, so
> putting it in a hidden field seems the best option.

What about cookies? They are accessed in Tapestry through the Cookies service.

> Unfortunately I am unable to find a standard way for tapestry which
> generates the streamed data needed by ValueEncoder.

I'm not following you here. ValueEncoder does not need streamed data.
It just does mapping between object and a string representation of it
and vice-versa. This mapping is implemented by you. If the given
object has a primary key field, it's the easiest solution.

> The wiki tells about DataSqueezer[0] but that seems quite outdated.

This is part of Tapestry 4, not 5.

> The persistence guide[1]
> mentions a "client strategy" which allows "an extra hidden field in each
> form" but I do not know how to force hidden fields instead of URL encoding.

AFAIK, it's impossible to do what you want this way. How would you
pass parameters from one page to another without using the session,
cookies, form submission or information in the URL?

-- 
Thiago

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