You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Leo Sakhvoruk <le...@gmail.com> on 2006/09/18 17:31:04 UTC

Very long URLs problem.

Hi,

I'm running into issues with Tapestry generating some seriously long 
URLs (something around 15k characters).

I have a page which generates a list of links using the simple "For" 
construct, in the beginning the link URLs are about 2k chars long. Once 
the link is clicked the user is taken to a different page if he/she 
wants to return to the original page by clicking a page link the 
original page is rendered again but now the link URLs are longer!!! 
After a few iterations of this the browser simply can't send the request 
because the URL is huge.

What can I do? The links are generated using DirectLink.

Any advice would be appreciated.

Thanks

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


Re: Re: Re: Very long URLs problem.

Posted by Martin Strand <ma...@entcap.se>.
It is possible, I implemented my own persistence strategy which uses DataSqueezer and it was pretty straightforward. You'll need a persistence scope as well - look at the Form persistence in the wiki to see how you should wire things together. This "squeeze" strategy combined with the HibernateSqueezer really simplified things for me.

public class SqueezerPersistenceStrategy
	extends ClientPropertyPersistenceStrategy
{
	private DataSqueezer squeezer;

	public SqueezerPersistenceStrategy(DataSqueezer squeezer)
	{
		this.squeezer = squeezer;
	}

	@Override
	public void store(String pageName, String idPath, String propertyName, Object newValue)
	{
		String squeezedString = squeezer.squeeze(newValue);
		super.store(pageName, idPath, propertyName, squeezedString);
	}

	@Override
	public Collection getStoredChanges(String pageName)
	{
		Collection<Object> result = new LinkedList<Object>();
		for (Object object : super.getStoredChanges(pageName))
		{
			PropertyChange change = (PropertyChange) object;
			String squeezedString = change.getNewValue().toString();
			Object unsqueezed = squeezer.unsqueeze(squeezedString);
			change = new PropertyChangeImpl(change.getComponentPath(), change.getPropertyName(), unsqueezed);
			result.add(change);
		}
		return result;
	}
}


On Wed, 20 Sep 2006 01:21:49 +0200, Sam Gendler <sg...@ideasculptor.com> wrote:

> On 9/19/06, Martin Strand <ma...@entcap.se> wrote:
>> The client persistence strategy doesn't use DataSqueezer:
>> https://issues.apache.org/jira/browse/TAPESTRY-738
>>
>
> That's unfortunate.  I suppose one could persist them yourself using
> hidden fields, at least in simple cases.  I just assumed that client
> persistence would use the same mechanisms as putting an object in a
> form.  I find it odd that it doesn't, really.  Actually, now that I
> think about it, didn't I read somewhere that it is possible to
> implement your own persistence strategies and tie them into tapestry
> via hivemind? If so, in the worst case, I guess you could grab the
> client persistence code out of the tapestry source and inject a
> modified strategy into your app.  Assuming that I'm correct about the
> possibility of doing this, anyway.
>
> --sam

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


Re: Re: Re: Very long URLs problem.

Posted by Sam Gendler <sg...@ideasculptor.com>.
On 9/19/06, Martin Strand <ma...@entcap.se> wrote:
> The client persistence strategy doesn't use DataSqueezer:
> https://issues.apache.org/jira/browse/TAPESTRY-738
>

That's unfortunate.  I suppose one could persist them yourself using
hidden fields, at least in simple cases.  I just assumed that client
persistence would use the same mechanisms as putting an object in a
form.  I find it odd that it doesn't, really.  Actually, now that I
think about it, didn't I read somewhere that it is possible to
implement your own persistence strategies and tie them into tapestry
via hivemind? If so, in the worst case, I guess you could grab the
client persistence code out of the tapestry source and inject a
modified strategy into your app.  Assuming that I'm correct about the
possibility of doing this, anyway.

--sam

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


Re: Re: Very long URLs problem.

