# This patch file was generated by NetBeans IDE # It uses platform neutral UTF-8 encoding and \n newlines. --- Base (BASE) +++ Locally Modified (Based On LOCAL) @@ -56,7 +56,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; - /** * Utility tag which can be used to print out a link based on the value of a node data or tries to find the first page * with a specific template name, starting from a specific page. @@ -73,38 +72,37 @@ * Stable serialVersionUID. */ private static final long serialVersionUID = 222L; - /** * Logger. */ private static Logger log = LoggerFactory.getLogger(AHref.class); - /** * href part that is added before the nodeData content. */ private String preHref; - /** * href part that is added after the nodeData content. */ private String postHref; - /** * level from where to start the template search. */ private int level; - /** * template name to search for. */ private String templateName; - /** * name of nodeData to evaluate. */ private String nodeDataName; - /** + * An extension to force instead of using default one ServerConfiguration.getInstance().getDefaultExtension() + * + * @see ServerConfiguration + */ + private String extension; + /** * link attributes, added using child tags. */ private transient List attributes; @@ -127,6 +125,16 @@ } /** + * Set extension to enforce. If not set server wide default will be used, most likely ".html" + * @param extensionToForce null value makes use of default extension + * @see ServerConfiguration + * @jsp.attribute required="false" rtexprvalue="true" + */ + public void setExtension(String extensionToForce) { + this.extension = extensionToForce; + } + + /** * href part that is added before the nodeData content. * @jsp.attribute required="false" rtexprvalue="true" */ @@ -174,6 +182,7 @@ /** * @see javax.servlet.jsp.tagext.Tag#doEndTag() */ + @Override public int doEndTag() { if (StringUtils.isEmpty(this.templateName)) { if (this.nodeDataName == null) { @@ -199,21 +208,18 @@ if (type == PropertyType.STRING) { if (StringUtils.isEmpty(nodeData.getString())) { this.writeLink(StringUtils.EMPTY); - } - else { + } else { this.writeLink(nodeData.getString()); } } - } - else { + } else { Content startPage; try { startPage = Resource.getCurrentActivePage().getAncestor(this.level); HierarchyManager hm = MgnlContext.getHierarchyManager(ContentRepository.WEBSITE); Content resultPage = hm.getPage(startPage.getHandle(), this.templateName); this.writeLink(resultPage.getHandle()); - } - catch (RepositoryException e) { + } catch (RepositoryException e) { log.error(e.getMessage()); this.writeLink(StringUtils.EMPTY); } @@ -237,7 +243,7 @@ out.print(path); if (MgnlContext.getHierarchyManager(ContentRepository.WEBSITE).isPage(path)) { out.print("."); //$NON-NLS-1$ - out.print(ServerConfiguration.getInstance().getDefaultExtension()); + out.print(extension == null ? ServerConfiguration.getInstance().getDefaultExtension() : extension); } if (this.postHref != null) { out.print(this.postHref); @@ -260,11 +266,9 @@ if (StringUtils.isNotEmpty(path)) { out.print(""); //$NON-NLS-1$ } - } - catch (RepositoryException e) { + } catch (RepositoryException e) { log.error(e.getMessage(), e); - } - catch (IOException e) { + } catch (IOException e) { throw new NestableRuntimeException(e); } attributes = null; @@ -282,5 +286,4 @@ this.attributes = null; super.release(); } - }