cancel
Showing results for 
Search instead for 
Did you mean: 

Webscripts with searchengine friendly urls

flm
Champ in-the-making
Champ in-the-making
Hi,

I tried to implement a webscript with search engine friendly urls, i.e. parameters in as path elements. I couldn't make it work so a created a really simple example which still does not provide the parameter in the javascript:

testsefurl.get.desc.xml:
<webscript>
  <shortname>Test</shortname>
  <description>Test</description>
  <url>/test/{id}</url>
</webscript>

testsefurl.get.js:
model.result = args.id;

testsefurl.get.html.ftl:
<html>
<body>
${result}
</body>
</html>

Accessing http://localhost:8080/alfresco/service/test/1234 returns an error that the result is undefined - the problem is that the parameter is not passed to the args array in the javascript.

I am using the 2.9C nightly and I am wondering if I stumbled on a bug or if I missed some detail in the webscript definition.

Regards,
Florian
3 REPLIES 3

mikef
Champ in-the-making
Champ in-the-making
1234 is not an argument, its the url.extension

For this to work your Javascript should read:

model.result = url.extension;


See http://wiki.alfresco.com/wiki/Web_Scripts#url

flm
Champ in-the-making
Champ in-the-making
Ok thanks, now I understand how the matching works. So only the part of the url up to the first parameter is used to match the webscript, everything else becomes the extension. And only the url parameters after the "?" separator are parsed into the args array.

That also means that it's not possible to create two separate scripts for these two urls:

test/{id}/show
test/{id}/edit

Whichever script is registered first will be called in both cases. I don't need that right now but I somehow expected that it would work.

davidc
Star Contributor
Star Contributor
You wouldn't be able to register those two urls.  As they wouldn't be considered unique.

That kind of mapping is something we're considering.
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.