I'm asking a question about portlet version 2.0 and 3.0 in the fragment-host.
I'm using Liferay 7.2.1 GA2.
For example, this one :
Fragment-Host: com.liferay.users.admin.web;bundle-version="4.0.27"
In the init.jsp, I have :
<%# taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
But since Liferay 7.1, it should be (cf Breaking Changes) :
<%# taglib uri="http://xmlns.jcp.org/portlet_3_0" prefix="portlet" %>
For now I don't made this change and I've the following error : Requires 3.0 opt-in
Do I made this change or is there another solution ?
Thanks,
With a fragment, you'll update/modify a JSP that belongs to a (typically) stock portlet. This overriding JSP needs to follow the standard that the overridden portlet sets.
In other words: If you try to provide a Portlet-2.0-spec JSP to a Portlet following the 3.0 specs, you might not find what you expect, and apparently get the error message that you report.
In general: If you override JSPs, you're dealing with implementation level changes to the code that Liferay delivers - there's a lot of maintenance effort connected to it, and this is one of the prices you'll have to pay
Related
In my Adf application I need to use a javascript component called ckeditor (http://ckeditor.com/). Ideally I would like to use it on a facelet page (not a jsp page). It seems like this can be achieved by using ck-jsf-editor (https://code.google.com/p/ck-jsf-editor/). The problem is that I can't figure out how to add this library/taglib to my Adf application.
Anyone knows the best way to do this?
In JDeveloper, you need to add the JAR that contains the JSF component to the project properties under the JSP tag libraries section.
If you are on JDeveloper 11.1.2 or 12c then your ADF application can already use facelets.
I trying to create a custom tag the Java way, by extending TagSupport. I'm want to use the custom tag to render some html in a xhtml file which also used RichFaces and JSF.
All the tutorials I've seen regarding custom tags you register then in a jsp page via:
<% taglib prefix="example" tagdir="/WEB-INF/tag-descriptor.tld" %>
However this does not work in xhtml documents. I've seen the custom xhtml tags based on xhtml snippets, but I really need logic in the code.
So how do you register a jsp tag lib in jsf? Is this possible? And if not, is there anyway to script java in a xhtml page as you do with jsp?
For a Facelet (.xhtml) you can't register a JSP tag lib.
Facelets is a completely different technology than JSP and those two are not compatible in any way where it concerns artifacts that are specific to each technology (like javax.servlet.jsp.tagext.TagSupport).
However, what's behind a custom JSP tag for JSF is a component, and you can of course author these in Java for Facelets. It boils down to creating a component directly in Java and then registering this in a *-taglib.xml (for JSF 2.2, this registration in an XML file won't be needed anymore).
See Simple Java based JSF custom component for more info.
I copied jquery.js to WebContent/js/jquery/jquery.js. Now I want to use that file in certain portlets. To do this I created a liferay-portlet.xml that looks like this:
<?xml version="1.0"?>
<!DOCTYPE liferay-portlet-app PUBLIC
"-//Liferay//DTD Portlet Application 6.0.0//EN"
"http://www.liferay.com/dtd/liferay-portlet-app_6_0_0.dtd">
<liferay-portlet-app>
<portlet>
<portlet-name>MyPortletName</portlet-name>
<header-portal-javascript>/js/jquery/jquery.js</header-portal-javascript>
</portlet>
</liferay-portlet-app>
If I access the portlet Liferay generates this line:
<script src="/js/jquery/jquery.js?browserId=firefox&minifierType=js&languageId=en_US&b=6100&t=1326630657000" type="text/javascript"></script>
That leads to a WARN [404_jsp:?] /js/jquery/jquery.js in the logging console.
Is it really correct that the URL looks like this? If I had two war-files, both containing a js-file with the same path, how would Liferay distinguish those two?
What do I need to do to get my setup working?
Using Liferay Portal Community Edition 6.1.0 CE (Paton / Build 6100 / December 15, 2011)
Use
<header-portlet-javascript>/js/jquery/jquery.js</header-portlet-javascript>
isntead of
<header-portal-javascript>/js/jquery/jquery.js</header-portal-javascript>
if you put js-files in to portlet
Because regarding comments in DTD, header-portal-javascript sets the path of JavaScript relative to the portal's context path. And header-portlet-javascript sets the path of JavaScript relative to the portlet's context path.
The location for jQuery looks incorrect.
If you're bundling this with your own plugin named foobar-portlet the correct path would be (provided that you use the same liferay-portlet.xml):
foobar-portlet/docroot/js/jquery/jquery.js
Two things:
jQuery is bundled with Liferay 5, check the version of Liferay and which jQuery version it has bundled and see if this meets your needs. However I believe it's not in Liferay 6 or 6.1, but I could be wrong about that.
And:
If you want to have a JavaScript library available to all of your portlets you're better off adding it to the theme(s) that you use rather than the portlets. This way it will be globally accessible. The downside is that if you're distributing your portlet then you should make people aware of this dependency.
Otherwise if you just want it available to a small group of your portlets, then follow what RP said.
Here's some good reference on using jQuery with Liferay 6.
I was wondering if it's possible to add JSF components to the tag library programmatically?
I'm implementing a plug-in mechanism in our application. And now, if I create a JSF component in the plug-in, I need to change the components taglib xml file in the main application, which is not the goal.
I'd rather like to put a components taglib xml file inside a plug-in which is then handled by the main application. Is there any way to do that?
The reason why I'm asking this is the following:
In our application, we send secure messages through a web interface. The messages are created by filling out forms, which are, in most cases, generated. But some forms have special behavior and we don't want to release the whole application if a new 'special form' is implemented, so we decided to put these in plug-ins.
Thanks for any help.
Cheers,
Andreas
Something like the following
xmlns:jsp="http://java.sun.com/JSP/Page"
seems to not work, any hint? alternatively how can I inject beans into JSF lifecycle flow at startup without the filter usage?
What is the namespace to use for
adding JSP taglib support into
facelets pages?
You cannot. Facelets are not JSPs and do not use JSP tag libraries. From the project page:
The difference is under the hood where
all the burden of the JSP Vendor API
is removed to more greatly enhance JSF
performance and provide easy
plug-and-go development.
how can I inject beans into JSF
Add them to your WEB-INF/faces-config.xml file using managed-bean elements.