I'd like to understand how can I customize different pages in the Liferay management screens. For example:
I'd like to add a few fields to images that are being uploaded to the Image Gallery
I'd like to add new field types that I can use when creating new structures (for example, add a "phone number" field type so I can add it to new structures I'd like to create).
Another example would be to customize the Web Content search page and add/remove fields and customize it's look & feel.
Any pointers would be helpful, as I've read most of the stuff about developing for Liferay but could figure our where to start with doing stuff like that (without changing core Liferay files)
I don't think 2) can be done without changing Liferay itself (e.g. patching the source code).
You can customize all built-in JSP pages using so called "JSP Hooks". I have done that to customize the pages for the user administration (mainly removing confusing fields from them).
The basic idea is to provide a modified version of the core JSP page. Upon deploying the hook, Liferay will replace the built-in page with the customized version. When the hook is undeployed, Liferay activates the original page again.
The following pages should have enough information to get you started:
http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/Portal+Hook+Plugins
http://www.liferay.com/community/wiki/-/wiki/1071674/Custom+Fields+and+JSP+Hooks
http://wikis.sun.com/display/websynergy/Customizing+JSPs+using+hooks+plugin
Make sure you search in the Liferay forum as well.
Related
I’m beginning to make a JSP form portlet and I have 2 doubts.
1)
I’ve made a structure and the respective template, and created several web contents with this.
Now I’m creating a JSP portlet to display the web contents, I’m getting all the contents with the JournalArticleLocalServiceUtil.getStructureArticles(), but whenever I add more content, it automatically appears in Live and Staging instead of only appearing in staging.
How can I fix this?
2)
Does Liferay sanitizes all the inputs automatically to prevent SQL injections and XSS attacks?
Thank you.
1) if you're always using the same groupId, you'll always get the same content: The Live and Staging Sites have different group Ids. You'll typically use the "current" groupId, which means the staging one when in staging and the live one when in live.
2) Servicebuilder typically is safe from SQL-injections unless you construct your SQL queries manually. As there are some legitimate uses of scripting content, you'll have to determine the level of escaping user-generated content for yourself, Liferay provides the class HtmlUtil with various escaping methods. Pick the ones you need. For general use, e.g. to sanitize WebContent, Blogs etc., you might want to deploy the AntiSamy plugin from Liferay's Marketplace
I'm working with GAE (Java) in my GWT application.
When my users enter a certain URL I'd like to dynamically create an html page on the server side and serve it to the client.
How can I do this? Using HttpServlet?
I'm quite lost here, do I need to have an html template file on the server side that I dynamically complete and serve to the client?
You should start with the tutorial to learn the basics. You can generate the whole HTML dynamically, but that tends to get awkward. It's better to separate the HTML to a template and fill in the details with the logic implemented in the GAE application.
https://developers.google.com/appengine/docs/java/gettingstarted/
You can use a library like this one https://github.com/alexmuntean/java-url-rewrite . Read the readme to understand more.
You can just take the request and serve anything you want (jsp, jsf, html static). And you can also write gwt code to do actions(effects or ajax for more things. Etc) with the existing html (just add ids to elements) And write another entry point for that page and just include the generated js in your page
I am planning to do a tutorial and POC on how to make a gwt website indexable by google
I am thinking about using GWT in my future project. I have few questions:
How can I define the structure of URLs? Does it allow me to recognize the parts of the URL by some information I have in database? How it is defined? Directly in Java or XML?
Does it support HTML5 history tools to change the URL without the necessity of using hashes?
Forms and editation of items in database - does it allow to generate Forms by definition and generate their validation, without the necessity of writing everything hard by hand?
Are there any tools for uploading files (images) in iframes, so that the page does not have to me reloaded? Drag'n'drop uploading? Are there any tools to simply manipulate uploaded images? Resize, crop...
Is it natively possible to create similar hover information like it can be seen on (for inst. when you hover an item on the left, there is an information bubble appearing on the right side):
http://goout.cz/theatre/prague/
Is it natively possible to create similar search dialog like on the page http://goout.cz - for inst. when you type 'a' it starts to suggest items in the database with their pictures.
All the GWT application I've found, run in browser rather as an JS application - but is it possible for javascript disabled browser to use them? Can search engines go through them?
Thanks
1. How can I define the structure of URLs? Does it allow me to recognize the parts of the URL by some information I have in database? How it is defined? Directly in Java or XML?
It's up to you to code it all (or almost all) by hand, in Java.
2. Does it support HTML5 history tools to change the URL without the necessity of using hashes?
It's possible to do it (quite easily actually) but GWT doesn't provide built-in support.
3. Forms and editation of items in database - does it allow to generate Forms by definition and generate their validation, without the necessity of writing everything hard by hand?
No. Editors cut the boilerplate by half, but you still have to build your forms by hand (but that's not a bad things: generated things never look or behave like you'd like to). And UiBinder helps creating UIs.
4. Are there any tools for uploading files (images) in iframes, so that the page does not have to me reloaded?
Yes.
Drag'n'drop uploading?
Not directly. There's support for native drag-and-drop, but not for accessing dropped files and uploading them. It's not hard to add though.
Are there any tools to simply manipulate uploaded images? Resize, crop...
The canvas API is supported but you'd have to do it all "by hand" (including, particularly, getting the image to draw it to the canvas, and then upload the canvas content)
5. Is it natively possible to create similar hover information like it can be seen on (for inst. when you hover an item on the left, there is an information bubble appearing on the right side): http://goout.cz/theatre/prague/
Yes.
6. Is it natively possible to create similar search dialog like on the page http://goout.cz - for inst. when you type 'a' it starts to suggest items in the database with their pictures.
Yes.
7. All the GWT application I've found, run in browser rather as an JS application - but is it possible for javascript disabled browser to use them?
No.
Can search engines go through them?
Google can, with little effort.
I am starting using Liferay Portal and I have two basic needs which I would like to achieve with Liferay.
Is there a posibility to add content to CMS through API level? I would like to insert some data "from code".
More important. How to achieve such situation that for every created user there will be its own homepage generated with some predefined template elements on it?
I have tried to Google something so far, but I did not find it helpful. Maybe some keywords?
After some analysis of documentation devoted to services and ServiceBuilder I realized that it is not what I want.
Let me show an example based on Websphere.
In Websphere we have bunch of EJB components available to perform some actions, exchange information with portal, easy to use. Isn't there any similar mechanism in Liferay not involving web services?
My recommendation for this kind of question is to take a look at the sevencogs-hook sourcecode. The structure of this hook is basically just a long script that runs once, setting up a complete demo site with users, sites, pages, content etc. The code runs once (after the first deployment) and then never again. There are no (obvious) conditionals, no context to understand etc.
You can basically just step through everything and - in that process - understand how content (and pages, images, blog posts, etc.) are created and positioned on pages in Liferay.
This hook accesses the Java API, a very similar API is available through Webservices. Basically all of Liferay's portlets also use the same API to do their business.
Edit: Additional information to keep this answer valuable/current: Sevencogs is discontinued, but still available in old releases (source & binary). The API has slightly changed, so compiling/running it will need a bit of work. James Falkner has blogged about the leftovers and lessons learnt - those snippets are extracted from sevencogs and contain the relevant code pieces to work with the API.
Looking at this page from the documentation: It smells like a SOAP interface (they mention some sort of document uploader service and I've read axis).
You'll find some url examples that should give a list of available webservices.
For number 1, you can use the one of the:
JournalArticleLocalServiceUtil.addArticle()
methods to programmatically add Liferay Web Content from a portlet. If you download the Liferay Portal Source you can see the structure of these methods.
For number 2, can create page templates with preconfigured portlets on them (through the Plugins-SDK), and then use the API to programmatically create the pages using one of the:
LayoutLocalServiceUtil.addLayout()
methods.
If you have any more speific questions about these comment back, and I hope this helps!
I am having trouble understanding the concept of portlets in a CMS.
Let's say I write a weather portlet to display current temperature. I build it, package it in a war, deploy the war in Liferay.
Now I created a page, and I want to create 2 instances of the portlet I wrote. I want to display the weather in Seattle and the weather in Miami.
Can I do this? How do I pass the portlet a parameter to tell it which city to display?
Portlet has so-called EDIT-mode. You can implement EDIT mode to show the form to choose which city you want to show the temperature for. Save this to portlet preferences. And when you will render the portlet in normal(VIEW) mode, look at the preferences for the city.
http://portals.apache.org/pluto/portlet-api/apidocs/javax/portlet/PortletPreferences.html
http://onjava.com/pub/a/onjava/2006/02/01/what-is-a-portlet-2.html?page=2
Another option is PortletConfig - which is generally configured in portlet.xml and is similar to Servlet init params. Preferences is probably your best bet.
If you're working in Liferay in particular, LR's model-builder infrastructure will get you much of this functionality including editing quick/cheap at the cost of cross-container portability. On the plus side it will integrate well with LR's (limited) RBAC which tends to be important in distributed content authoring environments