Giter VIP home page Giter VIP logo

iframe-plus-portlet's Introduction

IFrame+ (for Liferay portal)

IFrame+ is a portlet developed for the Liferay portal.

As the official Liferay Iframe portlet, the IFrame+ portlet makes possible to embed another web page inside the portlet. Navigation through the embedded page is then possible without loosing the context of the portal page.

What makes IFrame+ special and really useful is its capability to automatically resize its embedded IFrame in cross-domain* configuration where the official Liferay plugin only makes it possible for web page contained in the same domain.

The IFrame+ portlet also add a loading mask option.

*Cross-domain resizing can be used only if you have access to the source of the IFrame content (Javascript and CSS styles must be added)

Screenshots

###Web page embedded into the portlet Front page

###IFrame+ portlet configuration options Configuration options

###IFrame+ portlet optional loading mask Loading mask

Glossary

Consumer page: page in which an iFrame is embedded.

Provider page: page included in the consumer IFrame.

Why use this portlet?

Standard theme for Liferay portal use portlet with width defines in percentage. Thus, when the browser window is resized in width by a user, text or other elements within portlets wrap and take more space in height to be display. For normal portlets, height is automatically modified to display all the content. To achieve the same objective a "Resize Automatically" option can be activated in the official Liferay IFrame portlet. However, this option works only if the page is located in the same domain.

When the page to display through the portlet IFrame holds fixed width content auto resize is not required because it's possible to manually define IFrame dimension (in pixel). However, if content width is variable (set in percent) the only solution to be able to display correctly all the page content even when browser width is resized is to use a scroll bar which is not really pretty and not ergonomic.

How it works

Due to browsers' security policies, it's impossible to get access to an IFrame content from its parent window when both documents are located in two different domains. To overcome this restriction, different solutions exist, not always quite obvious, especially when the solution must be cross-browser.

Here come the IFrame+ portlet which, with the use of the easyXDM Javascript library (http://easyxdm.net), brings a cross-browser easy to use solution.

EasyXDM definition : "At the core easyXDM provides a transport stack capable of passing string based messages between two windows, a consumer (the main document) and a provider (a document included using an iframe)."

The easyXDM library integrated with this portlet use several techniques to make the cross-domain communication needed for IFrame resize possible with a large panel of browsers (IE6+, Firefox 1+, Chrome 2+, Safari 4+, Opera 9+).

To work, some Javascripts are needed on the consumer and on the provider page: On the provider page (page displayed in the IFrame) with the use of Javascript a message is automatically sent to the consumer page (where IFrame tag is defined) whenever the provider page content is resized (for example, when a user resizes its browser width or when a new content is dynamically added). On the consumer page, some Javascript is used to listen to the message sent by the provider pages and when a new one is received it changes the IFrame dimension (the message contains the new page height).

Choose your configuration

There is two ways to configure the Iframe+ portlet. The first configuration which is also the simplest is intended only for single page web site (where there is no inner navigation to other pages). The second one is intended for the web site where inner navigation to other pages is possible.

Configuration n°1 - for web site without inner navigation

When the Provider page is a web site where only one page is displayed (the inner window is not navigable). The simple configuration can be used.

The following schema shows how the provider page hosted in the iFrame+ portlet interacts with the Consumer page in the simple configuration.

IFrame+ schema no navigation

Configuration n°2 - for web site with inner navigation

When on the Provider side the inner window is navigable (user can navigate through multiple pages), the simple configuration won't work because navigating to another page will break the socket connection made on the home page and therefore subsequent pages won't be able to communicate with the Consumer socket anymore.

For this reason another configuration must be used. This configuration add an intermediary page which keeps the socket connection opened with the Consumer page.

The following schema shows how this configuration is implemented.

IFrame+ schema no navigation

It's up to you to choose one of these two configurations depending on your need.

How to install Iframe+ portlet

###Intallation for Configuration n°1 (web site without inner navigation) #####On the portal (consumer page)

  1. Deploy the portlet in your Liferay server (you can use the user interface or place the *.war file in the deploy folder for auto deploy.)
  2. Add IFrame+ portlet to a page (the portlet is instanciable and thus can be added multiple time to a page)
  3. Set the IFrame web page URL in the configuration page of the portlet.

#####On the provider page 1) Declare easyXDM.js and iframeplus-provider.js javascripts in the header of the page

  <script type="text/javascript" src="link/to/easyXDM.js"></script>
  <script type="text/javascript" src="link/to/iframeplus-provider.js"></script> 

Javascript files can be found in /docroot/js/iframeplus/iframeplus-provider.js and /docroot/js/easyxdm/easyXDM.js

2) Apply the following style on the Provider page to hide scollbar

  html, body {
	overflow: hidden;
	margin: 0px;
	padding: 0px;
  }

3) (Optional) if the consumer page uses dynamic content, you can use the resizeIframe() function to indicate content has changed.