Posted by Martin Strand <ma...@entcap.se>.
The client persistence strategy doesn't use DataSqueezer:
https://issues.apache.org/jira/browse/TAPESTRY-738

On Tue, 19 Sep 2006 01:53:43 +0200, Sam Gendler <sg...@ideasculptor.com> wrote:

> Do a search in documentation for 'DataSqueezer.'  That should show you
> how to build service objects which know how to automatically persist
> classes via an id and re-instantiate them later, without any manual
> intervention from you. Anytime Tap has to persist an object in a URL,
> cookie, or form data, it will automatically use the appropriate
> squeezer to store just an id. In the case of contrib:Table, you can
> also use a PrimaryKeyConverter to accomplish the same thing.  Without
> these mechanisms, whenever tapestry persists an object that isn't a
> native type, it just serializes it and then binhexes it into a string,
> which generates some incredibly long strings.  This is a mechanism
> that you want to avoid at all costs.  Fortunately, it is easy to fix.
>
> --sam
>
>
> On 9/18/06, Leo Sakhvoruk <le...@gmail.com> wrote:
>> Thanks for the advice Martin. Seems to have fixed the problem however
>> I'll need to do some testing to make sure it's all gone.
>>
>> Martin Strand wrote:
>> > Sounds like you have rather large persistent properties.
>> >
>> > 1. You can try @Persist("client:page") to forget properties when the client moves to another page so they don't add up to 15k URLs. :)
>> >
>> > 2. If you don't really need @Persist("client") you can try @Persist("session") instead
>> >
>> > 3. Or, you can persist an object identifier rather than the whole object, ie
>> > @Persist("client:page")
>> > public abstract Long getId()
>> > instead of
>> > @Persist("client:page")
>> > public abstract Object getObject()
>> >
>> > Martin
>> >
>> > On Mon, 18 Sep 2006 17:31:04 +0200, Leo Sakhvoruk <le...@gmail.com> wrote:
>> >
>> >
>> >> Hi,
>> >>
>> >> I'm running into issues with Tapestry generating some seriously long
>> >> URLs (something around 15k characters).
>> >>
>> >> I have a page which generates a list of links using the simple "For"
>> >> construct, in the beginning the link URLs are about 2k chars long. Once
>> >> the link is clicked the user is taken to a different page if he/she
>> >> wants to return to the original page by clicking a page link the
>> >> original page is rendered again but now the link URLs are longer!!!
>> >> After a few iterations of this the browser simply can't send the request
>> >> because the URL is huge.
>> >>
>> >> What can I do? The links are generated using DirectLink.
>> >>
>> >> Any advice would be appreciated.
>> >>
>> >> Thanks
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> >> For additional commands, e-mail: users-help@tapestry.apache.org
>> >>
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> > For additional commands, e-mail: users-help@tapestry.apache.org
>> >
>> >
>> >
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



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


Re: Re: Very long URLs problem.

Posted by Sam Gendler <sg...@ideasculptor.com>.
Do a search in documentation for 'DataSqueezer.'  That should show you
how to build service objects which know how to automatically persist
classes via an id and re-instantiate them later, without any manual
intervention from you. Anytime Tap has to persist an object in a URL,
cookie, or form data, it will automatically use the appropriate
squeezer to store just an id. In the case of contrib:Table, you can
also use a PrimaryKeyConverter to accomplish the same thing.  Without
these mechanisms, whenever tapestry persists an object that isn't a
native type, it just serializes it and then binhexes it into a string,
which generates some incredibly long strings.  This is a mechanism
that you want to avoid at all costs.  Fortunately, it is easy to fix.

--sam


