Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Uncaught ReferenceError: JSZipUtils is not defined
Hello, I am facing some problems (again) when trying to use external JS files in one of my portlets.This time I am getting the "Uncaught ReferenceError: JSZipUtils is not defined" and don't know really why. I need to import 6 JS files. This is what I have defined in the properties of my Portlet class:VisitReportWebPortlet.java
I don't really understand how the combo file is generated, but in the attached "VM31 combo.js" file is what I see on Chrome's console.
And here it seems that the different JS files are loaded... Btw, I have tried to do the same wiht a simple PHP page and works, but I need to make it work in Liferay 7 (liferay-ce-portal-7.0-ga3).
Any help that can guide me to find a solution?THANKS A LOT
@Component(
immediate = true,
property = {
"com.liferay.portlet.display-category=category.sample",
"com.liferay.portlet.instanceable=true",
"com.liferay.portlet.footer-portlet-javascript=/js/jszip.min.js",
"com.liferay.portlet.footer-portlet-javascript=/js/jszip-utils.min.js",
"com.liferay.portlet.footer-portlet-javascript=/js/docxtemplater-latest.min.js",
"com.liferay.portlet.footer-portlet-javascript=/js/FileSaver.min.js",
"com.liferay.portlet.footer-portlet-javascript=/js/DocxReader.js",
"com.liferay.portlet.footer-portlet-javascript=/js/BBHI_report.js",
"javax.portlet.display-name=BBHI Report Web",
"javax.portlet.init-param.template-path=/",
"javax.portlet.init-param.view-template=/view.jsp",
"javax.portlet.resource-bundle=content.Language",
"javax.portlet.security-role-ref=power-user"
},
service = Portlet.class
)
At some point, there is button with onclick="createReport()", reaching a point where a function from JSZipUtils is called:JSZipUtils.getBinaryContent(this.url, function(error,content){
But then I get the error:Uncaught ReferenceError: JSZipUtils is not defined
at DocxReader.Load (VM31 combo:52)
at createReport (VM31 combo:211)
at HTMLButtonElement.onclick I don't really understand how the combo file is generated, but in the attached "VM31 combo.js" file is what I see on Chrome's console.
And here it seems that the different JS files are loaded... Btw, I have tried to do the same wiht a simple PHP page and works, but I need to make it work in Liferay 7 (liferay-ce-portal-7.0-ga3).
Any help that can guide me to find a solution?THANKS A LOT
Attachments:
I think I have identified the problem... Within the jszip-utils.js file, there is a reference to a jquery function:
And I think this is the reason that makes everything that goes inside this function to not be declared properly.
Any help here?
Thanks!
!function(e){"object"==typeof exports?module.exports=e():"function"==typeof ...
And I think this is the reason that makes everything that goes inside this function to not be declared properly.
Any help here?
Thanks!
<p>I found this thread where seems that JSZip does not work in Liferay:</p>
<p><a href="https://liferay.dev/forums/-/message_boards/message/57848458?_19_threadView=flat">https://liferay.dev/forums/-/message_boards/message/57848458?_19_threadView=flat</a></p>
<p>So, I'll try to generate and send the document at server side.</p>
<p><a href="https://liferay.dev/forums/-/message_boards/message/57848458?_19_threadView=flat">https://liferay.dev/forums/-/message_boards/message/57848458?_19_threadView=flat</a></p>
<p>So, I'll try to generate and send the document at server side.</p>