cancel
Showing results for 
Search instead for 
Did you mean: 

Relative links in html pages

markus_kuehn
Champ in-the-making
Champ in-the-making
Hello,

when I access a html document in alfresco it is displayed in a new tab/window with an url like:

      
alfresco/d/d/workspace/SpacesStore/67d865e4-6402-11dd-9b94-51e5a45d1e35/A.html

Clicking on a relative link with 'href="B.html"' results in the url:

      
alfresco/d/d/workspace/SpacesStore/67d865e4-6402-11dd-9b94-51e5a45d1e35/B.html

which opens the document A.html again, instead of the B.html.

How could I make relative links in html pages work?

Thanks.
4 REPLIES 4

samall
Champ in-the-making
Champ in-the-making
Yes, you have to use the webdav link or CIFS.

pmonks
Star Contributor
Star Contributor
There was some discussion internally around using the /api/path Web Script instead of the download servlet when the user clicks on a file.  This solves the problem (for relative links only, of course) by ensuring that any subsequent path based requests initiated by the browser resolve correctly.

I could have sworn there was a ticket in JIRA (http://issues.alfresco.com/) for this, but I couldn't find it just now.  Could I ask you to raise this again then post the link back here so that we can all vote / comment on it?

Thanks!
Peter

markus_kuehn
Champ in-the-making
Champ in-the-making
Thanks for the input.

I found a way by using the suggested webdav-url for the documents in the web client. So now I can open html documents from within the alfresco web client and browse to other html documents of the repository by using relative links within the html documents.

For other developers interested in this:

Add to/change

BrowseBean.java:



   public void setupCommonBindingProperties(Node node)
   {
      // special properties to be used by the value binding components on the page
      node.addPropertyResolver("url", this.resolverUrl);
      node.addPropertyResolver("target", this.targetResolver);
      node.addPropertyResolver("webdavUrl", this.resolverWebdavUrl);
      node.addPropertyResolver("webdavWithTicketUrl", this.resolverWebdavWithTicketUrl);
      node.addPropertyResolver("cifsPath", this.resolverCifsPath);
      node.addPropertyResolver("fileType16", this.resolverFileType16);
      node.addPropertyResolver("fileType32", this.resolverFileType32);
      node.addPropertyResolver("size", this.resolverSize);
      node.addPropertyResolver("lang", this.resolverLang);
   }

   public NodePropertyResolver resolverWebdavWithTicketUrl = new NodePropertyResolver() {
         public Object get(Node node) {
            HttpSession session = (HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(false);
            User user = (User)session.getAttribute(AuthenticationHelper.AUTHENTICATION_USER);
            return Utils.generateURL(FacesContext.getCurrentInstance(), node, URLMode.WEBDAV) + "?ticket=" + user.getTicket();
         }
   };

browse.jsp: (only for the icons view mode)


                           <%– Primary column for icons view mode –%>
                           <a:column id="col11" primary="true" style="padding:2px;text-align:left;vertical-align:top;" rendered="#{BrowseBean.browseViewMode == 'icons'}">
                              <f:facet name="large-icon">
                                 <a:actionLink id="col11-act1" value="#{r.name}" href="#{r.webdavWithTicketUrl}" target="#{r.target}" image="#{r.fileType32}" showLink="false" styleClass="inlineAction" />
                              </f:facet>
                              <a:actionLink id="col11-act2" value="#{r.name}" href="#{r.webdavWithTicketUrl}" target="#{r.target}" styleClass="header" />
                              <r:lockIcon id="col11-lock" value="#{r.nodeRef}" align="absmiddle" />
                              <h:outputLabel id="col11-lang" value="#{r.lang}" styleClass="langCode" rendered="#{r.lang != null}"/>
                              <r:nodeInfo id="col11-info" value="#{r.id}">
                                 <h:graphicImage id="col11-img" url="/images/icons/popup.gif" styleClass="popupImage" width="16" height="16" />
                              </r:nodeInfo>
                           </a:column>

markus_kuehn
Champ in-the-making
Champ in-the-making
I opened a JIRA issue (https://issues.alfresco.com/jira/browse/ALFCOM-1866) and added a link to this topic.