I have two servers. Server-webapplication-1 builed by primefaces+liferay, Server-2 builed spring-boot rest API, the server-2 to do something and return a pdf file (i was referred link https://www.technicalkeeda.com/spring-tutorials/download-pdf-file-using-spring-mvc-rest-controller).
In web-application, i have a p:commandLink onclick will get PDF file from server-2 and pass the PDF file to server-webapplication-1. If the PDF file is small (<10Mb), i cant encode to base64 and pass it (How to pass a blob created in javascript to JSF bean). If the PDF file is big, i don't know how to do that because java-exception will be throught (java heap space).
So, how to pass a big file to jsf bean from javascript?
Related
Based on the selection of a few form elements, I want to dynamically load a PDF file into an embed/object tag which is stored in a database.
Serving the PDF
I found this solution to serve a PDF from a servlet.
Is this the right approach when using Facelets? Because I thought when using facelets, I shouldn't need Servlets so how would I do that with a Bean?
As I load the PDF dynamically from a Database, I don't have access to a file on the file-system so in which way would I have to modify the response.setHeader?
Call from JSF
I thought that I would somehow first trigger a javascript function to update the content of the src attribute in the embed tag and then with the ajax tag from the jsf core library trigger the rerendering of the embed element.
Is this the right approach?
<embed src="#{pdfServlet.getPdf[desiredFileId]}"></embed>
I am generating a pdf file from a database data. I want to store the file in webapp/resources so that I can have a relative link for my pdf to put it in my jsf page. Please let me know if there is a way to store pdf in relative path (webapp/resource)
I save uploaded image files in tomcat or portlet temporary directory, and I want to display them. I know their path in server file system, but how generate a right path for displaying it on portlet's page? It must become from smth like:
opt/liferay/tomcat-7.0.27/temp/28-Image-portlet/WEB-INF/classes/intech/webpro/kegor/image/Clipboard02.jpg
to
http://test.com/web/guest/liferay-benefits?p_p_id=Image_WAR_Imageportlet&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_cacheability=cacheLevelPage&p_p_col_id=column-1&p_p_col_count=1&_Imag
How to get it?
I know how it is done from portlets resources folder:
#{resource['images:smiley.jpg']}
But how to display image from some server directory in portlet?
You can't access images from another server using #{resource['image']} ,
You can either
1) give the full image path in xhtml
2) Keep the image paths in CSSfile and use CSS classes in xhtml.
3) create a common util function or
ResourceHelper ApplicationScoped Bean that has something like
getResource(String imageName) which returns the correct URL. You
can then use it in your xhtml as
#{ResourceHelper.getResource('image.png')}
If you only need to display content (without permission check), you can use Tomcat. Put file into /webapps/portlet-name/html/ (or temp/portlet-name/html/) directory.
As a result: http://site.com/portlet-name/html/image.jpg
I loaded the html file in webview in javafx2. We can call the javascript function by webEngine.executeScript("functionName()") if the function name is already available in the loaded HTML file.
Now I need to add external javascript file / function into the page. How to do that?
Use InputStream to read the external File from URLConnection then add content of stream to StringBuilder then keep them in executeScript . I think this way it will work.
I am trying to use tomahawk MyFaces file upload component t:inputFileUpload. I followed the example at JSF 2.0 File upload, with one change-instead of copying files to /lib, I used maven. There are no errors or warnings, but the file upload component is not showing up. Only the submit button shows on the screen. Please help me
Check the rendered HTML page. Perhaps it still contains <t:inputFileUpload>. In this case you may have forgotten to add the namespace for the prefix t to your file like this:
xmlns:t="http://myfaces.apache.org/tomahawk"
If the prefix isn't defined, the tags are simply not processed and directly rendered to the output.