It might have something to do with changes to the behavior of getServletPath() (which I had an argument with uncharacteristically grumpy HLS about on JIRA). Try add this:

    String fullServletPath = encoding.getServletPath()
        + StringUtils.defaultString(encoding.getPathInfo());

...then replace occurrences of encoding.getServletPath() with this fullServletPath variable. That might help.

Of course, without a description of the error you're getting, it's hard to know.

Cheers,

Paul

On Dec 20, 2005, at 4:54 AM, jone wrote:

Hi,all
I'd like to implement my own ServiceEncoder to make friendly url,In my
hivemind.xml,you can see:
....
<service-point id="ExternalEncoder"
interface="org.apache.tapestry.engine.ServiceEncoder">
        <invoke-factory>
<construct class="com.test.tapestry.services.PageServiceEncoder">
                <set property="serviceName" value="external"/>
                <set property="extension" value="page"/>
  </construct>
        </invoke-factory>
    </service-point>
.....
  <contribution configuration-id="tapestry.url.ServiceEncoders">
<encoder id="external" object="service:ExternalEncoder"/>
............
    </contribution>

This can work well in tapestry beta-10 or early version,but from beta-11 or
even RC2,I CANNOT do it successfully.
Following is the code for beta-11,it can generate friendly url,but problem
always exits when submitting form!

Could anybody help me?thanks in advance.


code:

public class PageServiceEncoder implements ServiceEncoder {

    private String _extension;
    private String _serviceName;

    public void encode(ServiceEncoding encoding) {
String service = encoding.getParameterValue (ServiceConstants.SERVICE);
        if (!service.equals(_serviceName))
            return;
String pageName = encoding.getParameterValue (ServiceConstants.PAGE);
        if (pageName.indexOf(INamespace.SEPARATOR) >= 0)
            return;
StringBuffer buffer = new StringBuffer (encoding.getServletPath()).append
(pageName.substring(pageName.indexOf('/')))
                .append('.').append(_extension);
        encoding.setServletPath(buffer.toString());
        encoding.setParameterValue(ServiceConstants.SERVICE, null);
        encoding.setParameterValue(ServiceConstants.PAGE, null);
    }

    public void decode(ServiceEncoding encoding) {
        String servletPath = encoding.getServletPath();
        int dotx = servletPath.lastIndexOf('.');
        if (dotx < 0)
            return;
        String extension = servletPath.substring(dotx + 1);
        if (!extension.equals(_extension))
            return;
        String page = new StringBuffer(50).append("test").append
(servletPath.substring(servletPath.indexOf('/', 1), dotx)).toString();
encoding.setParameterValue(ServiceConstants.SERVICE, _serviceName);
        encoding.setParameterValue(ServiceConstants.PAGE, page);
    }

    public void setExtension(String extension) {
        _extension = extension;
    }

    public void setServiceName(String serviceName) {
        _serviceName = serviceName;
    }
}










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



_________________________________________________________________
Piano music podcast: http://inthehands.com
Other interesting stuff: http://innig.net



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

Reply via email to