For example, if you load RSS fields using Javascript, you can call resizeIframe() function once all RSS entries are loaded or after each new entry to make the iframe fit correctly with the added elements.

 <script type="text/javascript"> 
 	resizeIframe();
 </script>

###Intallation for Configuration n°2 (web site with inner navigation) Installation for the configuration n°2 is similar to the configuration n°1. However, you have to create the Intermediary page and make it accessible. You can create the Intermediary page by using the css and the javascript files located in /docroot/js/iframeplus/iframeplus-intermediate.js and /docroot/js/iframeplus/iframeplus-intermediate.css, you can also use the /docroot/js/iframeplus/iframeplus-intermediary.html file which already contains the correct javascript lines of codes and css styles.

Once the Intermediary page created you have to indicates through the configuration page of the portlet (see "IFrame+ portlet configuration options" screenshot at the begining of the README) the URL of the Intermediary page you just created. The url must have an "url" parameter which contain the URL of the home page. For exemple, if your Intermediary page URL is : http://your.webapp.com/intermediary and your main page is http://your.webapp.com, the URL to put into the "Web site URL" field of the portlet configuration page is : http://your.webapp.com/intermediary?url=http://your.webapp.com

Loading mask option

The purpose of this option is to display a loading icon while the IFrame content is loading.

Depending on the provider page content the end of loading can or cannot be automatically detected.

If the "End loading: Automatically" option is checked, a message will be automatically sent to the consumer page as soon as the static content of the provider page has been fully loaded (by using the jquery $(window).load method).

If the "End loading: Manually" option is checked, a message to hide the loading mask must be manually added into the provider page. This option is necessary when the page load dynamic content which is still running even after the static content has been fully loaded.

To hide manually the loading mask use the "hideLoadingMask()" function defined in the "iframe-plus.js" script.

 <script type="text/javascript"> 
 	hideLoadingMask();
 </script>

Internationalization (i18n)

Portlet is available in French and English.

New Language can easily be added by creating a *.properities file for the language to support in the WEB-INF/src/content folder. Once created, the new "Language" file must be declared in the WEB-INF/liferay-hook.xml file.

Liferay version tested

This portlet has been tested on Liferay 6.1EE.

License

Copyright (c) 2012 University of Geneva, Nicolas Forney ([email protected]). This program is distributed under the terms of the GNU General Public License.

Author

Developer

Credits

Project used to develop IFrame+ :

iframe-plus-portlet's People

Contributors

cm0s avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

iframe-plus-portlet's Issues

Does not resize

I am using LR 6.1 EE and WAS8 server.

I deployed portlet and added to the page. Configured portlet to manually resize.

I see loading message for long time but loading never completes.

Am I missing something here? I do not get any errors in chrome web
Uploading iframe-plus.png . . .
error console.

Docs not quite clear

The documentation contains these two paragraphs

Installation for the configuration n°2 is similar to the configuration n°1. However, you have to create the Intermediary page and make it accessible. You can create the Intermediary page by using the css and the javascript files located in /docroot/js/iframeplus/iframeplus-intermediate.js and /docroot/js/iframeplus/iframeplus-intermediate.css, you can also use the /docroot/js/iframeplus/iframeplus-intermediary.html file which already contains the correct javascript lines of codes and css styles.

Once the Intermediary page created you have to indicates through the configuration page of the portlet (see "IFrame+ portlet configuration options" screenshot at the begining of the README) the URL of the Intermediary page you just created. The url must have an "url" parameter which contain the URL of the home page. For exemple, if your Intermediary page URL is : http://your.webapp.com/intermediary and your main page is http://your.webapp.com, the URL to put into the "Web site URL" field of the portlet configuration page is : http://your.webapp.com/intermediary?url=http://your.webapp.com

This leaves me with a question.

How do I construct the compound URL if I just want to use your provided intermediary page?

Say I have Liferay running here

http://mydomain:8080

with a iFrame+ instance on a page called foopage

And say I have some other web app running here

http://myotherdomain:9000/app

I understand the URL needs to look like

<intermediaryURL>?url=http://myotherdomain:9000/app

Okay, so I want to use your supplied intermediary page

I've tried

js/iframeplus/iframeplus-intermediary.html?http://myotherdomain:9000/app

and

/js/iframeplus/iframeplus-intermediary.html?http://myotherdomain:9000/app

None of these work for me.

So if you could please document how to construct the URL when using your supplied intermediary, it would be great.

Thanks again.

probleme installation with liferay 6.1 CE

