on 2014 Feb 21 2:23 AM
hi Guys,
I'm a starter of SAP UI5. I created a ui5 project using the eclipse project wizard.
In the index.html file, there's the bootstrap in the red box:
My question is: where's this resources folder? I looked all over the project structure, I didn't find a clue.
Could you tell me how does this line of code links to the sap-ui-core.js in detail?
Thanks !!
Hi there,
is this a local project?
The path "src=''resources/sap-ui-core.js" means that the file sap-ui-core.js is in the directory resources RELATIVE to the file (usually index.html) where you include it.
That means if your project folder is
c:\projects\project1\
the file sap-ui-core.js should be located in the folder
c:\projecty\project1\resources\
So you can either copy the sapui5 framwork there, or you change the path accordingly to the location of the framework.
Greets,
ben
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your reply Ben.
I just checked my project folder, but i couldn't find this file nor the resource folder:
I also searched my computer for this file and i only found this 2 locations:
(1) H:\Documents\workspace\.metadata\.plugins\org.eclipse.wst.jsdt.core\sapui5\sap.ui.core.js
(2) C:\Program Files (x86)\eclipse\configuration\org.eclipse.osgi\bundles\1246\1\.cp\libraries\sap.ui.core.js
But there was also one strange address:
http://localhost:49772/ZUI5_LIEF_APP/resources/sap-ui-core.js
This seems to be the right one. At least there is resource folder, but i cant access it.
Any ideas?
Regards Chris
Thanks Deepali for your answer. Yes that the file i was looking for, I also found it, but thats not solving my problem.
I want to know how this file is connected with the bootstrap "resources/sap-ui-core.js". There is no resource folder at all! It has to be linked somehow, but where and how?
Background:
I am trying to understand this article:
Its about how to register resources in different locations.
It says:
"The component and all its resources, the components, views, controllers, controls, css files, JavaScript modules, and so on, can be located in different locations (paths and web applications) and not directly under the default application root, for example index.html. By default, SAPUI5 tries to load the resources relative to the location where thesap-ui-core.jsbootstrap is located.
But where is thissap-ui-core.jslocated???
Regards
Chris
Hi Christoph,
sorry, I don't really understand you issue...
the sap-ui-core.js could be located everywhere - It could be, for example, on your local machine, on your AWS instance or you load it directly from https://openui5.hana.ondemand.com/resources/sap-ui-core.js
- you decide from where you want to load it.
I'm interested in what's your setup - do you use AWS or the SAP HANA Cloud trial? Or do you develop only locally?
Greets,
ben
Hi Ben,
i am developing locally.
In the bootstrap I declare with "src=resources/sap-ui-core.js" a JavaScript file. I just want to know how this concept is working and how the system is accessing this file, because I cant find a resource folder either on my local machine nor in Eclipse.
I hope you can now understand my issue.
Regards
Chris
Hi Chris,
if you are develop locally, you have to download SAPUI5 / OPENUI5 on you own and put it to the desired location. Usually, the framework is located in the resource folder which is located in your project folder.
Download OPENUI5 here:
When you extract it, you can see it contains the resource folder. Move this resource folder to your project location, and you are set.
Hope this helps!
Hey Ben
first of all thanks for your effort ;-).
We are coming closer, but thats still not what i wanted to know. I don't want to know how to setup the environment, I did that already and everything is working fine (Eclispe->Help->Install New Software).
I didn't copy the resource folder to my project location, so I have no resource folder and its still working. And thats what I cant understand.
I have basically the same question like Aaron Shen, who created this topic:
"My question is: where's this resources folder? I looked all over the project structure, I didn't find a clue.
Could you tell me how does this line of code links to the sap-ui-core.js in detail?
Thanks !!"
Hi Christoph,
you are welcome, I'm also interested in what's going up over there
Could you explain your local development environment?
I've only worked with the SAP Hana Studio connected to an repository which is located on an AWS Server, and I'm interested in how you develop locally. For example, what webserver are you using?
FYI:
If you want to know from here the sap-ui-core.js is loaded, you can use firefox or chrome console and under "Network" you can see it there...
Thanks,
ben
The file is loaded from this location:
http://localhost:53755/ZUI5_LIEF_APP2/resources/sap-ui-core.js
To execute the project I just say: Run As->Web App Preview.
I didnt install a webserver on my own, i guess the appropriate environment came with the installation of UI5.
But the files from the localhost have to be stored and linked as well? Argghhhhh I suspect I won't get this quiz solved 😞
Someone asked my question.
I think I figured it. May be use full to you.
Check the web.xml file inside WebContent->WEB-INF
- There is a a mapping for '/resources' path, pointing to a servlet, called 'ResourceServlet'.
- In the same file, this servlet points to a Servlet Class ''com.sap.ui5.resource.ResourceServlet"
Now this Servlet Class is available inside a jar file located here.
<Your Project> -> Java resources -> Libraries ->Web App Libraries->'com.sap.ui5.resource<your ui5 version>.jar
Since you are running 'Web App Preview', we are looking at 'Web App Libraries'.
I think the java code (from which the above jar was compiled) would have the code to point to the resources inside 'JavaScript Resources -> SAPUI5 Core Libraries'. I am not sure if we can see the java code here though.
regards
Krishna
I have the same question and I found this path.
sap-ui-core.js file we are looking for are included in com.sap.ui5.core_ of <version> .jar file. (There is the resources folder in this file)
com.sap.ui5.core_ of <version>.jar is included in eclipse> plugins(If you use hanastudio, hdbstudio> plugins)
I think pull path before resources is automatically found by ui5 framework(ResourceServlet).
servlet handle resource.
web.xml |
---|
<!-- ============================================================== --> <!-- UI5 resource servlet used to handle application resources --> <!-- ============================================================== --> <servlet> <display-name>ResourceServlet</display-name> <servlet-name>ResourceServlet</servlet-name> <servlet-class>com.sap.ui5.resource.ResourceServlet</servlet-class> </servlet> |
ResourceServlet.class |
---|
public class ResourceServlet extends HttpServlet { public static final String REQ_ATTR_RESOURCE_OVERLAY = new StringBuilder().append(ResourceServlet.class.getName()).append(".OVERLAY").toString(); public static final String REQ_ATTR_CACHEBUSTER_REQUEST = new StringBuilder().append(ResourceServlet.class.getName()).append(".CACHEBUSTER").toString(); public static final String REQ_ATTR_PATH = new StringBuilder().append(ResourceServlet.class.getName()).append(".PATH").toString(); public static final String CTX_ATTR_CACHEBUSTER_TIMESTAMP = new StringBuilder().append(ResourceServlet.class.getName()).append(".CACHEBUSTER_TIMESTAMP").toString(); private static final long serialVersionUID = -2721387829166070732L; private static final Logger LOG = Logger.getLogger(ResourceServlet.class.getName()); private static final Pattern BOOTSTRAP_SCRIPT = Pattern.compile("\\/sap-ui-core(-dbg)?\\.js"); private static Map<String, CacheResource> cache = new ConcurrentHashMap(); private static long cachebusterTimestamp; private static long remoteCachebusterExpiration = 0L; private ResourceLocator locator = null; private Template template = null; private ResourceConfig config = null; public void init() throws ServletException { ServletContext context = getServletContext(); this.locator = ResourceLocatorFactory.createResourceLocator(context); this.config = ResourceConfigFactory.createResourceConfig(context); this.template = new Template(this.locator, this.config.getTemplatePath()); String timestamp = (String)getServletContext().getAttribute(CTX_ATTR_CACHEBUSTER_TIMESTAMP); if (timestamp == null) { Map properties = ResourceUtil.loadProperties(context); if (properties != null) { timestamp = (String)properties.get("x-sap-ui5-BuildTimestamp"); } else { Manifest manifest = ResourceUtil.loadManifest(context); if (manifest != null) { timestamp = manifest.getMainAttributes().getValue("x-sap-ui5-BuildTimestamp"); } } if ((timestamp == null) || (timestamp.isEmpty()) || (!CacheBusterUtil.isCacheBusterTimestamp(timestamp))) { LOG.warning("Could not find property \"x-sap-ui5-BuildTimestamp\" in ui5.properties or MANIFEST.MF or the value is not valid! Using System.currentTimeMillis as cachebuster timestamp."); timestamp = Long.toString(System.currentTimeMillis()); } cachebusterTimestamp = CacheBusterUtil.getTimestamp(timestamp); getServletContext().setAttribute(CTX_ATTR_CACHEBUSTER_TIMESTAMP, timestamp); } } private boolean handleBootstrapRequest(HttpServletRequest request, HttpServletResponse response) throws IOException { if ((isDevMode(request)) && (System.getProperty("wtp.deploy") != null)) { Matcher m = BOOTSTRAP_SCRIPT.matcher(request.getPathInfo()); if (m.matches()) { String fileSuffix = m.group(1) == null ? "" : m.group(1); Resource bootstrapFile = null; if (request.getAttribute(REQ_ATTR_RESOURCE_OVERLAY) != null) { bootstrapFile = (Resource)request.getAttribute(REQ_ATTR_RESOURCE_OVERLAY); } else { bootstrapFile = this.locator.findResource(new StringBuilder().append("/resources/sap-ui-core").append(fileSuffix).append(".js").toString()); if ((bootstrapFile == null) || ("REMOTE".equals(bootstrapFile.getProperty("source")))) { return false; } } Resource lessSupport = this.locator.findResource(new StringBuilder().append("/resources/sap/ui/core/plugin/LessSupport").append(fileSuffix).append(".js").toString()); if ((bootstrapFile != null) && (lessSupport != null)) { long identifier = Math.max(bootstrapFile.getLastModified(), lessSupport.getLastModified()); File tempDir = new File(System.getProperty("java.io.tmpdir")); File tempBootstrap = new File(tempDir, new StringBuilder().append("sap-ui-core-less-").append(identifier).append(fileSuffix).append(".js").toString()); ByteArrayOutputStream os = new ByteArrayOutputStream(); if (!tempBootstrap.exists()) { tempBootstrap.createNewFile(); tempBootstrap.deleteOnExit(); bootstrapFile.pipe(os); os.write("\ntry {\n".getBytes("UTF-8")); lessSupport.pipe(os); os.write("\n} catch (ex) { /* ignore the errors when defining the LessSupport */ };".getBytes("UTF-8")); OutputStream fileOs = new FileOutputStream(tempBootstrap); try { os.writeTo(fileOs); } finally { if (fileOs != null) { fileOs.close(); } } } Resource resource = new ServletResource(getServletContext(), new StringBuilder().append(request.getServletPath()).append(request.getPathInfo()).toString(), tempBootstrap.toURI().toURL(), "MODIFIED"); request.setAttribute(REQ_ATTR_RESOURCE_OVERLAY, resource); } } } return false; } |
Hi Krishna,
just to add it here in case someone is looking for it too: You can find the openui5 version of the Resource Servlet here:
openui5/ResourceServlet.java at master · SAP/openui5 · GitHub
It goes through the deployed archive on the application server and hands the js files to the client as you said.
HTH,
M.
PS: Here is a link to the current version if the above master branch is not working somewhen in the future:
openui5/ResourceServlet.java at 5ecad53b87aa4dba74b18b1d86b0cf7948ab1258 · SAP/openui5 · GitHub
User | Count |
---|---|
69 | |
11 | |
10 | |
10 | |
9 | |
9 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.