Set pageBaseUrl using Java and a VariableResolver


import com.ibm.xsp.util.FacesUtil;
import javax.faces.context.FacesContext;

return FacesUtil.makeUrlAbsolute(FacesContext.getCurrentInstance(),
			context.getExternalContext().getRequestContextPath())+"/";

You can use the code in a variableResolver: (http://openntf.org/XSnippets.nsf/snippet.xsp?id=sample-variableresolver)

if ("getBaseURL".equals(name)) {
			return FacesUtil.makeUrlAbsolute(FacesContext.getCurrentInstance(),
					context.getExternalContext().getRequestContextPath())+"/";
}

In your XPage, you can then access the variable:

	<xp:this.pageBaseUrl>
		<xp:baseUrl href="#{getBaseURL}"></xp:baseUrl>
	</xp:this.pageBaseUrl>
All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.
No comments yetLogin first to comment...