When I try to install the .war file, I have a problem :
13:02:47,011 INFO [AutoDeployDir:167] Processing iframe-plus-portlet-0.3.0.war
13:02:47,102 INFO [PortletAutoDeployListener:71] Copying portlets for C:\Utilit
aires\liferay-portal-6.1.0-ce-ga1\deploy\iframe-plus-portlet-0.3.0.war
Expanding: C:\Utilitaires\liferay-portal-6.1.0-ce-ga1\deploy\iframe-plus-portl
et-0.3.0.war into C:\Utilitaires\liferay-portal-6.1.0-ce-ga1\tomcat-7.0.23\temp
20120607130247114
Copying 1 file to C:\Utilitaires\liferay-portal-6.1.0-ce-ga1\tomcat-7.0.23\tem
p\20120607130247114\WEB-INF
Copying 1 file to C:\Utilitaires\liferay-portal-6.1.0-ce-ga1\tomcat-7.0.23\tem
p\20120607130247114\WEB-INF\classes
Copying 1 file to C:\Utilitaires\liferay-portal-6.1.0-ce-ga1\tomcat-7.0.23\tem
p\20120607130247114\WEB-INF\classes
Copying 1 file to C:\Utilitaires\liferay-portal-6.1.0-ce-ga1\tomcat-7.0.23\tem
p\20120607130247114\META-INF
Copying 1 file to C:\Utilitaires\liferay-portal-6.1.0-ce-ga1\tomcat-7.0.23\tem
p\20120607130247114\WEB-INF\jsp
13:02:48,283 ERROR [BaseDeployer:322] Unable to copy portal TLD liferay-aui.tld
java.lang.NullPointerException
at java.io.File.(File.java:222)
at com.liferay.portal.util.FileImpl.copyFile(FileImpl.java:161)
at com.liferay.portal.kernel.util.FileUtil.copyFile(FileUtil.java:54)
at com.liferay.portal.tools.deploy.BaseDeployer.copyPortalDependencies(B
aseDeployer.java:318)
at com.liferay.portal.tools.deploy.BaseDeployer.deployDirectory(BaseDepl
oyer.java:524)
at com.liferay.portal.tools.deploy.BaseDeployer.deployFile(BaseDeployer.
java:889)
at com.liferay.portal.tools.deploy.BaseDeployer.deployFile(BaseDeployer.
java:819)
at com.liferay.portal.deploy.auto.PortletAutoDeployer.autoDeploy(Portlet
AutoDeployer.java:96)
at com.liferay.portal.deploy.auto.PortletAutoDeployListener.deploy(Portl
etAutoDeployListener.java:78)
at com.liferay.portal.kernel.deploy.auto.AutoDeployDir.processFile(AutoD
eployDir.java:180)
at com.liferay.portal.kernel.deploy.auto.AutoDeployDir.scanDirectory(Aut
oDeployDir.java:222)
at com.liferay.portal.kernel.deploy.auto.AutoDeployScanner.run(AutoDeplo
yScanner.java:50)
Copying 62 files to C:\Utilitaires\liferay-portal-6.1.0-ce-ga1\tomcat-7.0.23\w
ebapps\iframe-plus-portlet
7 juin 2012 13:02:49 org.apache.catalina.startup.HostConfig deployDirectory
INFO: D├®ploiement du r├®pertoire C:\Utilitaires\liferay-portal-6.1.0-ce-ga1\tom
cat-7.0.23\webapps\iframe-plus-portlet de l'application web
Copied 31 empty directories to 1 empty directory under C:\Utilitaires\liferay-
portal-6.1.0-ce-ga1\tomcat-7.0.23\webapps\iframe-plus-portlet
Copying 1 file to C:\Utilitaires\liferay-portal-6.1.0-ce-ga1\tomcat-7.0.23\web
apps\iframe-plus-portlet
Deleting directory C:\Utilitaires\liferay-portal-6.1.0-ce-ga1\tomcat-7.0.23\te
mp\20120607130247114
13:02:49,311 INFO [PortletAutoDeployListener:81] Portlets for C:\Utilitaires\li
feray-portal-6.1.0-ce-ga1\deploy\iframe-plus-portlet-0.3.0.war copied successful
ly. Deployment will start in a few seconds.

Iframe+ doesnt work in Chrome

Hello, Nicolas.
Thanks for the great source. But i have little problems with your Iframe+. I am new in liferay and in web programming. Iframe+ works fine for IE8 and Firefox 7.0.1 but doesnt work for IE7 and Chrome 17.0.963.79 m. I see that u are using document.body.clientHeight in iframe-plus.js in resizeIframe() method. I alert(document.body.clientHeight) and it gives 100 in IE7 and chrome and gives 217 (the height of the page) in Mozilla and ie8. Actually, now, i see in Firefox and IE8 it doesnt work in inner pages (after i log in). Do u have any suggestions why it doenst work, i have included the scripts (and i checked, they are included) and i set the css style

Liferay 7

Hi
I came across your code and I'm working on liferay dxp 7 and I need a solution like this to expose my legacy applications.. plz let me know if this would work in the new version 7 of liferay
Kind regards
Paige

frame displays incorrectly

I want to thank you for sharing this portlet. I was astonished at how fast it loaded compared to LR's iframe portlet. However, It doesn't display correctly for me. I have a php app on same server as portal. When I configure iframe+ it displays like this:

iframe

I am sure its user error : -) thanks again

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.