Re: Keeping the original url after submit

2006-07-17 Thread Blackwings

I think there is another solution more simple and handle by Tapestry. I
think you can declare a page "version" as accessible directly from outside
using a static URL and Tapestry serialize the page as a static page.

Check this page :
http://tapestry.apache.org/tapestry4/tapestry/ComponentReference/ExternalLink.html

2006/7/17, Firas A. <[EMAIL PROTECTED]>:


I got it!

But the solution is rather low-level.

First, I had to modify my form listener to return an ILink:
public ILink onSubmit()

Then, I had to create the ILink using LinkFactoryImpl:

@InjectObject("service:tapestry.globals.WebRequest")
public abstract WebRequest getWebRequest();

@InjectObject("engine-service:direct")
public abstract IEngineService getService();

// Somewhere in the page class:
Map params = new HashMap(1);
params.put(ServiceConstants.PARAMETER,
getRequestCycle().getListenerParameters());
LinkFactoryImpl linkFactory = new LinkFactoryImpl();
DataSqueezerImpl dataSqueezer = new DataSqueezerImpl();
dataSqueezer.register(new StringAdaptor());
linkFactory.setDataSqueezer(dataSqueezer);
linkFactory.setContributions(Collections.EMPTY_LIST);
linkFactory.setContextPath(getWebRequest().getContextPath());
ErrorLog errorLog = new ErrorLogImpl(new DefaultErrorHandler(), LogFactory
.getLog(MyPageClass.class));
linkFactory.setErrorLog(errorLog);
linkFactory.setRequest(getWebRequest());
linkFactory.setRequestCycle(getRequestCycle());
linkFactory.setServletPath(getWebRequest().getActivationPath());
linkFactory.initializeService();
ILink iLink = linkFactory.constructLink(getService(), false, params,
false);


That was a lot of code don't you think?

But here's a question: how do you make sure this 'original' ILink is not
lost/overridden betwing requests, especially if your page uses validators?
I
found a solution for that too. If you need help with this, drop me a line
and I'll gladly help.

Regards!




RE: Keeping the original url after submit

2006-07-17 Thread Firas A.
I got it!
 
But the solution is rather low-level.
 
First, I had to modify my form listener to return an ILink:
public ILink onSubmit()
 
Then, I had to create the ILink using LinkFactoryImpl:
 
@InjectObject("service:tapestry.globals.WebRequest")
public abstract WebRequest getWebRequest();
 
@InjectObject("engine-service:direct")
public abstract IEngineService getService();
 
// Somewhere in the page class:
Map params = new HashMap(1);
params.put(ServiceConstants.PARAMETER,
getRequestCycle().getListenerParameters());
LinkFactoryImpl linkFactory = new LinkFactoryImpl();
DataSqueezerImpl dataSqueezer = new DataSqueezerImpl();
dataSqueezer.register(new StringAdaptor());
linkFactory.setDataSqueezer(dataSqueezer);
linkFactory.setContributions(Collections.EMPTY_LIST);
linkFactory.setContextPath(getWebRequest().getContextPath());
ErrorLog errorLog = new ErrorLogImpl(new DefaultErrorHandler(), LogFactory
.getLog(MyPageClass.class));
linkFactory.setErrorLog(errorLog);
linkFactory.setRequest(getWebRequest());
linkFactory.setRequestCycle(getRequestCycle());
linkFactory.setServletPath(getWebRequest().getActivationPath());
linkFactory.initializeService();
ILink iLink = linkFactory.constructLink(getService(), false, params, false);
 
 
That was a lot of code don't you think?
 
But here's a question: how do you make sure this 'original' ILink is not
lost/overridden betwing requests, especially if your page uses validators? I
found a solution for that too. If you need help with this, drop me a line
and I'll gladly help.
 
Regards!