On 9/18/06, Leo Sakhvoruk <le...@gmail.com> wrote:
> Thanks for the advice Martin. Seems to have fixed the problem however
> I'll need to do some testing to make sure it's all gone.
>
> Martin Strand wrote:
> > Sounds like you have rather large persistent properties.
> >
> > 1. You can try @Persist("client:page") to forget properties when the client moves to another page so they don't add up to 15k URLs. :)
> >
> > 2. If you don't really need @Persist("client") you can try @Persist("session") instead
> >
> > 3. Or, you can persist an object identifier rather than the whole object, ie
> > @Persist("client:page")
> > public abstract Long getId()
> > instead of
> > @Persist("client:page")
> > public abstract Object getObject()
> >
> > Martin
> >
> > On Mon, 18 Sep 2006 17:31:04 +0200, Leo Sakhvoruk <le...@gmail.com> wrote:
> >
> >
> >> Hi,
> >>
> >> I'm running into issues with Tapestry generating some seriously long
> >> URLs (something around 15k characters).
> >>
> >> I have a page which generates a list of links using the simple "For"
> >> construct, in the beginning the link URLs are about 2k chars long. Once
> >> the link is clicked the user is taken to a different page if he/she
> >> wants to return to the original page by clicking a page link the
> >> original page is rendered again but now the link URLs are longer!!!
> >> After a few iterations of this the browser simply can't send the request
> >> because the URL is huge.
> >>
> >> What can I do? The links are generated using DirectLink.
> >>
> >> Any advice would be appreciated.
> >>
> >> Thanks
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
> >
>
>

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


Re: Very long URLs problem.

Posted by Leo Sakhvoruk <le...@gmail.com>.
Thanks for the advice Martin. Seems to have fixed the problem however 
I'll need to do some testing to make sure it's all gone.

Martin Strand wrote:
> Sounds like you have rather large persistent properties.
>
> 1. You can try @Persist("client:page") to forget properties when the client moves to another page so they don't add up to 15k URLs. :)
>
> 2. If you don't really need @Persist("client") you can try @Persist("session") instead
>
> 3. Or, you can persist an object identifier rather than the whole object, ie
> @Persist("client:page")
> public abstract Long getId()
> instead of
> @Persist("client:page")
> public abstract Object getObject()
>
> Martin
>
> On Mon, 18 Sep 2006 17:31:04 +0200, Leo Sakhvoruk <le...@gmail.com> wrote:
>
>   
>> Hi,
>>
>> I'm running into issues with Tapestry generating some seriously long
>> URLs (something around 15k characters).
>>
>> I have a page which generates a list of links using the simple "For"
>> construct, in the beginning the link URLs are about 2k chars long. Once
>> the link is clicked the user is taken to a different page if he/she
>> wants to return to the original page by clicking a page link the
>> original page is rendered again but now the link URLs are longer!!!
>> After a few iterations of this the browser simply can't send the request
>> because the URL is huge.
>>
>> What can I do? The links are generated using DirectLink.
>>
>> Any advice would be appreciated.
>>
>> Thanks
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>     
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
>   

Re: Very long URLs problem.

Posted by Martin Strand <ma...@entcap.se>.
Sounds like you have rather large persistent properties.

1. You can try @Persist("client:page") to forget properties when the client moves to another page so they don't add up to 15k URLs. :)

2. If you don't really need @Persist("client") you can try @Persist("session") instead

3. Or, you can persist an object identifier rather than the whole object, ie
@Persist("client:page")
public abstract Long getId()
instead of
@Persist("client:page")
public abstract Object getObject()

Martin

On Mon, 18 Sep 2006 17:31:04 +0200, Leo Sakhvoruk <le...@gmail.com> wrote:

> Hi,
>
> I'm running into issues with Tapestry generating some seriously long
> URLs (something around 15k characters).
>
> I have a page which generates a list of links using the simple "For"
> construct, in the beginning the link URLs are about 2k chars long. Once
> the link is clicked the user is taken to a different page if he/she
> wants to return to the original page by clicking a page link the
> original page is rendered again but now the link URLs are longer!!!
> After a few iterations of this the browser simply can't send the request
> because the URL is huge.
>
> What can I do? The links are generated using DirectLink.
>
> Any advice would be appreciated.
>
> Thanks
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org

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