Images in Eclipse CustomizableIntroPart are not shown - java

I'm creating a CustomizableIntroPart for my Eclipse application. I define my pages using XHTML which works fine. But handling images is causing some trouble. I generate my content using IIntroXHTMLContentProvider, but when I generate an img-tag and set the src attribute images are not displayed. Images might be either in the executing or in some other plugins contributing to the XHTML page.
Element img = dom.createElement("img");
img.setAttribute("src", getApplicationIcon(element));
img.setAttribute("class", "appIcon");
div.appendChild(img);
I couldn't find any documentation on how to specify the source. I tried things like
plugin:my.plugin.id/icons/foo.png
Any help would be appreciated.

In the end, it's a web browser that will display your XHTML content and so it has no notion of "contributed from plugins" right?
But you are using code to process these contributions, and they're coming from either your plugin or other plugins?
If that's the case, I'd use org.osgi.framework.Bundle.getEntry(String) to get the URL to your image, and then org.eclipse.core.runtime.FileLocator.toFileURL(URL) to convert it to a file:/// URL. Then use that URL to reference your icons.

I've never used CustomizableIntroPart before, but I have successfully referred to images in different plugins using a prefix of platform:/plugin/..., like this:
platform:/plugin/my.plugin.id/icons/foo.png

Related

JSP page is not running in other systems in the same network

I have developed a jsp page which is running perfectly in my system. But when I access this URL from another system in the same network some features are not available. Precisely, I have an SVG image which should be displayed and some other information along with it, which is coming from a hardware.
When I try to access from other systems this SVG is not displaying. But other information is correct. I cant find any error in my web console or eclipse console. What could be the reason?
Without seeing any of the code or your project structure. This sounds like a url problem. Sometimes relative urls to certain resources will not load if they are not in the correct directory. For example..
Imagine on your jsp page your svg image is at
/images/image.svg
Well this resource will not be accessible if the URL is pointing at /users/profiles/feed/
What you have to do in these cases is make sure that all your resources are absolute urls, or jump back directories like so:
../images/image.svg
or if you're up 2 directories
../../images/image.svg

jsp, can't find source of css property

This may be a tricky question because I can't give much detail,
I'm working of legacy code on a big project (in jsp) and I came across a "styleid = product".
It changes quite a lot of things when I remove it, but I can't seem to find it in any of the CSS files, there are properties like "tdproduct" and "thproduct" but I can't seem to find any connection.
Can anyone give me an indication of other places I might need to look for this (except .css files).
thanks in advance
Can you load the page in firefox/chrome browser?
If so you can see the generated source code.
Since JSP is a server side technology that generates some dynamic content, its also possible that the CSS will be also generated dynamically.
Theoretically it can be JSP itself, the CSS and even Java Script :)
Good luck!
Hope this helps
css are dynamically loaded when your page is loaded. your style classes can also be defined in the jsp that you are including in the parent jsp.
open the page in firefox and use firebug to view the styles loaded. You can locate where your style is loading from.

How to make Liferay not produce condensed HTML code?

I found that Liferay transfers my JSP code in a somehow "condensed" way -- putting most of the text into a few very long lines.
This makes it uncomfortable to debug javascript.
Is it possible to turn off this feature temporary?
For others looking at this post, if you simply want to do this on an adhoc basis you can add these params to the URL:
/web/guest/page?js_fast_load=0&css_fast_load=0&strip=0
Note this is for JS, CSS and HTML
HTML Minification is on regardless you're in developer mode or not since HTML stripping can itself produce problems you want to see in developer mode.
You can add strip=0 parameter to the URL to prevent the served HTML page being stripped.
In order to turn HTML-Stripping completely off change in your system.properties:
com.liferay.filters.strip.StripFilter=false
But as #BalusC said you should use a tool which does the formatting when debugging. So you're not bothered by the stripping.
There are two ways to do it. Copy the following in portal-ext.properties and restart the server
javascript.fast.load=false
or If you dont want to restart and its just for temporary purpose add js_fast_load parameter to url and set its value to false.
For example if you are in a page http://localhost:8080/web/guest/home in which your portlet or the javascript is present. Use this url instead http://localhost:8080/web/guest/home?js_fast_load=0
Liferay has a file named portal-developer.properties as template in WEB-INF/classes. You can either reference this or just copy/paste the content into your portal-ext.properties.
This has several options to minify html, js, css and others. You'll kill your loading time - i.e. you really only want these options at development time, but then it really helps.
By default all files are also combined into a single one (for js, another for css etc.) - with the development options you'll get a separate request for every file on every page request.
I just want to update package name for Liferay 6.2 from #Fabian Barney's answer:
com.liferay.portal.servlet.filters.strip.StripFilter=false

how to convert html page to image using java or php

I want to know how to convert html file to image. How do I do this?
You can checkout the source code for the popular BrowserShots service,
http://browsershots.org/
If you're running Windows, and have the GD library installed, you can use imagegrabwindow. I've never used it myself, but as always, the PHP site has lots of documentation and examples.
Use:
WKHTMLTOPDF.
It also has binding to PHP, or you can run it yourself from command line.
Problem is that you need to implement all the functionality of a browser and an HTTP stack (and this still does not deal with the case where the content is modified using javascript).
As John McCollum says, if you've got the website open in a browser on your PC, then you can use imagegrabwindow or snapsIE (MSIE only)
If you want to to be able to get a snapshot using code only, then you might want to look at one of the off the shelf solutions - AFAIK there are several programs (at least 2 of which are called html2pdf) which will generate a PDF of static html - and its relatively easy using standard tools to trim this to window size and convert to an image file.
e.g. https://metacpan.org/pod/distribution/PDF-FromHTML/script/html2pdf.pl

How do you embed XHTML into APT file when using Maven to generate a site?

I am using maven to generate a website for a Java project, which uses APT "Almost Plain Text" as a wiki like markup. Maven takes this and turns it into XHTML.
I already have a custom template/skin that I am using for the site, but the index page will have a couple of extra custom design elements that are beyond the capabilities of APT. So how can you add xhtml to the apt file so that it gets correctly embedded in the final output?
Thanks.
This does not appear possible at the current point in time. The work around was to define the index page as a resource "index.html" rather than a apt page "index.apt".

Categories

Resources