Access global and resource type specific data from a resource type

If you need to access global or resource type specific data (e.g. images, javascript, css etc.) from within your resource-type, then you can place it either in webapps/yanel/htdocs (global) or in MY-RESOURCE_TYPE/htdocs (resource type specific).

To access the data there are two helper methods in org.wyona.yanel.core.util.PathUtil:

Resource type specific:

getResourcesHtdocsPathURLencoded(Resource resource)

for example:

sb.append("<script src=\"" + PathUtil.getResourcesHtdocsPathURLencoded(this) + "js/ajaxlookup.js\" type=\"text/javascript\"></script>");

will generate:

<script src="BACK2REALM/yanel/resource-types/" type=\"text/javascript\"></script>

whereas BACK2REALM denotes the path back to the realm root and "yanel" is the reserved prefix (configured within web.xml) and for example the file js/ajaxlookup.js is located at MY-RESOURCE_TYPE/htdocs/js/ajaxlookup.js (and for example the file RESERVED_PREFIX/js/ajaxlookup.js would be located at MY-RESOURCE_TYPE/yanel-htdocs/js/ajaxlookup.js)

(Please note that the method getResourcesHtdocsPath(Resource) is deprecated!)


getGlobalHtdocsPath(Resource resource)

for example:

sb.append("<script src=\"" + PathUtil.getGlobalHtdocsPath(this) + "yanel-js/prototype.js\" type=\"text/javascript\"></script>");

will generate:

<script src="BACK2REALM/yanel/yanel-js/prototype.js" type=\"text/javascript\"></script>

Your comments are much appreciated

Is the content of this page unclear or you think it could be improved? Please add a comment and we will try to improve it accordingly.