You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jamie Orchard-Hays <ja...@dang.com> on 2005/01/20 03:51:03 UTC
friend URLs and Reset service
I've been using Friendly URLs with 3.01 for a while. However, today I
decided to setup a link for resetting the service as Richard Lewis-Shell
suggested. When I click on my link, I get:
Service reset requires exactly one service parameter.
with a trace of:
a.. org.apache.tapestry.engine.ResetService.service(ResetService.java:71)
a..
org.apache.tapestry.engine.AbstractEngine.service(AbstractEngine.java:872)
a..
org.apache.tapestry.ApplicationServlet.doService(ApplicationServlet.java:197)
a..
org.apache.tapestry.ApplicationServlet.doGet(ApplicationServlet.java:158)
a.. javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
a.. javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
a.. jrun.servlet.FilterChain.doFilter(FilterChain.java:86)
a..
jrun.servlet.security.JSecurityCheckFilter.doFilter(JSecurityCheckFilter.java:70)
a.. jrun.servlet.FilterChain.doFilter(FilterChain.java:94)
a.. jrun.servlet.FilterChain.service(FilterChain.java:1
URL is: http://localhost:8160/registrar-student/reset.svc
Has anyone else encountered this problem or else had success?
Thanks,
Jamie
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: friend URLs and Reset service
Posted by Jamie Orchard-Hays <ja...@dang.com>.
Thanks for that Paul. Once I remembered to add the servlet path to web.xml,
all works.
Jamie
----- Original Message -----
From: "Paul Ferraro" <pm...@columbia.edu>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Thursday, January 20, 2005 3:02 AM
Subject: Re: friend URLs and Reset service
> Sigh - good catch guys... The reset service code was basically
> copied/pasted from the restart service code - and the page parameter was
> overlooked. Here's the fix:
>
> Since the reset service is page based, the url for a reset request for the
> page "path/mypage" should ideally look like:
>
> http://localhost/path/mypage.reset
>
> To do this properly requires a few changes...
>
> 1.) A new application property to define the reset service suffix:
>
> <application name="MyApplication" engine-class="com.mycompany.BaseEngine">
> <property name="org.apache.tapestry.reset-url-suffix"
> value=".reset"></property>
> <!-- ... --> </application>
>
> 2. Update to BaseEngine
>
> public class BaseEngine extends org.apache.tapestry.engine.BaseEngine
> {
> public static final String SERVICE_URL_SUFFIX =
> "org.apache.tapestry.service-url-suffix";
> public static final String PAGE_URL_SUFFIX =
> "org.apache.tapestry.page-url-suffix";
> // New
> public static final String RESET_URL_SUFFIX =
> "org.apache.tapestry.reset-url-suffix";
> // End new /**
> * @see
> org.apache.tapestry.engine.AbstractEngine#extractServiceName(org.apache.tapestry.request.RequestContext)
> */
> protected String extractServiceName(RequestContext requestContext)
> {
> String[] serviceContext =
> requestContext.getParameters(Tapestry.SERVICE_QUERY_PARAMETER_NAME);
> if
> (requestContext.getRequest().getParameter(Tapestry.TAG_SUPPORT_SERVICE_ATTRIBUTE)
> != null)
> {
> return Tapestry.TAGSUPPORT_SERVICE;
> }
>
> String servletPath = requestContext.getRequest().getServletPath();
> IApplicationSpecification specification = this.getSpecification();
> String pageUrlSuffix = specification.getProperty(PAGE_URL_SUFFIX);
> if (servletPath.endsWith(pageUrlSuffix))
> {
> if ((serviceContext == null) || (serviceContext.length == 0))
> {
> if
> (requestContext.getRequest().getParameter(Tapestry.PARAMETERS_QUERY_PARAMETER_NAME)
> == null)
> {
> return Tapestry.PAGE_SERVICE;
> }
> return Tapestry.EXTERNAL_SERVICE;
> }
> return serviceContext[0];
> }
> String serviceUrlSuffix =
> specification.getProperty(SERVICE_URL_SUFFIX);
> if (servletPath.endsWith(serviceUrlSuffix))
> {
> return servletPath.substring(1,
> servletPath.indexOf(serviceUrlSuffix));
> }
> // New
> String resetUrlSuffix =
> specification.getProperty(RESET_URL_SUFFIX);
>
> if (servletPath.endsWith(resetUrlSuffix))
> {
> return Tapestry.RESET_SERVICE;
> }
> // End new throw new ApplicationRuntimeException("Invalid request:
> " + requestContext.getRequest().getRequestURL());
> }
> }
>
> 3. Update to the overridden ResetService class:
>
> public class ResetService extends org.apache.tapestry.engine.ResetService
> {
> /**
> * @see
> org.apache.tapestry.engine.IEngineService#getLink(org.apache.tapestry.IRequestCycle,
> org.apache.tapestry.IComponent, java.lang.Object[])
> */
> public ILink getLink(IRequestCycle requestCycle, IComponent component,
> Object[] parameters)
> {
> if (Tapestry.size(parameters) != 1)
> {
> throw new
> IllegalArgumentException(Tapestry.format("service-single-parameter",
> Tapestry.RESET_SERVICE));
> }
>
> String page = (String) parameters[0];
> String suffix =
> requestCycle.getEngine().getSpecification().getProperty(BaseEngine.RESET_URL_SUFFIX);
> return new Link(requestCycle, page + suffix, null, null);
> }
> /**
> * @see
> org.apache.tapestry.engine.AbstractService#getServiceContext(org.apache.tapestry.request.RequestContext)
> */
> protected String[] getServiceContext(RequestContext requestContext)
> {
> IApplicationSpecification specification =
> requestContext.getServlet().getApplicationSpecification();
> String urlSuffix =
> specification.getProperty(BaseEngine.RESET_URL_SUFFIX);
> String servletPath = requestContext.getRequest().getServletPath();
>
> return new String[] { servletPath.substring(1,
> servletPath.indexOf(urlSuffix)) };
> }
> }
>
> I'll update the wiki in the morning...
>
> Paul
>
> Richard Lewis-Shell wrote:
>
>> I am not familiar with the friendly URL changes, but the reset service
>> requires a page name parameter. For me, withOUT friendly URLs, this
>> *just works*:
>> <a jwcid="@ServiceLink" service="reset"
>> disabled="ognl:!page.engine.resetServiceEnabled">reset</a>
>>
>> Without looking at the reset service code, I suspect that it generates
>> links with the current page name automatically.
>>
>> Perhaps you just need to get the parameters 'translated' through the
>> friendliness somehow?
>>
>> Richard
>>
>> Jamie Orchard-Hays wrote:
>>
>>> I've been using Friendly URLs with 3.01 for a while. However, today I
>>> decided to setup a link for resetting the service as Richard Lewis-Shell
>>> suggested. When I click on my link, I get:
>>>
>>> Service reset requires exactly one service parameter.
>>>
>>> with a trace of:
>>>
>>> a..
>>> org.apache.tapestry.engine.ResetService.service(ResetService.java:71)
>>> a..
>>> org.apache.tapestry.engine.AbstractEngine.service(AbstractEngine.java:872)
>>> a..
>>> org.apache.tapestry.ApplicationServlet.doService(ApplicationServlet.java:197)
>>> a..
>>> org.apache.tapestry.ApplicationServlet.doGet(ApplicationServlet.java:158)
>>> a.. javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
>>> a.. javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>>> a.. jrun.servlet.FilterChain.doFilter(FilterChain.java:86)
>>> a..
>>> jrun.servlet.security.JSecurityCheckFilter.doFilter(JSecurityCheckFilter.java:70)
>>> a.. jrun.servlet.FilterChain.doFilter(FilterChain.java:94)
>>> a.. jrun.servlet.FilterChain.service(FilterChain.java:1
>>>
>>> URL is: http://localhost:8160/registrar-student/reset.svc
>>>
>>> Has anyone else encountered this problem or else had success?
>>>
>>> Thanks,
>>> Jamie
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>
>
> ---------------------------------------------------------------------
> 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: friend URLs and Reset service
Posted by Paul Ferraro <pm...@columbia.edu>.
Sigh - good catch guys... The reset service code was basically
copied/pasted from the restart service code - and the page parameter was
overlooked. Here's the fix:
Since the reset service is page based, the url for a reset request for
the page "path/mypage" should ideally look like:
http://localhost/path/mypage.reset
To do this properly requires a few changes...
1.) A new application property to define the reset service suffix:
<application name="MyApplication" engine-class="com.mycompany.BaseEngine">
<property name="org.apache.tapestry.reset-url-suffix" value=".reset"></property>
<!-- ... -->
</application>
2. Update to BaseEngine
public class BaseEngine extends org.apache.tapestry.engine.BaseEngine
{
public static final String SERVICE_URL_SUFFIX = "org.apache.tapestry.service-url-suffix";
public static final String PAGE_URL_SUFFIX = "org.apache.tapestry.page-url-suffix";
// New
public static final String RESET_URL_SUFFIX = "org.apache.tapestry.reset-url-suffix";
// End new
/**
* @see org.apache.tapestry.engine.AbstractEngine#extractServiceName(org.apache.tapestry.request.RequestContext)
*/
protected String extractServiceName(RequestContext requestContext)
{
String[] serviceContext = requestContext.getParameters(Tapestry.SERVICE_QUERY_PARAMETER_NAME);
if (requestContext.getRequest().getParameter(Tapestry.TAG_SUPPORT_SERVICE_ATTRIBUTE) != null)
{
return Tapestry.TAGSUPPORT_SERVICE;
}
String servletPath = requestContext.getRequest().getServletPath();
IApplicationSpecification specification = this.getSpecification();
String pageUrlSuffix = specification.getProperty(PAGE_URL_SUFFIX);
if (servletPath.endsWith(pageUrlSuffix))
{
if ((serviceContext == null) || (serviceContext.length == 0))
{
if (requestContext.getRequest().getParameter(Tapestry.PARAMETERS_QUERY_PARAMETER_NAME) == null)
{
return Tapestry.PAGE_SERVICE;
}
return Tapestry.EXTERNAL_SERVICE;
}
return serviceContext[0];
}
String serviceUrlSuffix = specification.getProperty(SERVICE_URL_SUFFIX);
if (servletPath.endsWith(serviceUrlSuffix))
{
return servletPath.substring(1, servletPath.indexOf(serviceUrlSuffix));
}
// New
String resetUrlSuffix = specification.getProperty(RESET_URL_SUFFIX);
if (servletPath.endsWith(resetUrlSuffix))
{
return Tapestry.RESET_SERVICE;
}
// End new
throw new ApplicationRuntimeException("Invalid request: " + requestContext.getRequest().getRequestURL());
}
}
3. Update to the overridden ResetService class:
public class ResetService extends org.apache.tapestry.engine.ResetService
{
/**
* @see org.apache.tapestry.engine.IEngineService#getLink(org.apache.tapestry.IRequestCycle, org.apache.tapestry.IComponent, java.lang.Object[])
*/
public ILink getLink(IRequestCycle requestCycle, IComponent component, Object[] parameters)
{
if (Tapestry.size(parameters) != 1)
{
throw new IllegalArgumentException(Tapestry.format("service-single-parameter", Tapestry.RESET_SERVICE));
}
String page = (String) parameters[0];
String suffix = requestCycle.getEngine().getSpecification().getProperty(BaseEngine.RESET_URL_SUFFIX);
return new Link(requestCycle, page + suffix, null, null);
}
/**
* @see org.apache.tapestry.engine.AbstractService#getServiceContext(org.apache.tapestry.request.RequestContext)
*/
protected String[] getServiceContext(RequestContext requestContext)
{
IApplicationSpecification specification = requestContext.getServlet().getApplicationSpecification();
String urlSuffix = specification.getProperty(BaseEngine.RESET_URL_SUFFIX);
String servletPath = requestContext.getRequest().getServletPath();
return new String[] { servletPath.substring(1, servletPath.indexOf(urlSuffix)) };
}
}
I'll update the wiki in the morning...
Paul
Richard Lewis-Shell wrote:
> I am not familiar with the friendly URL changes, but the reset service
> requires a page name parameter. For me, withOUT friendly URLs, this
> *just works*:
> <a jwcid="@ServiceLink" service="reset"
> disabled="ognl:!page.engine.resetServiceEnabled">reset</a>
>
> Without looking at the reset service code, I suspect that it generates
> links with the current page name automatically.
>
> Perhaps you just need to get the parameters 'translated' through the
> friendliness somehow?
>
> Richard
>
> Jamie Orchard-Hays wrote:
>
>> I've been using Friendly URLs with 3.01 for a while. However, today I
>> decided to setup a link for resetting the service as Richard
>> Lewis-Shell suggested. When I click on my link, I get:
>>
>> Service reset requires exactly one service parameter.
>>
>> with a trace of:
>>
>> a..
>> org.apache.tapestry.engine.ResetService.service(ResetService.java:71)
>> a..
>> org.apache.tapestry.engine.AbstractEngine.service(AbstractEngine.java:872)
>>
>> a..
>> org.apache.tapestry.ApplicationServlet.doService(ApplicationServlet.java:197)
>>
>> a..
>> org.apache.tapestry.ApplicationServlet.doGet(ApplicationServlet.java:158)
>>
>> a.. javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
>> a.. javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>> a.. jrun.servlet.FilterChain.doFilter(FilterChain.java:86)
>> a..
>> jrun.servlet.security.JSecurityCheckFilter.doFilter(JSecurityCheckFilter.java:70)
>>
>> a.. jrun.servlet.FilterChain.doFilter(FilterChain.java:94)
>> a.. jrun.servlet.FilterChain.service(FilterChain.java:1
>>
>> URL is: http://localhost:8160/registrar-student/reset.svc
>>
>> Has anyone else encountered this problem or else had success?
>>
>> Thanks,
>> Jamie
>>
>> ---------------------------------------------------------------------
>> 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
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: friend URLs and Reset service
Posted by Richard Lewis-Shell <rl...@mac.com>.
I am not familiar with the friendly URL changes, but the reset service
requires a page name parameter. For me, withOUT friendly URLs, this
*just works*:
<a jwcid="@ServiceLink" service="reset"
disabled="ognl:!page.engine.resetServiceEnabled">reset</a>
Without looking at the reset service code, I suspect that it generates
links with the current page name automatically.
Perhaps you just need to get the parameters 'translated' through the
friendliness somehow?
Richard
Jamie Orchard-Hays wrote:
> I've been using Friendly URLs with 3.01 for a while. However, today I
> decided to setup a link for resetting the service as Richard Lewis-Shell
> suggested. When I click on my link, I get:
>
> Service reset requires exactly one service parameter.
>
> with a trace of:
>
> a.. org.apache.tapestry.engine.ResetService.service(ResetService.java:71)
> a..
> org.apache.tapestry.engine.AbstractEngine.service(AbstractEngine.java:872)
> a..
> org.apache.tapestry.ApplicationServlet.doService(ApplicationServlet.java:197)
>
> a..
> org.apache.tapestry.ApplicationServlet.doGet(ApplicationServlet.java:158)
> a.. javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
> a.. javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> a.. jrun.servlet.FilterChain.doFilter(FilterChain.java:86)
> a..
> jrun.servlet.security.JSecurityCheckFilter.doFilter(JSecurityCheckFilter.java:70)
>
> a.. jrun.servlet.FilterChain.doFilter(FilterChain.java:94)
> a.. jrun.servlet.FilterChain.service(FilterChain.java:1
>
> URL is: http://localhost:8160/registrar-student/reset.svc
>
> Has anyone else encountered this problem or else had success?
>
> Thanks,
> Jamie
>
> ---------------------------------------------------------------------
> 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