[ 
https://issues.apache.org/jira/browse/TAPESTRY-1462?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12495927
 ] 

Christian Haselbach commented on TAPESTRY-1462:
-----------------------------------------------

Workaround if you need to construct the link according to the correct context 
path of the request (and not the very first request that ever happened since 
the start of the application):
Create a new class which is a copy of LinkFactoryImpl and replace the method 
constructLink():
---
    public ILink constructLink(IEngineService service, boolean post, Map 
parameters,
            boolean stateful)
    {
        finalizeParameters(service, parameters);

        IEngine engine = _requestCycle.getEngine();

        ServiceEncoding serviceEncoding = createServiceEncoding(parameters);

        // Give persistent property strategies a chance to store extra data
        // into the link.

        if (stateful)
            
_persistenceStrategySource.addParametersForPersistentProperties(serviceEncoding,
 post);

        String contextPath = _request.getContextPath();
        String fullServletPath = contextPath + serviceEncoding.getServletPath();

        return new EngineServiceLink(_requestCycle, fullServletPath, 
engine.getOutputEncoding(),
                _codec, _request, parameters, stateful);
    }
---
Furthermore, remove the method finalizeParameters(), because it uses a class 
that is not public (ImplMessages).

Then register it in your hivemodule.xml:
  <implementation service-id="tapestry.url.LinkFactory">
  <invoke-factory service-id="hivemind.BuilderFactory" model="singleton" >
    <construct class="your.path.AlternativeLinkFactoryImpl" >
      <set-object property="dataSqueezer" value="infrastructure:dataSqueezer" 
/> 
      <set-configuration property="contributions" 
configuration-id="tapestry.url.ServiceEncoders" /> 
      <set-object property="servletPath" 
value="app-property:org.apache.tapestry.servlet-path" /> 
      <set-object property="contextPath" value="infrastructure:contextPath" /> 
      <set-object property="request" value="infrastructure:request" /> 
      <set-object property="requestCycle" value="infrastructure:requestCycle" 
/> 
      <set-service property="persistenceStrategySource" 
service-id="tapestry.persist.PropertyPersistenceStrategySource" />
    </construct>
  </invoke-factory>
  </implementation>


> LinkFactoryImpl caches context path and servlet path
> ----------------------------------------------------
>
>                 Key: TAPESTRY-1462
>                 URL: https://issues.apache.org/jira/browse/TAPESTRY-1462
>             Project: Tapestry
>          Issue Type: Bug
>    Affects Versions: 4.0, 4.1
>            Reporter: Christian Haselbach
>            Priority: Minor
>
> The class org.apache.tapestry.services.impl.LinkFactoryImpl caches the 
> context path and the servlet path, two values that can differ for every 
> request.
> The class has the web request injected and should use the values from there.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to