简体   繁体   English

将iframe放在Liferay portlet中

[英]Placing an iframe inside of a Liferay portlet

This is not a technical question whatsoever. 这不是一个技术问题。 What I have done is created an Ext JS application that I wanted to utilize inside of a Liferay portlet. 我所做的是创建一个Ext JS应用程序,我想在Liferay portlet中使用它。 After experimenting and failing miserably trying to import the entire Ext JS project into Liferay, I decided to place the entire application inside of an iframe, and place that iframe easily into my portlet (since portlets can render html). 在尝试将整个Ext JS项目导入Liferay后进行实验和失败之后,我决定将整个应用程序放在iframe中,并将iframe轻松放入我的portlet中(因为portlet可以呈现html)。

This is probably the simplest method, it makes my project much less bulky (not importing the entire Ext JS framework which is about 204MB as well as my application). 这可能是最简单的方法,它使我的项目不那么笨重(不导入整个Ext JS框架,大约204MB 以及我的应用程序)。

Also, it allows for extensibility. 而且,它允许可扩展性。 Whenever I modify my Ext JS application, changes will immediately show in my portlet because an iframe is independent from the main html document. 每当我修改我的Ext JS应用程序时,更改将立即显示在我的portlet中,因为iframe独立于主html文档。

The question(s): Are there any issues I'm overlooking by doing this? 问题:这样做有什么问题我忽略了吗? Any kind of problems that may arise? 可能出现的任何问题?

To me it seems like the easy way out but when I think about it, it's a much smarter approach. 对我而言,这似乎是一个简单的方法,但当我考虑它时,它是一个更聪明的方法。

Cheers mates! 干杯队友!

You're providing some information about decisions that you have made, but not about their reasons. 您提供了有关您所做决定的一些信息,但没有提供有关其原因的信息。 I'm infering some possible reasons to highlight what might be the caveats of this approach: 我正在推断一些可能的理由来强调这种方法可能存在的注意事项:

Let's say you'll have to integrate with Liferay, because that's the existing portal, and you're choosing Ext JS because that's what you're most familiar with. 假设您必须与Liferay集成,因为这是现有的门户网站,而您选择的是Ext JS,因为这是您最熟悉的内容。

This optimizes the development time for the application by making best use of your time. 这样可以充分利用您的时间,从而优化应用程序的开发时间。 If you're the one Ext JS guru in your office, this might be a burden for maintainers. 如果你是办公室里的那个Ext JS大师,这对维护者来说可能是一种负担。 If Ext JS is only one example of a "personal" choice, your portal might end up as a huge pile of "legacy" implementations (which is what I call this kind of solutions). 如果Ext JS只是“个人”选择的一个例子,那么您的门户可能最终成为一大堆“遗留”实现(我称之为这种解决方案)。 So you bought quick development time by drawing from future maintenance effort. 因此,您从未来的维护工作中吸取了快速的开发时间。

Let's say you've chosen to use Ext JS (external to portlet) because nobody in your team could give you a hint on how to do proper portal/portlet development. 假设您选择使用Ext JS(portlet外部),因为您团队中的任何人都无法提供有关如何进行正确门户/ portlet开发的提示。 This should raise a red flag for the team, being unable to support the environment of choice. 这应该为团队带来一个红旗,无法支持选择的环境。 But it can be mitigated, either by choosing a different platform or by proper training 但是可以通过选择不同的平台或通过适当的培训来减轻它

Let's say you're chosen Ext JS because nobody cared and it's a truly "throwaway" application, write-once-run-forever (or run-for-a-limited-time) where nobody expects any maintainance effort and you just want it out-of-the-way. 假设你选择了Ext JS,因为没有人关心它,它是一个真正的“一次性”应用程序,一次性写入(或者限时运行)没有人期望任何维护工作,你只是想要它遥遥。 In this case: Don't worry. 在这种情况下:别担心。

What are you missing? 你错过了什么? You basically don't get anything from the portal environment: Infrastructure, theming, identity management, permissioning, clustering, failover, caching, monitoring etc. It's up to you to judge if this acceptable or not. 您基本上无法从门户环境中获得任何信息:基础架构,主题,身份管理,权限,群集,故障转移,缓存,监控等。您可以自行判断是否可以接受。 Some examples: Will the admins now be required to monitor your independently running application because it can be down independent of the portal? 一些示例:管理员现在是否需要监控您独立运行的应用程序,因为它可以独立于门户网站? Who understands what to do in case it's down? 谁知道怎么做以防万一? How do you handle log in to your application? 如何处理登录您的应用程序?

It doesn't really sound like you're using Liferay or portlets as they are typical are used. 它听起来并不像您使用Liferay或Portlet,因为它们是典型的。 Which asks the question, why are you even using Liferay and portlets to begin with? 问这个问题,为什么你甚至开始使用Liferay和portlet? If you're just writing a JS application, what's the point of this thing in the middle adding an extra layer that you don't know how to work with? 如果你只是在编写一个JS应用程序,那么这个东西在中间添加一个你不知道如何使用的额外层的重点是什么? I dont mean that to be an insult, it just seems like it isn't the right tool for the job, or you need to spend more time learning about Liferay, portlets and how they work. 我不是说这是一种侮辱,它似乎不适合工作,或者你需要花更多的时间来学习Liferay,portlet以及它们的工作方式。

More to your specific questions though: In general, I tend to think of iframe usage as a hack around trying to find a better solution. 更多的是你的具体问题:一般来说,我倾向于将iframe用法视为试图找到更好的解决方案的黑客。 There are some use cases for iframes. iframe有一些用例。 See this question Why do people still use iframes? 看到这个问题为什么人们仍然使用iframe? for more on use cases for iframes. 有关iframe用例的更多信息。

Edit: Gave it some more thought on why I feel this solution isn't as good as it could be. 编辑:更多地考虑一下为什么我觉得这个解决方案不尽如人意。 By serving your application from an iframe that Liferay provides, your changing the architecture of the solution. 通过Liferay提供的iframe提供您的应用程序,您可以更改解决方案的体系结构。 I've used an iframe in a portlet before, so it can offer a solution. 我之前在portlet中使用了iframe,因此它可以提供解决方案。 But we only did so because there was NO other way to get the functionality we needed into our solution. 但我们之所以这样做,是因为没有其他方法可以将我们所需的功能纳入我们的解决方案中。 And this was because it was a limitation of the services we had to connect to. 这是因为它是我们必须连接的服务的限制。 By getting Liferay to serve the application, you can maintain the general architecture of the existing solution. 通过让Liferay为应用程序提供服务,您可以维护现有解决方案的一般体系结构。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM