- 浏览: 531559 次
- 性别:
- 来自: 山东济南
文章分类
最新评论
-
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 1635Test.java package test; im ... -
tomcat SSL基本配置
2009-11-30 09:25 1538切换到$TOMCAT_HOME下: 1.生成 server ... -
Oracle 10g自带性能监测工具
2009-11-04 09:08 3188安装Oracle 10g时可以选择安装自带的性能监测工具,对于 ... -
Liferay应用界面
2009-09-16 17:26 2242我们用Liferay Portal开发的项目,已有小成,sho ... -
LifeRay 5.1.2 使用struts1.1时ClassNotFoundException
2009-08-25 10:37 1278今天修改一个portlet时出现 java.lang.Clas ... -
Tomcat 5 中文路径问题
2009-08-06 10:02 1435在tomcat 5下一个动态加载svg图形文件的页面; 页面中 ... -
dhtmlxtree使用中的CharConversionException: isHexDigit
2009-08-04 16:48 2023使用dhtmlxtree时,点击树节点异步加载子节点数据时,在 ... -
程序员五大层次,你属于哪一层?
2009-07-14 13:54 1249软件界一个无 ... -
第一次面别人
2009-05-27 09:40 1721“面”不是吃的,是看的。 从换了工作以后都很忙,周 ... -
liferay中使用struts时jar文件冲突
2009-05-26 13:52 1772异常: java.lang.NoSuchMethodE ... -
犹豫中,不知道该怎么办了!
2009-03-04 10:38 1244先说说我现在的公司, ... -
参数传递的浏览器差异
2008-10-19 22:32 1769情况大体是这样的:一个头页面header.jsp上有一个搜索框 ... -
该死的黑客
2008-09-22 15:06 1454公司一台对外网服务的linux系统数据库服务器,上周五被人破译 ... -
A Tutorial on Clustering Algorithms
2008-07-02 09:50 3118A Tutorial on Clustering Algor ... -
The Examples for Quartz Time Format
2008-05-16 15:02 1813The Examples for Quartz Time Fo ... -
让人头疼的新手
2008-05-13 11:25 5094刚进公司没多久时,领导让我带两个新人(07年7月份毕业的)。他 ... -
昨天参加了一次面试
2008-05-06 11:40 2976象去年这个时候一样, ... -
开发小记
2008-02-13 15:54 15251. 在oracle中字符串拼 ... -
javascript实现日期操作的工具包
2007-12-13 13:39 3359最近一个小项目中用到了dwr,其中使用到了日期型数据;查了一下 ... -
开发中莫名奇妙的事(八卦)
2007-09-28 08:52 21212007年9月22日 ant进行jar ...
相关推荐
【Liferay Portlet 对象详解】 在 Liferay 平台中,Portlet 是核心组件,它负责呈现内容和提供互动功能。Portlet 技术的理解和应用是开发 Liferay 应用程序的关键。本文将深入解析 Portlet 的关键概念,包括 ...
**Liferay Portlet SDK 5.2.3详解** Liferay Portlet SDK 是 Liferay Portal 平台的一个重要组成部分,它为开发者提供了构建、部署和管理portlet所需的所有工具和技术支持。Liferay Portlet SDK 5.2.3是该系列的一...
Liferay Soy Portlet是Liferay门户平台中一种用于创建动态用户界面的工具,它结合了模板语言Soy和JavaScript框架Dojo。Soy是Google开发的一种声明式模板语言,主要用于生成HTML,它允许开发者以清晰、简洁的方式描述...
《Liferay Portlet 开发——全面指南》:深入解析与实战技巧 本书旨在为开发者提供一份详尽的Liferay Portlet开发指南,涵盖从基础知识到实际应用的全面内容。Liferay是一款开源的企业级门户平台,它支持高度定制化...
在Liferay中,跨页面Portlet之间的调用与数据传递是一项关键任务,因为这涉及到不同Portlet间的协作和信息共享。Liferay提供了多种通信机制,包括PortletSession、Public Render Parameters以及Portlet事件,但这些...
Liferay Portlet工程示例代码提供了开发者们一个深入理解并实践Liferay Portal平台上的portlet开发的宝贵资源。Liferay Portal是一款开源的企业级门户系统,它允许用户创建、管理和集成各种Web应用程序,而portlet...
在IT领域,特别是企业级应用开发中,Liferay作为一个强大的企业门户平台,提供了丰富的功能和服务,其中Liferay Portlet的开发是构建定制化企业应用的关键技术之一。本文将基于提供的文件信息,深入解析Liferay ...
《Liferay Portlet Development Guide 4.3》是针对Liferay Portal平台的一份详细开发指南,旨在帮助开发者理解和创建portlet应用程序。Liferay Portal是一个开源的企业级门户系统,它提供了丰富的功能,如用户管理、...
liferay portlet例子 liferay portlet例子
### Liferay Portlet 开发详解 #### 一、概述 Liferay是一款开源的企业级内容管理系统(Content Management System, CMS),主要用于构建企业门户站点。在Liferay中,Portlet是一种用于显示内容和服务的应用程序组件...
Liferay Portlet是Liferay门户平台上的核心组件,用于创建和展示交互式的Web应用程序。Portlet是portlet容器(如Liferay)中的可重用单元,它可以嵌入到门户页面上,提供各种功能,如内容展示、搜索、用户管理等。...
Liferay5.2.3的样例,通过war.bat打包后发布到相应的liferay环境即可。 另外,需要配置context,tomcat中的代码如下: </Context>
Liferay Portlet开发文档是一份全面介绍Liferay Portlet开发的指南,内容涵盖了Portal的概念、Portlet的定义以及JSR 286(Java Specification Request 286)规范。文档强调了Liferay作为一款开源企业级门户网站解决...
在Liferay Portal环境中,portlet是构建用户界面的基本模块,它提供了与用户交互的功能。"Liferay Portlet 站内消息组件"是一个专门用于在Liferay站点内部实现消息传递功能的portlet。这个组件通常用于增强社交协作...
【标题】:“Liferay Portlet Demo” 在Liferay Portal中,Portlets是可重用的Web组件,它们为用户提供交互式功能。"Liferay Portlet Demo"是一个示例项目,旨在展示如何在Liferay环境中开发、部署和使用portlet。...
**Liferay 简单Portlet详解** Liferay Portal 是一款开源的企业级门户平台,它提供了丰富的功能,如用户管理、内容管理、社交网络等。Portlet是Liferay中的核心组件,是构建门户应用程序的基本模块。这篇博文将深入...
《Liferay Portlet开发参考手册》是温兵先生编著的一本专为开发者设计的指南,旨在帮助读者深入了解和熟练掌握Liferay Portal平台上的Portlet开发技术。Liferay Portal是一款开源的企业级内容管理平台,而Portlet是...
commons-configuration-gae.zip,配置的实现(由apache commons配置库提供),使用google app engine datastore api存储配置参数;配置的实现(由apache commons配置库提供),使用google app engine datastore api...
在"用struts1.X实现liferay portlet插件(HelloWorld)"的项目中,我们将探讨如何将Struts1与Liferay的portlet机制相结合,构建一个简单的portlet插件。以下是一些主要的知识点: 1. **Struts1基础知识**:Struts1的...
Liferay的特点在于其强大的portlet容器,portlet是一种可重用的Web组件,可以集成到门户页面中,为用户提供定制化的功能。 Alfresco则是一个强大的企业内容管理系统(Enterprise Content Management, ECM),它涵盖...