- 浏览: 524633 次
- 性别:
- 来自: 山东济南
文章分类
最新评论
-
dragon_8844:
非常不错,nice
java.util.concurrent 多线程框架 -
wusendong:
很好的文章!受益匪浅,谢谢!
java.util.concurrent 多线程框架 -
SINCE1978:
你也关注并发啊
java.util.concurrent 多线程框架 -
lku1314:
这个不错 刚刚找到这个组建 以前孤陋寡闻了 像lz学习!标 ...
quartz 在WEB中应用小结 -
lliiqiang:
人们对于目标需要的需求明确的去做,对于目标以外的因素是随机的执 ...
flex和后端的数据交互(一)--XML和HTTPService
The Iframe portlet makes it possible to embed another HTML page inside the current page. Furthermore the user can navigate through the embedded page without loosing the context of the portal page.
The Iframe portlet uses the HTML iframe tag that is part of HTML 4 and is supported in all major browsers. The iframe portlet will adjust to the size of the HTML page if that page is hosted in the same server. The browser will take care of making the adding scrollbars if the embedded page does not fit within the size of the iframe.
Basic functionalities
Embedding remote web sites
To show the basic functionality add an iframe portlet to any page of the portal that you can administer. Then click the configure button.
You'll see a form with a handful of options, for now just look at the Source URL field and write in it:
Go back to the full page and you'll be able to see the google search box inside your portlet. You can even do a search and have the search displayed within your portlet.
Embedding portal pages
Controlling the attributes of the iframe window
You can control the size, look and other attributes of the iframe using the HTML attributes field. This field is formed by a text area that can contain one attribute value per line of the form:
The supported attributes are:
* border
* bordercolor
* frameborder
* heightMaximized
* heightNormal
* hspace
* scrolling
* vspace
* width
Note: The size of the iframe portlet will automaticalle adjust to the size of the HTML page displayed if this page is in the same server. However, if you set the attributes width or height it won't automatically resize.
Add parameters dynamically
Any parameter can be passed to the iframe page from the URL of the page in which you have placed the iframe portlet. These parameters will follow the patter: {portlet namespace}iframe_{parameter name}={parameter value}. It is also mandatory to include the p_p_id parameter to make this work.
For example, this would be a valid url with a parameter called "example1", with the value "value1":
[http://localhost:8080/web/guest/home?p_p_id=48_INSTANCE_1Kv8&_48_INSTANCE_1Kv8_iframe_example1=value1]
Change the URL dynamically
The Page the iframe is displaying can be also changed from the URL using the anchor element. For example, if we have an iframe in the home page, this URL would use the iframe to display Google: [http://localhost:8585/web/guest/home#http://www.google.com]
Note: This url will be displayed in all the iframes we have in a page.
Authentication
If the embedded web page requires authentication the iframe portlet can be configured to provide authentication information. This section describes the different options offered to the user.
Basic vs form based authentication
There are several way to provide the authentication information to the embedded page. The iframe portlet supports two of them:
* Basic authentication: This method is described in the HTTP specification. The user name and passwords are usually provided as HTTP headers but it's also possible to embed them in the URL with the syntax http://username:password@www.myurl.com This method is simple but it's not supported in many websites.
* Form authentication: Is the name given to websites that authenticate the user by making him fill in a form with his user name and password. It's the one used in most web sites. There are two variants of this: GET and POST. The first one sets the username and password in the URL and the second one in the body of the request. Usually they make little difference and both will probably work with any website.
Security note: Be aware that none of these methods are secure unless they are sent through an HTTPS connection. If you want to make sure that the user and password information cannot be seen by third parties only use authentication with sites that support HTTPS and use only URLs in the iframe that start with https:// Also if you use Basic authentication you'll have to use HTTPS to communicate with the Liferay portal because the user name and passwords will be included in the HTML of the page served to the user.
Automatic vs configured user name and password
Liferay provides two ways to retrieve the user name and passwords that will be used to authenticate against the embedded web page:
* Automatic: The user name and password of the current user that is viewing the page with the iframe portlet will be used. It's only supported by the 'basic authentication' method described in the previoues section.
* Configured: The administrator will configure a user name and password and they will be used for all users.
To use the automatic way just leave the 'user name' and 'passwords' fields blank. Otherwise fill them with the values that will be used for authentication
Note that the value of those fields is different depending on the type of authentication used:
* Basic: just write the username and passwords as they are
* Form: prefix the user name and password with the names of the fields for them in the form. For example:
User name: userName=myusername Password: userPass=mypassword
Hidden variables
When using form based authentication, the iframe portlet allows the administrator to configure a set of additional parameters that will be sent with the form. This parameters must be set in the 'Hidden Variables field and its format must be:
xxxx=blah;abc=formSubmit1
See an example below (By Ryan):
How to manually find out the authentication type supported by the web page to be embedded
Sometimes we don't know what type of authentication is supported by the application that will go inside the iframe. If we don't want to, or cannot afford to try out different configurations through the portal we can find out following this process.
Preparation
To follow the following example create an account here, if you don't have one already:
http://www.rsscalendar.com/rss/login.asp
For this example, I'm going to use username "liferay" and the password "test".
Basic Authentication
First we'll try form based auth.
1) Open a browser and write the following URL with valid user and passwords:
[http://myuser:mypassword@www.rsscalendar.com/rss/login.asp]
2) Now that you know this works, use the same information in the IFrame portlet. Source URL: http://www.rsscalendar.com/rss/login.asp Authentication Type: Basic Form Method: User Name: liferay Password: test
Form based Authentication
1) Create a file called form-auth.html on your desktop.
2) Input the following code into form-auth.html:
I got "UserName" and "UserPassword" from viewing source on http://www.rsscalendar.com/rss/login.asp. I also found out that the form was using method "post" and input type "submit" by viewing source.
3) Open up logintest.html, type in your new usename and password you just created. Hit Submit. You should now be logged in to rsscalendar.
4) Now that you know this works, use the same information in the IFrame portlet. Source URL: http://www.rsscalendar.com/rss/login.asp Authentication Type: Form Form Method: Post User Name: UserName=liferay Password: UserPassword=test
Notice that I put UserName=liferay instead of just 'liferay'. The reason for this is so the Iframe portlet knows what input names to use when it creates the form to submit.
How does it work?
When form based authentication is not used, the iframe portlet works in a very simple way. It just takes the configured URL and adds the authentication parameters if they were set.
When form based authentication is used, what the IFrame authentication does is make a first (hidden) request to a portal page that recreates a form and then submits it to the configured URL. To learn the details of this form take a look at the following file from Liferay's sources:
Troubleshooting
The web site takes the whole browser window instead of just the iframe
Some web sites have a security measure to avoid being inserted in frames or iframes. The use JavaScript to detect that they are in that situation and reload the page to use the whole browser window.
If that's your case you should not use that web site in an iframe unless you've got authorization from them. Once you get it, ask them for a URL that does work inside an iframe
Authentication does not work
Try authenticating manually using the process described in a previous section. Use the same user and password that the iframe portlet is using.
To find out which user and password the iframe portlet is using check:
* Basic authentication: look at the HTML source code of the page with the portlet and check the SRC attribute of the IFRAME tag.
* Form authentication: Switch the configuration to basic auth and follow the above procedure. Then set the configuration back to Form authentication.
Basic Authenticacion in iexplorer does not work
Corné|Corné 12:27, 13 May 2008 (PDT) Since IE 7 this is default behaviour; http://support.microsoft.com/kb/834489 Setting the header with Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ== would be a better solution something like;
Maybe is your navigator who does not permit basic autentication, to find out if it does, look at windows registry for
HKEY_LOCALMACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_HTTP_USERNAME_PASSWORD_DISABLE\iexplore.exe HKEY_LOCALMACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_HTTP_USERNAME_PASSWORD_DISABLE\explore.exe
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_HTTP_USERNAME_PASSWORD_DISABLE\iexplore.exe HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_HTTP_USERNAME_PASSWORD_DISABLE\explore.exe
they should exist and have a REG_DWORD value of 0x00000000(0), if not, create or change their values to permit links in the form of http://user:password@www.domain.com
you can also try first with firefox navigator that has this feature enabled by default.
The Iframe portlet uses the HTML iframe tag that is part of HTML 4 and is supported in all major browsers. The iframe portlet will adjust to the size of the HTML page if that page is hosted in the same server. The browser will take care of making the adding scrollbars if the embedded page does not fit within the size of the iframe.
Basic functionalities
Embedding remote web sites
To show the basic functionality add an iframe portlet to any page of the portal that you can administer. Then click the configure button.
You'll see a form with a handful of options, for now just look at the Source URL field and write in it:
[http://www.google.com]
Go back to the full page and you'll be able to see the google search box inside your portlet. You can even do a search and have the search displayed within your portlet.
Embedding portal pages
Controlling the attributes of the iframe window
You can control the size, look and other attributes of the iframe using the HTML attributes field. This field is formed by a text area that can contain one attribute value per line of the form:
attribute-name=attribute-value
The supported attributes are:
* border
* bordercolor
* frameborder
* heightMaximized
* heightNormal
* hspace
* scrolling
* vspace
* width
Note: The size of the iframe portlet will automaticalle adjust to the size of the HTML page displayed if this page is in the same server. However, if you set the attributes width or height it won't automatically resize.
Add parameters dynamically
Any parameter can be passed to the iframe page from the URL of the page in which you have placed the iframe portlet. These parameters will follow the patter: {portlet namespace}iframe_{parameter name}={parameter value}. It is also mandatory to include the p_p_id parameter to make this work.
For example, this would be a valid url with a parameter called "example1", with the value "value1":
[http://localhost:8080/web/guest/home?p_p_id=48_INSTANCE_1Kv8&_48_INSTANCE_1Kv8_iframe_example1=value1]
Change the URL dynamically
The Page the iframe is displaying can be also changed from the URL using the anchor element. For example, if we have an iframe in the home page, this URL would use the iframe to display Google: [http://localhost:8585/web/guest/home#http://www.google.com]
Note: This url will be displayed in all the iframes we have in a page.
Authentication
If the embedded web page requires authentication the iframe portlet can be configured to provide authentication information. This section describes the different options offered to the user.
Basic vs form based authentication
There are several way to provide the authentication information to the embedded page. The iframe portlet supports two of them:
* Basic authentication: This method is described in the HTTP specification. The user name and passwords are usually provided as HTTP headers but it's also possible to embed them in the URL with the syntax http://username:password@www.myurl.com This method is simple but it's not supported in many websites.
* Form authentication: Is the name given to websites that authenticate the user by making him fill in a form with his user name and password. It's the one used in most web sites. There are two variants of this: GET and POST. The first one sets the username and password in the URL and the second one in the body of the request. Usually they make little difference and both will probably work with any website.
Security note: Be aware that none of these methods are secure unless they are sent through an HTTPS connection. If you want to make sure that the user and password information cannot be seen by third parties only use authentication with sites that support HTTPS and use only URLs in the iframe that start with https:// Also if you use Basic authentication you'll have to use HTTPS to communicate with the Liferay portal because the user name and passwords will be included in the HTML of the page served to the user.
Automatic vs configured user name and password
Liferay provides two ways to retrieve the user name and passwords that will be used to authenticate against the embedded web page:
* Automatic: The user name and password of the current user that is viewing the page with the iframe portlet will be used. It's only supported by the 'basic authentication' method described in the previoues section.
* Configured: The administrator will configure a user name and password and they will be used for all users.
To use the automatic way just leave the 'user name' and 'passwords' fields blank. Otherwise fill them with the values that will be used for authentication
Note that the value of those fields is different depending on the type of authentication used:
* Basic: just write the username and passwords as they are
* Form: prefix the user name and password with the names of the fields for them in the form. For example:
User name: userName=myusername Password: userPass=mypassword
Hidden variables
When using form based authentication, the iframe portlet allows the administrator to configure a set of additional parameters that will be sent with the form. This parameters must be set in the 'Hidden Variables field and its format must be:
xxxx=blah;abc=formSubmit1
See an example below (By Ryan):
How to manually find out the authentication type supported by the web page to be embedded
Sometimes we don't know what type of authentication is supported by the application that will go inside the iframe. If we don't want to, or cannot afford to try out different configurations through the portal we can find out following this process.
Preparation
To follow the following example create an account here, if you don't have one already:
http://www.rsscalendar.com/rss/login.asp
For this example, I'm going to use username "liferay" and the password "test".
Basic Authentication
First we'll try form based auth.
1) Open a browser and write the following URL with valid user and passwords:
[http://myuser:mypassword@www.rsscalendar.com/rss/login.asp]
2) Now that you know this works, use the same information in the IFrame portlet. Source URL: http://www.rsscalendar.com/rss/login.asp Authentication Type: Basic Form Method: User Name: liferay Password: test
Form based Authentication
1) Create a file called form-auth.html on your desktop.
2) Input the following code into form-auth.html:
<form action="[http://www.rsscalendar.com/rss/login.asp"] method="post"> User name: <input name="UserName" type="text" value=""> Password: <input name="UserPassword" type="text" value=""> <input type="submit"> </form>
I got "UserName" and "UserPassword" from viewing source on http://www.rsscalendar.com/rss/login.asp. I also found out that the form was using method "post" and input type "submit" by viewing source.
3) Open up logintest.html, type in your new usename and password you just created. Hit Submit. You should now be logged in to rsscalendar.
4) Now that you know this works, use the same information in the IFrame portlet. Source URL: http://www.rsscalendar.com/rss/login.asp Authentication Type: Form Form Method: Post User Name: UserName=liferay Password: UserPassword=test
Notice that I put UserName=liferay instead of just 'liferay'. The reason for this is so the Iframe portlet knows what input names to use when it creates the form to submit.
How does it work?
When form based authentication is not used, the iframe portlet works in a very simple way. It just takes the configured URL and adds the authentication parameters if they were set.
When form based authentication is used, what the IFrame authentication does is make a first (hidden) request to a portal page that recreates a form and then submits it to the configured URL. To learn the details of this form take a look at the following file from Liferay's sources:
portal-web/docroot//html/portlet/iframe/proxy.jsp
Troubleshooting
The web site takes the whole browser window instead of just the iframe
Some web sites have a security measure to avoid being inserted in frames or iframes. The use JavaScript to detect that they are in that situation and reload the page to use the whole browser window.
If that's your case you should not use that web site in an iframe unless you've got authorization from them. Once you get it, ask them for a URL that does work inside an iframe
Authentication does not work
Try authenticating manually using the process described in a previous section. Use the same user and password that the iframe portlet is using.
To find out which user and password the iframe portlet is using check:
* Basic authentication: look at the HTML source code of the page with the portlet and check the SRC attribute of the IFRAME tag.
* Form authentication: Switch the configuration to basic auth and follow the above procedure. Then set the configuration back to Form authentication.
Basic Authenticacion in iexplorer does not work
Corné|Corné 12:27, 13 May 2008 (PDT) Since IE 7 this is default behaviour; http://support.microsoft.com/kb/834489 Setting the header with Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ== would be a better solution something like;
<% String userName = StringPool.BLANK; String passWord = StringPool.BLANK; for (int i = 0; i < hiddenVariablesArray.length; i++) { String hiddenValue = StringPool.BLANK; int pos = hiddenVariablesArray[i].indexOf(StringPool.EQUAL); if (pos != -1) { hiddenValue = hiddenVariablesArray[i].substring(pos + 1, hiddenVariablesArray[i].length()); if(i==0) userName = hiddenValue; if(i==1) passWord = hiddenValue; } } response.setHeader("Authorization", "Basic "+com.liferay.portal.kernel.util.Base64.encode( new String(userName+":"+passWord).getBytes())); response.sendRedirect(src); response.flushBuffer(); %>
Maybe is your navigator who does not permit basic autentication, to find out if it does, look at windows registry for
HKEY_LOCALMACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_HTTP_USERNAME_PASSWORD_DISABLE\iexplore.exe HKEY_LOCALMACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_HTTP_USERNAME_PASSWORD_DISABLE\explore.exe
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_HTTP_USERNAME_PASSWORD_DISABLE\iexplore.exe HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_HTTP_USERNAME_PASSWORD_DISABLE\explore.exe
they should exist and have a REG_DWORD value of 0x00000000(0), if not, create or change their values to permit links in the form of http://user:password@www.domain.com
you can also try first with firefox navigator that has this feature enabled by default.
发表评论
-
java动态编程一例
2009-12-22 08:37 1575Test.java package test; im ... -
tomcat SSL基本配置
2009-11-30 09:25 1504切换到$TOMCAT_HOME下: 1.生成 server ... -
Oracle 10g自带性能监测工具
2009-11-04 09:08 3135安装Oracle 10g时可以选择安装自带的性能监测工具,对于 ... -
Liferay应用界面
2009-09-16 17:26 2209我们用Liferay Portal开发的项目,已有小成,sho ... -
LifeRay 5.1.2 使用struts1.1时ClassNotFoundException
2009-08-25 10:37 1233今天修改一个portlet时出现 java.lang.Clas ... -
Tomcat 5 中文路径问题
2009-08-06 10:02 1385在tomcat 5下一个动态加载svg图形文件的页面; 页面中 ... -
dhtmlxtree使用中的CharConversionException: isHexDigit
2009-08-04 16:48 1870使用dhtmlxtree时,点击树节点异步加载子节点数据时,在 ... -
程序员五大层次,你属于哪一层?
2009-07-14 13:54 1199软件界一个无 ... -
第一次面别人
2009-05-27 09:40 1667“面”不是吃的,是看的。 从换了工作以后都很忙,周 ... -
liferay中使用struts时jar文件冲突
2009-05-26 13:52 1715异常: java.lang.NoSuchMethodE ... -
犹豫中,不知道该怎么办了!
2009-03-04 10:38 1194先说说我现在的公司, ... -
参数传递的浏览器差异
2008-10-19 22:32 1721情况大体是这样的:一个头页面header.jsp上有一个搜索框 ... -
该死的黑客
2008-09-22 15:06 1396公司一台对外网服务的linux系统数据库服务器,上周五被人破译 ... -
A Tutorial on Clustering Algorithms
2008-07-02 09:50 3077A Tutorial on Clustering Algor ... -
The Examples for Quartz Time Format
2008-05-16 15:02 1776The Examples for Quartz Time Fo ... -
让人头疼的新手
2008-05-13 11:25 4690刚进公司没多久时,领导让我带两个新人(07年7月份毕业的)。他 ... -
昨天参加了一次面试
2008-05-06 11:40 2852象去年这个时候一样, ... -
开发小记
2008-02-13 15:54 14401. 在oracle中字符串拼 ... -
javascript实现日期操作的工具包
2007-12-13 13:39 3251最近一个小项目中用到了dwr,其中使用到了日期型数据;查了一下 ... -
开发中莫名奇妙的事(八卦)
2007-09-28 08:52 20892007年9月22日 ant进行jar ...
相关推荐
Liferay-Portlet-SDK 5.2.3操作说明.ppt
详解portlet技术,是帮助你学习进步的好助手哦。快来下载吧
liferay-portlet-development
一个Liferay Soy Portlet使用web service进行可视化数据的实例。
中文英文的liferay-portlet-development-guide;主要是里面有中文翻译好的,免去你翻译的烦恼。
liferay portlet 开发的例子介绍
liferay portlet例子 liferay portlet例子
可供参考的liferay开发的portlet示例工程,学习参考的简单示例
Liferay5.2.3的样例,通过war.bat打包后发布到相应的liferay环境即可。 另外,需要配置context,tomcat中的代码如下: </Context>
commons-configuration-gae.zip,配置的实现(由apache commons配置库提供),使用google app engine datastore api存储配置参数;配置的实现(由apache commons配置库提供),使用google app engine datastore api...
Liferay Portlet 开发文档, 比较全的开发介绍,了解PORTLET 的应用和基本开发, 熟悉Lifery IDE 开发。
liferay portlet demo
Liferay Spring Portlet MVC 使用 Maven 的 Liferay Spring Portlet MVC 项目模板。 Liferay EE 6.2.10.11 (GA1, SP710) Java 1.7 小门户 2.0 弹簧框架 4.1.5 基于注解的控制器配置 用法 $ git clone ...
liferay portlet开发参考手册——作者:温兵
liferay portlet开发介绍文档。
Liferay用户导入Portlet 用于从csv文件将用户导入Liferay的Portlet 作为此应用程序的用户数据源,我们将使用具有以下格式的CSV文件: username;email;firstName;lastName;password;male paul;paul@paul.com;Paul...
带有React JS和Webpack的Liferay MVC Portlet 发展 运行npm install启动webpack开发服务器npm start 建造 运行gradle clean buildWebpack deploy cleanJSDist
使用struts1.X实现了liferay portlet插件。
Liferay跨页面Portlet之间的调用与数据传递,Portlet之间的通信方法有多种,比如PortletSession,Public Render Parameter,Portlet event等。但是这些方法使用起来都很复杂,像Public Render Parameter和event等,...
一个小例子 挺有用的 关于 liferay产品中配置 struts2