JBoss.orgCommunity Documentation
This is a very rough documentation issued from the merge, content still has to be validated, we still hope that it can help the beta testers. Thanks !
GateIn portal is a merge of two mature projects that have been around for a while, JBoss Portal and GateIn Portal. It takes the best of both into a single new project. The aim is to provide both an intuitive portal to use as-is and a portal framework to build upon depending on your needs.
GateIn homepage: www.gatein.org
GateIn videos: www.jboss.org/gatein/videos.html
GateIn documentation: www.jboss.org/gatein/documentation.html
GateIn downloads: www.jboss.org/gatein/downloads.html
Portal is the Web-based application software that provides users with personalized User Interface(UI). Through this UI, users can easily access, search, communicate with other users, applications and informations.
The portal is responsible for UI management, personalization and aggregation of enterprise contents and business applications.
Portal has two main components:
A portlet is a web application. Portlets are pluggable user interface components that are managed and displayed in a portal. Portlets produce fragments of markup code aggregated into a portal page. Typically, a portal page is displayed as a collection of non-overlapping portlet windows, where each portlet window displays a portlet. Hence a portlet (or collection of portlets) resembles a web-based application hosted in a portal. The content generated by a portlet can vary from one user to another depending on the user who configures that portlet.
GateIn has created standard portlets that can be plugged into any portal.
A navigation is a menu that helps users to visualize the structure of a site and provides hyper links to quickly move from page to page. There is a bar which contains navigations called Navigation bar. There are three navigation types:
A gadget is a mini web application running on a platform and an user can put it in a web page. GateIn Portal provides some useful gadgets such as:
Calculator gadget : This is the coolest calculator for your page. This mini-application lets you perform most of the basic arithmetic operations and also offers cool skins to make your page more alive.
Calendar gadget : A cool calendar help users keep track of date. You also can switch easily between daily, monthly and yearly view and change skin that you like.
Todo gadget : This mini-application helps you organize your day and work group. It is designed to keep track of your tasks in a convenient and transparent way. You can highlight tasks by coloring tasks with different colors.
RSS Reader : This gadget lets you get a sneak preview of your favorite feeds from the web. You can get the latest news, the latest posts from your favorite blogs, the latest email...all in one gadget. This gadget is a web based for receiving and viewing RSS feeds.
GateIn Portal has two modes:
There are two permission types:
There are several permission levels:
Portlets are pluggable user interface components that are managed and displayed in a portal. Functional Portlets support all functions of a Portal. GateIn Portal provides users with the following portlets:
This Portlet allows users to register a new account. Moreover, it also used to support users to choose a preferred language for displaying the Portal interface.
This Portlet is used to manage user information, groups of users and memberships.
This Portlet is used to manage different application categories. You can add, edit, set permissions, delete a category and its applications.
This Portlet is used to define a word or a phrase of a current language to an expected language.
This Portlet supports administration actions in GateIn Portal.
The Star Toolbar Portlet helps users to change language, change skin or sign out GateIn Portal.
These Portlets constitute the interface of the Portal. GateIn Portal consists of the following Interface Portlets:
This Portlet is considered as the welcome gateway of a Portal. It contains the organization's slogan, logo, icon, button, etc.
This Portlet is used to display the path of the selected page from Navigation.
This Portlet provides the footer for a site. Footer can be a text, images that are displayed at the bottom of a web site. It provides information about author/institutional sponsor, revision date, copyright, comments form, and navigational links.
This Portlet is used to provide a home page for a portal. The home page is a main page displayed firstly when you visit the site.
This Portlet is used to create IFrame elements for a site. Iframe is a HTML element which can embed a document into a HTML document. So embedded data is displayed inside a sub window of browser window.
This Portlet provides a navigation bar. A navigation likes a menu that helps users to visualize the structure of a site and provide links to quickly move from page to page.
This Portlet is used to provide a site map page of a web site. It lists pages on a website, typically organized in hierarchical fashion.
This Portlet provides web-browser for users. It allows users to connect to other sites over Internet.
This portlet is used for hosting mini - applications known as gadgets. The dashboard uses a variety of graphical effects for displaying, opening, and using gadgets.
See more details in Dashboard Portlet
All its common used functions (like Word editor) such as writing, formatting text, creating tables, inserting links or picture, etc.
See more details in FCK Portlet
The Dashboard portlet is used for hosting mini applications known as gadgets. The Dashboard uses a variety of graphical effects for displaying, opening and using gadgets. Gadgets can be moved around, rearranged, deleted and created. More than one instance of the same gadget can be opened at the same time, each instance of the very same gadget can have different settings. The gadgets instances are as independent as different portlets instances.
Click on Add Gadgets to open the Dashboard Workspace.
This portlet includes two parts :
Figure 3.1. A popup window that lists all gadgets. By default, there are four gadgets but you can add more.
A space used to contain and organize gadgets by dragging from the popup window and drop them into this space.
Moreover, you can change the number of columns to create in this space.
Click on Group Editor : Edit Page
Click on Edit Portlet . It will show a dialog to change the number of columns to display gadgets.
Change the number of columns and click the Save button to accept changing.
You can also add more gadgets, do as follows:
Open the popup to add gadges
Click the Add Gadgets link
dialog to add a new gadget will appear :
Enter a link (a .xml or .rss) in a text box on the left pane.
Remote gadgets can be only created using the .xml file format which s the standard gadget format.
Click on the + icon to add a new gadget to the gadget list beneath.
GateIn Portal provides users with FCK portlet used as a lightweight text editor in the web pages. All its common used functions (like Word editor) such as writing, formatting text, creating tables, inserting links or picture, etc.
FCK portlet also consists of some main elements:
The area at the top of the editor which contains many different buttons. You will use these buttons to activate the program functions.
This area is under the toolbar. This area allows typing your text and format document.
It is a menu with the functions that will appear when you right click anywhere in the space of editing area or an existing object.
Small windows appear when some of the functions are activated, it is used to provide the necessary information to accomplish that functions. For an example: To insert a link, you need to open Link dialog by clicking!images/LinkIcon.png! icon on the Tool bar :
If you are a visitor of GateIn Portal, you only may read news or take some normal actions. Thus to access and get more actions, you should register and contact with administrators to get more permissions!
GateIn Portal supports users to register a new account by themselves quickly and easily. Just by completing the steps below, you will have a new account that helps you access more pages and take more actions in GateIn Portal:
Go to a portal by typing the URL in the address bar (e.g: http://localhost:8080/portal).
Click Register on the Navigation bar. The Register page will appear:
The Account Setting information includes:
Name | Description |
User Name | the name that the user uses to login. This field must be unique and start with a character |
Password | The *Password* must be between 6 and 30 characters and can contain space characters. Since Portal 2.6, space characters are either at the beginning or in the end can be counted. |
Confirm Password | re-type the password above. *Password* and *Confirm Password* must be the same. |
First Name | the first name of a user. |
Last Name | the last name of a user. |
Email Address | the email of a user. It must be in the right format likes username@abc.com |
Fill in the form.
Click the magnifying glass icon !images/magnifyIcon.png! to search and check if the chosen username is available.
Input values in the User Profile tab, include: Profile information, Home information, Business information. These fields are not required.
GateIn Portal facilitates users with 4 commonly used languagues: English, French, Vietnamese and Arabic in the Language field. You can select one of these languages to work with.
Click Save to register a new account or Reset to refresh all entered values. There will be an alert message and you can not add a new account if one of these cases occurs:
After adding a new account, you should either contact the administrator to get more permissions or you are only a visitor user.
TODO
There are two ways to change the account information:
All users can follow this guides to change your account information.
To change your account information, you just click on your account:
The Account Profiles form will appear:
If you want to change your Account Profiles :
1. Select the Account Profiles tab. It will display your current basic information.
2. Your User Name can not be changed. You can change these fields: First Name , Last Name and Email .
3. Click the Save button to accept changes.
If you want to change your Password :
1. Select the Change Password tab, it will display a form:
2. Input your current password to identify that you are the owner of this account.
3. Input your new password, it must have at least 6 characters
4. Reinput your password in the Confirm New Password field.
5. Click the Save button to accept changes.
After registering your account, you can easily sign in GateIn Portal to go into your private mode:
1. Go to a Portal in the public mode by inputting URL in the address bar (e.g: http://localhost:8080/portal)
2. Click the Sign in link at the top right of a page if you are current in the Classic portal. The Sign in form appears:
3. Input your registered User name and Password .
2. Select the Remember My Login check box when you sign in GateIn Portal at the first time if you want to automatically return to GateIn Portal without signing in again. You can see Remember User Account for more details.
3.Click the Sign in button to accept or Discard to escape the Sign in form.
Details:
Field | Description |
User name | The registered user name. |
Password | The registered password. |
Remember My Login | This option allows users to return to GateIn Portal and be automatically authenticated based on the value of a cookie provided by the browser. Thus users do not have to perform an explicit authentication again. |
Forgot your User Name/Password? | To follow some steps to get the forgotten user name or password. Please refer [Portal:Account and Password Retrieval] for more details. |
Sign in | To sign into GateIn Portal with user name and password. |
Discard | To close the *Sign In* form. |
In case, User Name does not exist or the inputted User name/Password is invalid, there will be an alert message requires you to input the right value. To login again, you click the OK button on the alert message and enter User Name and Password again.
After signing in, you will be redirected to the authenticated homepage:
After signing in, you will be redirected to the authenticated homepage and welcomed with your full First Name and Last Name:
This function lets you get back to the anonymous portal. It ends your current portal session.
In the upper left corner of the screen, click Sign out :
This feature is really useful when you forget your account or password by recovering it quickly through following simple steps:
1. Show the form that guides you step by step in recovering your User name/ Password by clicking the link 'Forget your User Name/Password?' beneath the Password field of the Sign in form.
This form offers two options to select:
2. Select one of two options in this form.
3. Click the Next button to go to the next step:
4. Enter a value in the field of this form.
5. Click the Send button to send the entered values.
After information is sent, you will be received an email with your User name/ Password in your email address that you registered.
The User name/Password that you received only have effect on 1 day. It means if current date is over 1 day from received date, you can not use the received User name/ Password thus you have to get another email active.
This feature allows users to return to the GateIn Portal and be automatically authenticated based on the value of a cookie provided by the browser. Thus users do not have to perform an explicit authentication again.
1. Input your registered User name and Password .
2. Select the Remember My Login check box when logging in GateIn Portal at the first time.
3. Click the Sign in button to sign in the portal.
You must remember escaping the browser without signing out. The next time, you can automatically sign in the portal without signing in again with your first/last name welcome.
The convenient Toolbar helps users and administrators to manipulate all actions quickly.
You can change language, change skin and sign out from GateIn Portal.
It shows all different sites available in GateIn Portal allows users to directly edit the navigation tree.
Users can easily see and access pages in GateIn Portal.
You easily edit a page or add a new page
With the Edit Inline Composer popup that consists of two tabs: Applications and Containers, it is convenient for a user to select the component that he wants and to drag and drop it to the page.
You also quickly edit, delete portlets in a page, change portal's properties or switch the view mode.
It is so difficult to manage and set permissions for a great number of registered users in a system. To solve this problem, GateIn Portal helps Administrators manage users, groups and memberships easily as well as effectively.
Go to Administration / Community Management (or Organization/Management). The Organization form appears:
Select the User Management tab in the Organization form. By default, it will show all existing registered users. With User Management , you can see all existing registered users, and also search, edit, delete them. For each user, you can see his groups and his memberships (roles) in these groups. You can not add users to a group but you can remove them from the group.
The Administrator can search users by user name, first name, last name or email address.
1. Type the search term related to the user that you want to search. You do not need to enter an exact term.
2. Select the field in which you would like to search
3. Click the magnifying glass icon!images/SearchIcon.png! to perform searching. It will return a searching result in form.
1. Click the edit icon!images/EditIcon.png! corresponding to the user that you want to edit.
2. Select the Account Info tab to view and change the essential user information .
3. Select the User Profile tab to view and change profile information. The Language field is used to set the display language of that user.
4. Select the User Membership tab to see user's information in groups.
5. Click the Save button to accept changes.
1. In the User Management form: Click the trash can icon !images/DeleteIcon.png! corresponding to the user that you want to delete.
2. Click the OK button in the confirmation message to confirm or the Cancel button to quit without deleting anything.
Select the Group Management tab in the Organization form.
By default, all existing groups will be displayed on the left pane. This tab is used to add new, edit or delete a group. The right pane shows information about the selected group including information about the members in the specific group and a small form to add a new user to a group.
1. Choose the path to create a new group by selecting the groups from list on the left pane or clicking the arrow icon !images/ArrowIcon.png! if you want to create a group in a higher level. The selected path is displayed in the path bar.
2. Click the Add New Group icon. The Add New Group form will be displayed on the right pane:
Name | Description |
Group Name | The name of the new group. This field is required and any length from 3 to 30 characters is allowed. |
Label | The display name of the group. Any length from 3 to 30 characters is allowed. |
Description | The description about the group. Any length from 3 to 30 characters is allowed. |
3. Fill in the required fields. Only alpha, digit and underscore characters are allowed for the Group Name field and it must be unique.
4. Click the Save button to accept entered values or the Cancel button to quit.
1. Select the path to the group you want to edit by selecting the groups from list on the left pane.
2. Click the edit icon!images/EditIcon1.png! to show the Edit Group form of the selected group. This form is identical with the New Group form.
3. You can not change the Group Name. Make changes for a Label or a Description field and then click the Save button to accept changes or the Cancel button to cancel changes and return to the Group Info form.
1. Select the path to the group you want to edit by selecting the groups from the list on the left pane. The Group's information is displayed including the user list and a form which allows to add a new user.
2. Enter the exact user name of the user that you want to add to the selected group or you can enter some characters if you are not sure about the exact spelling.
3. Select the membership for the user in a group from memberships list. The refresh icon!images/RefreshIcon.png! can be used to update the memberships list in case there are any changes.
4. Click the Save button to accept adding the selected user to a specific group with the selected membership type.
1. Click the edit icon!images/EditIcon.png! corresponding to a specific user with a membership in the Group Info table to open the Edit Membership form :
2. Change the membership of the selected user by selecting another value in the Membership field.
3. Complete editing the selected user by clicking the Save button.
1. Select the path to the group you want to delete by selecting the groups from list on the left pane.
2.Click the trash can !images/DeleteIcon.png! icon in order to delete.
3.Click the OK button on the confirmation message to accept or the Cancel button to quit without deleting.
The roles of an user in the specific group are managed in Membership Management form. Currently there are three membership types: Manager, Member and Validator. By default, Manager has the highest rights in a group. You can add new, edit or delete a membership type. Select the Membership Management tab in the Organization portlet. There will be a membership type list and a form to add new/edit:
1. In the Add/Edit Membership form at the bottom, the input value for the membership name field (required) and the description field (optional). Only letters, digits, dots, dashes and underscores are allowed for the membership name.
2.Click the Save button to accept adding the new membership or click Reset button to clear the entered values.
1. Click the edit icon!images/EditIcon.png! in the row of the membership type you want to edit. The selected Membership type information is displayed in the Add/Edit Membership form.
2. Make changes in this form.
3. Click Save to accept changes.
1. Click the trash can icon in the row of the membership type that you want to delete.
2. Click the OK button in the confirmation message to accept the deletion.
Permissions play an important part in accessing and performing actions in the Portal. Depending on permissions assigned by an administrator, users can either access or edit portals, pages and portlets. GateIn Portal have applied several permission levels:
The three above permission levels helps users assign access and edit permissions clearly and flexibly.
You have to set permission for new portals as well as existing portals:
For new portals: on the Toolbar select Site then click on the Add New Portal button, select the Permission Setting tab then the Access Permission Setting sub tab.
For existing portals: on the Toolbar click Site Editor then Edit Page . Click on View Page properties then select the Permission Setting tab.
If you do not want everyone to access the Portal, do not select the Make it public check box and you have to select group by group. Do as follows:
Click the Add Permission button.
After selecting a membership type, the selected permission is displayed in the access permission list. Each time, you only can select one group with one membership type. If you want to add more, click Add Permission and select again.
Only users who are in the portal editor group can edit that portal. Access rights can be given to several groups but edit rights can only be given to a group with a membership type (or every membership type by select ). To assign an edit permission to a user, you must add him to the editor group of the respective portal.
Use one of these following paths to assign permissions on a portal:
Click Select Permission to choose a group.
Select a group and a membership type (select if you want to assign all membership types for the selected group). After selecting the membership from the right, the selected information is displayed.
4. Click on the Save button to accept.
In some cases, permissions on a page are initialized and users who have the edit permission can change the page.
When you have access permission on a specific page, you can access that page which other users can't access it because they are not given that permission.
These following path help you quickly set access permission for a page:
To be able to access a page (read the page content or take an action on the page), users have to be in one of the groups that have access permission to that page. There may be several groups that have access right to a page.
If you allow anyone to access the page tick on Make it public , otherwise, you have to select the groups one by one.
Only users who are in the page's editor group can edit it. The access right can be set for several groups but the edit right only can be set for one single group. To give a user the edit permission, you must add him to the editors group of that page.
Click the Select Permission button to set new or change another group.
Select a group with a membership type (select if you want all membership types in a selected group)
After selecting a specific membership from the right, the selected information is displayed.
Click the Save button to accept.
Follow these below steps to set access permission on a portlet:
Select Group --> Administration --> Application Registry on the navigation bar
Select a category on the left pane that includes the portlet you want to set right. Then all portlets of the selected category are listed immediately and detail information of each portlet is displayed on the right pane.
To set permissions for a portlet:
GateIn Portal skins are graphic styles that help users display an attractive user interface. Each skin has its own characteristics with different backgrounds, icons, etc. In order to be user-friendly and flexible in use, users are allowed to change their skins without having edit rights on the portal.
1. Go to GateIn Start -> Administration -> Advanced --> Edit Current portal
2. Click the edit icon!images/EditIcon.png! to edit portal properties.
3. In the Portal Setting tab: select one skin type in the Skin list field to change and display a skin.
4. Click Save and Finish icon !images/Finish1.png! so that the modification can take effect.
1. Click Edit Inline on the Toolbar. The Edit Inline Composer will appear.
2. Click Portal Properties to edit portal's properties.
3. In the Portal Setting tab: select one skin type in the Skin list field to change and display a skin.
4. Click Save and the !images/DiskIcon.png! icon so that the modification can take effect.
1. Go to GateIn Start -> Administration -> Skin Settings.
1. Go to GateIn on the Toolbar --> click Change Skin.
The Skin Setting form is displayed with a list of all supported skins. The left pane contains the skin list and the right pane is used to display the template of the selected skin.
2. Select one by clicking on the skin's name.
3. Click the Apply button and wait for few seconds to take effect.
In order to understand clearly about what the navigation is and navigation types that GateIn Portal supports, please refer the Navigation concept page.
The page navigation of a portal is created automatically when a portal is created.
Only users who have the edit right on a portal can perform this action.
Follows these below guides to edit a portal 's navigation:
1. Go to GateIn Start-> Administration -> Advanced--> Edit Page and Navigation.
2. Select Portal navigation in list on the left pane (eg: portal: classic's Nav).
3. Right click the blank space on the left pane and select Edit Navigation in the menu:
The form for editing the portal navigation will be opened:
Notice: The number that users select in the Priority field is the priority of a page navigation on the Navigation bar.
4. Make changes to fields in this form: Description, Priority.
5. Click the Save button to accept changes.
6. Click the!images/OKIcon.png! to take effect of new changes.
Or click the Cancel button to quit without saving any change.
No one can create the portal's page navigation so no one can delete it. A navigation is deleted automatically after you delete its portal.
Each group has only one page navigation. Only users of that group have the "manager" membership can create/edit/delete navigation for that group
1. Go to GateIn Start -> Administration -> Advanced --> Edit Page and Navigation.
2. Select a Group navigation in the list on the left pane (eg: group:platform/administrator's Nav). All pages of this group will be listed underneath.
3. Right click the blank space on the left pane and select Edit Navigation in the context menu:
The form for editing the group navigation will be opened:
4. Make changes for two fields: Description and Priority.
Notice: The number that users select in the Priority field is the priority of a page navigation on the Navigation bar.
5. Click the Save button to accept any changes.
6. Click the!images/OKIcon.png! to take effect new changes on the Navigation bar.
Or click the Cancel button to quit without saving any change.
The page navigation of a user is created automatically when a user is created (registered). So an administrator don't have to create it.
Only the user who is the owner of the user page navigation can edit it.
No one can create user's page navigation so that no one can delete it. A user's navigation is deleted automatically when its user is deleted.
If you are allowed to access GateIn Start in the User Workspace, you can take all actions related to a node such as : add a new node, edit, copy, cut, delete and clone node.
1. Go to GateIn Start -> Administration -> Advanced --> Edit Page and Navigation
2. Select a navigation from the navigation list.
3. Select a node from list (to create a new node like sub-node of the selected node) or click the icon!images/UpIcon.png! to create a new node on root
4. Right-click on the selected navigation or node and select Add new Node option. Add new node form appears:
The Page Node Setting tab includes:
Name | Description |
Uri | An identification of the node. The Uri is automatically created after adding a new node |
Node name | The name of the node. This field is required and must be unique. Only alpha, digit and underscore characters are allowed for this field and it must have at least 3 characters. |
Label | The display name of the node on the screen. This field is not required and may be changed. This field must have a length between 3 and 120 characters. |
Visible | This check box allow to hide (and show) the page and its node at the navigation bar, the page navigation and the site map |
Publication date & time | This option allows publishing this node for a period of time. *Start Publication Date* and *End Publication Date* only appear when this option is selected. |
Start Publication Date | The start date and time to publish the node. |
End Publication Date | The end date and time to publish the node. |
In the Page Selector tab, you can select a page or not for this node.
Name | Description |
Page Id | The identification string of the page. |
Name | The selected page's name. |
Title | The selected page's title. |
You do not have to input values in these fields. It is automatically displayed after selecting an existing page by clicking the Search and Select Page button. The Select a page form appears like:
After configuring the page node settings, the page selector and the node's icon, click the Save button to accept or the Cancel button to quit without creating a new node.
1. Go to GateIn Start -> Administration -> Advanced --> Edit Page and Navigation
2. Select a navigation from the navigation list.
3. Right-click on the selected node and select Edit this Node option.
It will displays a form to edit this node:
In the Page Node Setting tab: you can change the value of these fields: Label, Visible and Publication Date & time. After finish changing, click the Save button to accept changing or Cancel button to refuse it.
In the Page Selector tab : you also search and select another page for this node by clicking the Search and Select Page button. You can see more details on how to select a page for a node on the above Add a new node section. After finish changing another page for this node, click the Save button to accept changing or Cancel button to leave without saving any changes.
You also easily copy a node by following these steps:
1. Go to GateIn Start -> Administration -> Advanced --> Edit Page and Navigation
2. Select a navigation from the navigation list.
3. Right-click on the selected node and select Copy node option.
4. Select the position that you want to paste this node and select Paste Node option. Click the!images/MarkIcon.png! icon to Save.
1. Go to GateIn Start -> Administration -> Advanced --> Edit Page and Navigation
2. Select a navigation from the navigation list.
3. Right-click on selected node and select Clone node option.
4. Select the position that you want to paste this node and select Paste Node option. Click the!images/MarkIcon.png! icon to Save.
In Manage Pages you will see:
1. Go to GateIn Start -> Administration -> Advanced --> Edit Page and Navigation
2. Select a navigation from the navigation list.
3. Right-click on the selected node and select Cut node option.
4. Select the position that you want to paste this node and select Paste Node option. Click the!images/MarkIcon.png! icon to Save.
1. Go to GateIn Start -> Administration -> Advanced --> Edit Page and Navigation
2. Select a navigation from the navigation list.
3. Right-click on the selected node and select Delete node option.
It will display an alert message, click the OK button to accept deleting or Cancel button to quit without deleting a node.
You can easily change the position of node on the navigation bar on their own convenient order by following these steps:
1. Go to GateIn Start -> Administration -> Advanced --> Edit Page and Navigation.
2. Select a navigation from the navigation list.
3. Select the node that you want to move. Right click on the selected node and then click on Move up or Move down
The selected node will be moved up/down.
Only by using one page list can users add, edit, delete and view quickly and easily which pages you like to. Following these guides to manage pages:
You easily add a new page by following these simple steps:
1. Go to GateIn ->Administration -> Advanced --> Manage Pages
1. Go to Administrator on the Toolbar --> Manage Pages
Details
Button | Description |
Add New Page | allows you to add a new page. |
Back | allows you to return to home page. |
2. Click the Add New Page button.
3. Enter values for fields in the Page Setting tab
Name | Description |
Page Id | The string to identify the page. It is automatically generated when you will finish creating page. |
Owner type | The owner type of the the page (portal, group or user). The "User" type is displayed by default. You can change the owner type by clicking on the icon. |
Owner Id | The identification name of page owner. When the owner type is "group", there will be a list of groups of which you have to select one. |
Page Name | The name of the page. This is a required field and must be unique. Only alpha, digit and underscore characters are allowed to be used for this field and it must have a length between 3 and 30 characters |
Page title | The title of the the page. This field is not required and must have a length between 3 and 30 characters. |
Show Max Window | The option allows to choose whether showing the page in maximum size or not. |
If the Owner type is "portal" or "group":
4. Click the Save button to accept creating a new page or the Cancel button to quit the form.
1. Go to GateIn Start -> Administration -> Advanced --> Manage Pages
2. In the existing pages list: click the edit icon on the row of page you want to edit.
Indicator | Meaning |
!images/PreviewPage.png! | Preview page: allows viewing node's page with preview mode in a Normal Page |
!images/EditPage.png! | Edit page properties: allows editing node's page properties |
!images/ShowContainer.png! | Show container: allows to list all existing containers that will be used to change the layout of a selected page |
!images/ShowPortlet.png! | Show portlet: allows to list all existing portlets that will be used to re-arrange the content of selected page. |
!images/SavePage.png! | Save page: allows saving changes of a page |
!images/Back.png! | Back: allows returning to the page list without saving |
!images/Finish.png! | Finish:allows saving and returning to the page list |
In the Page Setting tab:
Name | Description |
Page Id | The string to identify editing page. This string is generated automatically, user can not change. |
Owner type | The type of editing page. User can not change. |
Owner Id | The identification name of page's owner. User can not change. |
Page name | The name of the page. User can not change. |
Page title | The title of page. User can change and it must have length from 3 to 30 characters. |
Show Max Window | The option allows whether showing page in maximum size or not. User should check this option for desktop page only. |
Click !images/ShowContainer.png! icon to show current container layout of selected page on your right and all the container layouts list on the left pane.
If you want to change current layout, select a layout type from the list on the left pane, then left click on the template you want and drag and drop it into the right pane. New container will be displayed on the right pane. You can change position of current container by left click and drag and drop it to another place on the right pane or remove current container by clicking delete icon on the right corner.
Click !images/ShowPortlet.png! icon to show current portlet layout of page.
If you want to change current layout, select layout type from the list on the left pane, then left click on the template you want and drag and drop it into the right pane. New portlet will be added and displayed in the right pane. You can change position of current portlet by left click and drag and drop it to the place you want on the right pane or remove current portlet by clicking delete icon.
You easily view a page by clicking on the!images/View.png! icon on the row of the page you want to view in the existing pages list.
1. Go to GateIn Admin -> Administration -> Advanced --> Manage Pages
2. There is a list of all existing pages, click the trash can icon !images/DeleteIcon.png! on row of the page you want to delete. It will display the confirmation message.
3. Click the OK button to accept deleting or Cancel button to quit without deleting this page.
Only by following there simple steps can you create a page quickly by using a wizard and publish this page on the Navigation bar:
1. Go to GateIn Start ->Administration -> Basic --> Create page wizard. Welcome to Page Creation Wizard appears:
1. Go to Editor --> Add New Page on the Toolbar. Create page wizard: Welcome to Page Creation Wizard appears:
2. Click the Next button or number '1' of the wizard steps in order to go to step 1. This step allows users to set up page setting such as :the navigation path, the node name, the display name, etc.
There are two parts: the left pane is used to show a small description that will guide you what to do in this step. And the main wizard includes two parts: the left pane contains a list of navigations and shows the page list of each selected navigation, the right pane displays main information of a page.
3. On the left of wizard: Click the combo box icon !images/ComboBox.png! to see the navigations list. Select a navigation from the list that you want to create page. The pages list of selected navigation are displayed.
4. Select a page from the above list or click on arrow up icon !images/ArrowIcon.png! to add a page at root.
Name | Description |
Current Selected Page Node | The path of the selected node to add a new sub page |
Node Name | The node name of the added page. It is required field. This field must start with a character and must have a length between 3 and 30 characters. |
Display Name | The display name of the node which contains the added page and must have a length between 3 and 30 characters. |
Visible | This check box allows to hide this page. If not checked the page is under no circumstances shown, even if the publication period is OK. If checked the page or the page node appears on on the navigation bar, the page navigation and the site map. If "visible" is checked the visibility can depend on the "publication date & time" option. |
Publication date&time | This option allows publishing the page for a period of time. If this option is checked the visibility of the page depends on the publication period start and end date. |
Start Publication Date | The start date and time to publish the page |
End Publication Date | The end date and time to publish the page |
+Note:+You can set date and time by clicking the Start Publication Date field and End Publication Date field and select a date in the calendar pop up
5. Click Next or number '2' of the wizard steps to go to step 2.
6. Select Empty Layout or click the icon to see more templates to select.
7. Click the Next button or number '3' of the wizard step to go to step 3. You can drag portlets on the left pane and drop it on the right pane to constitute the content of this page.
Indicator | Meaning |
!images/preview.png! | *Preview Page*: allows viewing a page in preview mode |
!images/ShowContainer.png! | *Show Container*: allows listing all existing containers |
!images/ShowPortlet.png! | *Show Portlets*: allows listing all existing portlets |
8. Click the Show Container icon !images/ShowContainer.png! if you want to see the existing containers and re-select the layout of the page. There will be a category list which contains specific containers when clicking the icon.
The step 2 of creating a page by wizard is the same as the above
In the step 3, you can drag portlets from the Edit Inline Composer popup and drag it to the constitute the content of this page
You can click on!images/Switch.png! to view the content of this page.
Click Save to accept creating a new page, the Back button to return the previous step or the Abort button to quit without creating a new page.
You can easily drag and drop page body to the specific place where you want to in the page by following guides:
1. Go to GateIn Start -> Administration -> Advanced --> Edit Current portal. It will display :
2. Click on the Portal Page, drag and drop to another reasonable places which you want to in this page.
Creating a new portal requires you to have a special permission that only an administrator can give you. You need follow these guides to create a new portal.
Click on Site in the toolbar.
Click the Add New Portal button. By default, the Create New Portal form is shown with the Portal Templates tab.
By default, Portal template is Classic. Select the Portal Setting tab.
Enter a value for the Portal Name field. This field is required and must be unique. Only alpha, digit and underscore characters are allowed for this field and it must have at least 3 characters.
Select a display language for the portal by selecting a language from the list.
Select a skin for a portal by selecting one from the skin list.
Click on the Properties tab to fill in the Keep session alive property. Keeping the working session for a long time to avoid a time out. There are 3 options:
never : it never happens even if an application requests it
on-demand : it starts to be used as soon as an application requests it
always : it's always enabled (which has a cost but the administrator will be aware of that)
Click on the Permission Setting tab and set the permissions for the Portal.
By default the access permissions list for the portal is empty. You have to select at least one or tick on the Make it public check box to assign access permission to everyone.
Click on Save to accept creating a new portal.
You also can edit or delete a portal, see more details on Manage Portals
You can easily manage a portal by editing or deleting it.
You can change information of the current using portal such as properties or layout. However, you must have the edit right given by an Admininstrator. When you have edit right, follow these steps to edit the current portal:
1. Go to GateIn Start -> Administration -> Advanced --> Edit Current Portal. A form to edit the current portal will appear:
Indicator | Meaning |
!images/preview.png! | *Preview page*: allows viewing node's page in preview mode. |
!images/EditPage.png! | *Edit page properties*: allows editing node's page properties. |
!images/ShowContainer.png! | *Show container*: allows listing all existing containers when editing node's page. |
!images/ShowPortlet.png! | *Show portlet*: allows listing all existing portlets when editing node's page. |
!images/Savepage.png! | *Save page*: allows saving changes of page when editing node's page. |
!images/RollBack.png! | *Rollback*: allows canceling all changes that have not been saved. |
!images/Abort.png! | *Abort*: allows canceling all changes that have not been saved and escaping Edit page and navigation form. |
!images/Finish1.png! | *Finish*: allows saving all changes and escaping Edit page and navigation form. |
2. Click!images/EditPage.png! icon to edit portal properties.
3. Click!images/ShowContainer.png! icon to edit portal container layout.
4. Click!images/ShowPortlet.png! icon to edit portal portlet layout.
5. Click!images/Savepage.png! icon to save changes.
You must have the edit right to change information of the current using portal:
1. Go to Editor on the Toolbar ->click Edit Site Layout.
2. Click the!images/PortalProperties.png! button in the Edit Inline Composer. The edit Form of the portal will be shown:
3. Change the properties of the current portal.
4. Click the Propertites tab. Select an option for Keep session alive that means keeping the working session for a long time to avoid the working time out. There are 3 options:
5. Set permissions for a portal:
To change any permission, click the Select Permission button and then select a group with the Membership type you want. Only one group can have the Edit Permission of the portal.
You can set the Edit Permission for the portal when you create or edit it.
6. Click the Save button to accept changes or the Cancel button to quit.
You can easily delete a portal by following these guides:
1. Go to GateIn Start -> Administration -> Advanced --> Manage Portals
+The 1^st^ way+:
1. Go to Administrator on the Toolbar --> Manage Portals. List of all portals will be shown.
2. Click the trash can !images/deleteIcon.png! icon in the row of the portal you want to delete in the portal list.
3. Click the OK button in the confirmation message to delete.
+The 2^nd^ way+:
1. Click on Site in the Toolbar --> click on!images/DeletePortal2.6.png! .The confirmation message will appear:
2. Click OK to accept deleting a portal or Cancel to quit without deleting it.
GateIn Portal allows users to switch between Portals simply and easily. You can use another portals such as gateway, starting site if you are given the appropriate permissions by the administrators.
Go to Site on the Toolbarm it will list all portals in which you have at least the access right
You easily switch between Portals by simply clicking on the portal that you want to choose and wait for few seconds to take effect.
GateIn Portal provides users with the most familiar interface language to work with and perform all actions efficiently. The priority of the interface language is 1. User's language 2. Browser's language 3. Portal 's language. Thus to display your prefer language, you should pay attention to this order to change the language type appropriately.
You can change the interface language permanently by three ways :
This way supports you to change the interface language of the current Portal.
1. Go to GateIn Start -> Administration -> Advanced --> Edit Current portal.
2. Click !images/EditIcon.png! icon to edit portal's properties.
3. In the Portal Setting tab: You can change display language of Portal by selecting another language in the Locale field.
4. Click Save and Finish!images/FinishIcon.png! icon to take affect.
You easily change the interface language of the current Portal by following guides:
1. Go to Editor on the Toolbar --> click Edit Page. The Edit Inline Composer popup will appear:
2. Click on Portal Properties to edit portal's properties.
3. In the Portal Setting tab: You can change display language of Portal by selecting another language in the Locale field.
4. Click Save and Finish!images/DiskIcon.png! icon to take affect.
If you can access GateIn Start, you can do this way to set interface language for yourself, not for interface language of Portal by these following steps:
1. Go to GateIn Start -> Administration -> Language Settings
The Interface Language Setting form is displayed with a list of all supported languages. The current using language is marked by!images/MarkedIcon.png! icon.
2. Select another one by clicking on the name of language.
3. Click the Apply button and wait for few seconds to take affect.
You can set the interface language for yourself by following guides:
1. Go to GateIn on the Toolbar --> click Change Language
The Interface Language Setting form is displayed with a list of all supported languages. The current using language is marked by!images/MarkedIcon.png! icon.
2. Select another one by clicking on the name of language.
3. Click the Apply button and wait for few seconds to take affect.
You also set interface language for yourself, not for interface language of the Portal by this way.
1. Click Change Language on the right corner to show the Interface Language Setting form:
The Interface Language Setting form will appear:
2. Select another language in list. The selected language will be marked by !images/MarkedIcon.png! icon.
3. Click the Apply button to change the interface language and wait for few seconds to take affect or click the Cancel button to quit without changes.
There are two modes to set displaying language for a user.
GateIn Portal supports RTL (Right to Left) to meet the demand of Arabian customers who want to use the Portal by their own language for more convenient and easy to use. When you change from other languages to Arabic or set the displaying language as Arabic, the displaying on Portal will be changed to Right to Left (RTL) direction because Arabian usually read from Right to Left.
Some screen shots of Portal with RTL:
Exo Portal supports a multi-language environment for your portal. You can internationalize any menu entry on the navigation. As the navigation bar is composed by nodes so you have to modify the display names of the nodes. Instead of entering the display name in English you have to use a so called resource key. This resource key is used to define the label that is shown on the navigation bar, the menu, and the breadcrumb.
The resource key format is: #{key}
The resource key is the can contain any text that you consider to be fine. It should be human-readable and must not contain spaces.
There are three ways to create a key for a node: using the Create Page Wizard or using the Edit Page Wizard or the Edit Page and Navigation dialog.
You can follow these steps:
1. Go to GateIn Start -> Administration -> Basic --> Create Page Wizard
2. Click Next to move to step 1
3. At step 1, continue as usual, but enter a resource key in the Display Name field.
4. Click on the Next button and continue and click on the Save button. For example, create a key named "AAA".
1. Go to GateIn Start -> Administration -> Basic --> Edit Page Wizard
2. Click on the Next button to move to step 1
3. At step 1, continue as usual, but enter a resource key in the Display Name field.
1. Go to GateIn Start -> Administration -> Advanced --> Edit Page and Navigation.
2. There are two alternatives:
3. A Create/Edit node dialog appears, enter a resource key in the Label field
+Note:+ You can reuse the same resource key in several nodes.
Exo Portal organizes resource keys in resource files. Each file contains a list of keys and their meanings (translations) in one specific language. Normally one resource file has one language supported by Portal. This helps to structure the resource keys. Each resource file has a name and a language attribute. One resource file only can contain translations for one single language.
Do as follows: 1. Go to GateIn Start -> Page Navigation -> Administration --> Internationalization
2. Select a data resource that you want to internationalize. You also may search the desired resource name with a specific language:
+Example:+ if you want to define a key of a node of portal "classic" in language French, search resource: locale.navigation.portal.classic with value in the Language field is "fr"
+Example:+ if you want to define a key for a node on navigation of "administrators" group that is the sub one of the "platform" group in language French, search resource: locale.navigation.group.platform.administrators with the value in the Language field is "fr"
3. Click the magnifying glass!images/MagnifyIcon.png! icon corresponding to a data resource to see details of the resource file. Click the Edit button in order to modify the content.
4. Enter the resource key with the string that will be displayed as node name on the navigation bar .
5. Click on the Save button.
This portlet is used to define a word or a phrase of the current language to an expected language. The form of this portlet is like:
Each resource supports a language. So, you can define a word or a phrase according to the supported language.
1. Select the New Resource button in the Internationalization Portlet form. The Resource Data form will appear:
Name | Description |
Name | The name of Resource. This field is required. |
Language | The language that this resource 'll support. This field is required. |
Resource | The word or the phrase which you want to define. |
2. Enter values into required fields.
3. Click the Save button to accept adding a new resource or the Cancel button to quit.
Click the magnifying icon !images/GlassIcon.png! corresponding to resource which you want to view. On the view form, you also can edit information again by clicking the Edit button. You only can change Resource field, then click the Save button to accept changes or click the Cancel button to quit without saving any changes.
Click the trash can icon!images/DeleIcon.png! corresponding to the resource which you want to delete. There 'll be a confirmation message, click the OK button to confirm deleting and the Cancel button to quit.
The Search Resource form displays directly on the portlet:
Enter the name of the resource which you want to search and select the supported language. Click the Search button to perform searching and displaying a list of the expected Resource.
To add a gadget, you can follow these steps:
1. Open the User Workspace on your left pane.
2. Click the tool!images/Tool.png! icon to add a new category
The Gadget Containers Management dialog appears:
Click the add icon !images/AddIcon.png! to show the Gadget Container Form .
Name | Description |
Label | The display name of the category. This field is required and must have at least 3 characters. |
Description | The brief description of the category.A length from 0 to 255 characters is allowed. This field is not required. |
Enter values for fields in the Gadget Container Form .
Click on the Save button to accept adding a new category or click Cancel to quit. After you added the new category you will see it in the dialog :
Edit the information of an existing category by selecting it from the left pane, the selected category is marked by a symbol. Then click the edit icon to show the edit form. Change the current category information and click on the button to accept changes.
Delete an existing category by selecting it from the left pane. In the message box Click on the OK button to confirm the deletion or click the Cancel button.
3. Click on the Save button in the Gadget Containers Management dialog to accept or on the Cancel button to quit. Added categories will be displayed in list in the User Workspace.
4. Click the list icon!images/ListIcon.png! to see category list and select one in list.
5. Click the add icon!images/AddIcon1.png! at the bottom of the User Workspace to open the Add Application dialog:
6. Select a gadget by clicking the add icon !images/PlusIcon.png! that is located next to the the gadget. The selected gadget is displayed immediately in the user workspace. Normally, you can see only two gadgets in the User Workspace. When there are more gadgets, some gadgets are not visible.
7. Click the scroll down icon !images/DownIcon.png!images/ or the scroll up icon!images/ UpIcon.png! at the bottom of the User Workspace to see the other gadgets. If there are no more gadgets to scroll to, the color of the scroll down and scroll up icon switches to gray color.
To edit a gadget, click !images/EditIcon.png! icon.
Remove a gadget from the User Workspace by using the functional bar!images/FunctionBar.png! at the upper right corner of that gadget.
Click the remove icon !images/RemoveIcon.png! . When the confirmation message appears, click the OK button to accept or the Cancel to quit.
This convenient feature that helps you import default portlets/gadgets automatically in different categories and these portlets/gadgets will be listed on the left pane.
1. Go to Administration-> Application Registry page-> Organize item on the navigation bar. A form for organizing portlets/gadgets will be displayed:
2. Click the Auto Import button!images/Auto1.png! at upper right corner on the action bar. A pop up will be shown:
2. Click the OK button to accept importing gadgets automatically. All portlets/gadgets categories will be imported and listed on the left pane.
Portlets and gadgets are organized in different categories. Each category contains one or several portlets or gadgets. You can also mix portlets and gadgets into one category. By default all gadgets are placed in the ExoGadgets category.
You easily add a new category by following these guides:
Go to Administration -> Application Registry page -> Organize item.
1. Open a form to add a new category on the right pane by clicking the Add Category button on the action bar:
The Category Setting tab: includes common information about a category.
Name | Description |
Category name | The name of the category which you want to add. This field is required and its length must be between 3 and 30 characters. |
Display name | The display name of the category in list and its length must be between 3 and 30 characters. |
Description | A brief description of the category. Any length from 0 to 255 characters is allowed. |
The Permission Setting tab: used to set the access permission for a category.
Figure 7.1. {info} This access permission enters the game whenever a user creates or modifies a page. In that moment the user only can see and use portlets in those categories on which he or she has access permission (defined by groups and memberships). {info}
2. Enter values for required fields in this form.
3. Click the Save button to accept adding a new category into a category list. The new category will be added into a list on the left pane.
You can edit a category in list by following:
1. Click the edit icon!images/EditIcon1.png! on the title bar of a category that you want to edit.
2. Change the information of the selected category.
3. Click the Save button to accept changes.
You also easily remove a category from a list:
1. Click the trash can icon!images/DeleteIcon.png! on the Title bar of the category that you want to delete.
2. Click on the OK button on the message to accept deleting or click on the Cancel button to quit.
You can follow these steps to add a portlet/gadget to your prefered category :
1. Click the "add" icon!images/AddIcon.png! on the title bar of a category to which you want to add portlets. An interface will appear in the right pane as you can see below:
Name | Description |
Display name | The display name of a portlet/gadget that you want to add to a category. |
Application Type | the type of selected object. |
2. Enter the display name and select a type for the selected portlet/gadget.
3. Select a portlet/gadget by checking the radio button.
4. Click the Save button to accept adding a portlet/gadget to a category.
You easily set an access permission on a portlet by following these guides:
1. Go to GateIn Start -> Page Navigations -> select Administration --> Application Registry
2. Select a category on the left pane that includes the portlet you want to set right. Then all portlets of the selected category are listed immediately and detail information of each portlet is displayed on the right pane.
3. To set permission for a portlet:
Whenever the user creates or modifies a page he or she can only see and use portlets that fulfill two conditions: the portlet is in a category on which the user has access permission (see category section above) and the user has access permission on the portlet
You easily view detail information of all specific portlets by following these guides:
1. On the navigation bar, go to the Administration-> Application Registry page-> Portlet item . A form to view all portlets will appear:
Name | Description |
Left pane | lists all portlets in two parts: Local and Remote |
Right pane | shows detail information about a portlet: Name, Display name, Description and Portlet preferences. |
2. Select one portlet in the list on the left pane. The detail information of that portlet appears on the right pane.
You can follow these steps to add a gadget to the gadget list :
1. Go to the Administration --> Application Registry and click on Gadget :
There are two ways to add gadgets:
1. Open the form to add a remote gadget by clicking Add a remote gadget :
2. Enter a link to an .xml file in the URL field.
3. Click on the Add button to accept the entered URL or on the Cancel button to quit. The added gadget will be added into gadget list on left pane of the Dashboard portlet.
1. Show the form to add a new gadget by clicking Create a new gadget :
Source: The source code to create a new gadget. This source will be a .xml file.
2. Enter a value for the Source field in this form.
3. Click the Save button to create a new gadget. The created gadget will be added to the gadget list on the left pane of the Dashboard Portlet.
You also edit, refresh and delete a local gadget as well as a remote gadget:
You can add a new gadget to the gadget list in the Dashboard portlet :
1. Go to the Dashboard on the navigation bar. Click on the Add Gadgets link :
2. Enter a link (a .xml file or RSS) in the text box on the left pane.
3. Click on the icon!images/PlusIcon.png! to add a new gadget to the gadget list beneath.
1. Click the edit icon!images/EditGadget.png! . It will display a dialog:
2. After editing , click the Save button to accept changing or Cancel button to quit.
Configuration file path : "portal/WEB-INF/conf/portal/portal-configuration.xml"
<component> <key>org.exoplatform.portal.config.UserPortalConfigService</key> <type>org.exoplatform.portal.config.UserPortalConfigService</type> <component-plugins> <component-plugin> <name>new.portal.config.user.listener</name> <set-method>initListener</set-method> <type>org.exoplatform.portal.config.NewPortalConfigListener</type> <description>this listener init the portal configuration</description> <init-params> <value-param> <name>default.portal</name> <description>The default portal for checking db is empty or not</description> <value>classic</value> </value-param> .......... </init-params> </component-plugin> </component-plugins> </component>
You can see in the configuration above, we defined the classic as a default portal. Notes that the definition should be as a initial parameter of the NewPortalConfigListener component-plugin
When a user logs in he sees three types of navigation tree:
they all are configured thanks to the usual XML configuration syntax in a file: "portal/WEB-INF/conf/portal/portal-configuration.xml"
<component> <key>org.exoplatform.portal.config.UserPortalConfigService</key> <type>org.exoplatform.portal.config.UserPortalConfigService</type> <component-plugins> <component-plugin> <name>new.portal.config.user.listener</name> <set-method>initListener</set-method> <type>org.exoplatform.portal.config.NewPortalConfigListener</type> <description>this listener init the portal configuration</description> <init-params> <value-param> <name>default.portal</name> <description>The default portal for checking db is empty or not</description> <value>classic</value> </value-param> <object-param> <name>portal.configuration</name> <description>description</description> <object type="org.exoplatform.portal.config.NewPortalConfig"> <field name="predefinedOwner"> <collection type="java.util.HashSet"> <value><string>classic</string></value> <value><string>webos</string></value> </collection> </field> <field name="ownerType"><string>portal</string></field> <field name="templateLocation"><string>war:/conf/portal</string></field> </object> </object-param> <object-param> <name>group.configuration</name> <description>description</description> <object type="org.exoplatform.portal.config.NewPortalConfig"> <field name="predefinedOwner"> <collection type="java.util.HashSet"> <value><string>platform/administrators</string></value> <value><string>platform/users</string></value> <value><string>platform/guests</string></value> <value><string>organization/management/executive-board</string></value> </collection> </field> <field name="ownerType"><string>group</string></field> <field name="templateLocation"><string>war:/conf/portal</string></field> </object> </object-param> <object-param> <name>user.configuration</name> <description>description</description> <object type="org.exoplatform.portal.config.NewPortalConfig"> <field name="predefinedOwner"> <collection type="java.util.HashSet"> <value><string>root</string></value> <value><string>john</string></value> <value><string>marry</string></value> <value><string>demo</string></value> </collection> </field> <field name="ownerType"><string>user</string></field> <field name="templateLocation"><string>war:/conf/portal</string></field> </object> </object-param> </init-params> </component-plugin> </component-plugins>
In the previous XML file we define, for the 3 navigation types, some sets of predefined portal, groups or users that will have some XML files inside the war. Those files will be used to create an initial navigation the first time the portal is launched. That information will then be stored in the JCR and hence only modifiable from the portal UI.
The portal navigation incorporates the pages that can be accessed even when the user is not logged in (if the permission allow a public access). Several portal navigations are used for example when a company has several trademarks and each trade would have its own website.
The configuration of a portal called "classic" is made by providing 4 XML files under the directory portal/WEBINF/conf/portal/portal/classic:
That file describes the layout and portlets that will be shown for all pages. Usually the layout contains the banner, footer, menu, breadcrumbs portlets. Indeed, in GateIn, every area is a portlet even the banner and footer which makes the platform extremely configurable.
<?xml version="1.0" encoding="ISO-8859-1"?> <portal-config> <portal-name>classic</portal-name> <locale>en</locale> <factory-id>office</factory-id> <access-permissions>Everyone</access-permissions> <edit-permission>*:/platform/administrators</edit-permission> <creator>root</creator> <portal-layout> <application> <instance-id>portal#classic:/web/BannerPortlet/banner</instance-id> <show-info-bar>false</show-info-bar> </application> <application> <instance-id>portal#classic:/web/NavigationPortlet/toolbar</instance-id> <show-info-bar>false</show-info-bar> </application> <application> <instance-id>portal#classic:/web/BreadcumbsPortlet/breadcumbs</instance-id> <show-info-bar>false</show-info-bar> </application> <page-body> </page-body> <application> <instance-id>portal#classic:/web/FooterPortlet/footer</instance-id> <show-info-bar>false</show-info-bar> </application> </portal-layout> </portal-config>
Even if not shown in the previous XML file, it is also possible to apply a nested container that can also contain portlets. Containers are then responsible of the layout of their children (row, column or tabs containers exist).
Each application references a portlet using the id portal#{portalName}:/{portletWarName}/{portletName}/{uniqueId}
In order to define at which location GateIn Portal shall render the current page use the page-body tag.
The defined classic portal is accessible to "Everyone" (that means it can be accessed through the URL /portal/public/classic) but only members of the group /platform/administrators can edit it.
This file defines all the navigation nodes the portal will have. The syntax is simple as we get nested node tags. Each node references a page that is defined in the next XML file.
If the label #{} is used then it means the i18n mechanism is activated and that the real label to render is taken from an associated properties file for the current locale.
<?xml version="1.0" encoding="UTF-8"?> <node-navigation> <owner-type>portal</owner-type> <owner-id>classic</owner-id> <priority>1</priority> <page-nodes> <node> <uri>home</uri> <name>home</name> <label>#{portal.classic.home}</label> <page-reference>portal::classic::homepage</page-reference> </node> <node> <uri>webexplorer</uri> <name>webexplorer</name> <label>#{portal.classic.webexplorer}</label> <page-reference>portal::classic::webexplorer</page-reference> </node> </page-nodes> </node-navigation>
This navigation tree can have multiple views inside portlets such as the breadcrumbs that render the current view node, the site map or the menu portlets.
+Warning+: For top nodes, the uri and the name of your navigation nodes must have the same value. For the other nodes the uri is composed like <uri>contentmanagement/fileexplorer</uri> where 'contentmanagement' is the name of the parent node and 'fileexplorer' the name of the node (<name>fileexplorer</name>).
This XML file structure is very similar to portal.xml and it can also contain container tags. Each application can decide if it wishes to render the portlet border, the window state icons or the mode.
<?xml version="1.0" encoding="ISO-8859-1"?> <page-set> <page> <page-id>portal::classic::homepage</page-id> <owner-type>portal</owner-type> <owner-id>classic</owner-id> <name>homepage</name> <title>Home Page</title> <access-permissions>Everyone</access-permissions> <edit-permission>*:/platform/administrators</edit-permission> <application> <instance-id>portal#classic:/web/HomePagePortlet/homepageportlet</instance-id> <title>Home Page portlet</title> <show-info-bar>false</show-info-bar> <show-application-state>false</show-application-state> <show-application-mode>false</show-application-mode> </application> </page> <page> <page-id>portal::classic::webexplorer</page-id> <owner-type>portal</owner-type> <owner-id>classic</owner-id> <name>webexplorer</name> <title>Web Explorer</title> <access-permissions>*:/platform/users</access-permissions> <edit-permission>*:/platform/administrators</edit-permission> <application> <instance-id>group#platform/users:/web/BrowserPortlet/WebExplorer</instance-id> <title>Web Explorer</title> <show-info-bar>false</show-info-bar> </application> </page> </page-set>
Porlet instances can be associated with portlet-preferences that override the one defined in the usual portlet.xml file of the portlet application WAR.
<?xml version="1.0" encoding="ISO-8859-1"?> <portlet-preferences-set> <portlet-preferences> <owner-type>portal</owner-type> <owner-id>classic</owner-id> <window-id>portal#classic:/web/BannerPortlet/banner</window-id> <preference> <name>template</name> <value>par:/groovy/groovy/webui/component/UIBannerPortlet.gtmpl</value> <read-only>false</read-only> </preference> </portlet-preferences> <portlet-preferences> <owner-type>portal</owner-type> <owner-id>classic</owner-id> <window-id>portal#classic:/web/NavigationPortlet/toolbar</window-id> <preference> <name>useAJAX</name> <value>true</value> <read-only>false</read-only> </preference> </portlet-preferences> <portlet-preferences> <owner-type>portal</owner-type> <owner-id>classic</owner-id> <window-id>portal#classic:/web/FooterPortlet/footer</window-id> <preference> <name>template</name> <value>par:/groovy/groovy/webui/component/UIFooterPortlet.gtmpl</value> <read-only>false</read-only> </preference> </portlet-preferences> <portlet-preferences> <owner-type>portal</owner-type> <owner-id>classic</owner-id> <window-id>portal#classic:/web/GroovyPortlet/groovyportlet</window-id> <preference> <name>template</name> <value>par:/groovy/groovy/webui/component/UIGroovyPortlet.gtmpl</value> <read-only>false</read-only> </preference> </portlet-preferences> </portlet-preferences-set>
Group navigations are dynamically added (mounted) to the user navigation when he logs in. This means that a user sees in his menu also all the pages that are assigned to the groups to which he belongs to.
Here only 3 XML files are necessary: navigation.xml, pages.xml and portlet-preferences.xml. The syntax is the same as for portal navigations.
The 3 files are located in the directory: "portal/WEB-INF/conf/portal/group/group-name-path/" like for example "portal/WEB-INF/conf/portal/group/platform/administrators/"
The user navigation is the set of nodes and pages that is owned by a user. You can see that part as the user dashboard. The files needed are navigation.xml, pages.xml, portlet-preferences.xml. You will also find gadgets.xml (formerly called widgets.xml) which defines the gadgets (widgets) that will be located in the user workspace. The user workspace is located at the left hand side, the access is restricted to some privileged users, see Portal:Predefined User Configuration.
Those files are located in the directory "portal/WEB-INF/conf/portal/users/{userName}"
<?xml version="1.0" encoding="ISO-8859-1"?> <widgets> <owner-type>user</owner-type> <owner-id>root</owner-id> <container id="Information"> <name>Information</name> <description>Information's Description</description> <application> <instance-id>user#root:/GateInWidgetWeb/WelcomeWidget/WelcomeWidget1</instance-id> <application-type>GateInWidget</application-type> </application> <application> <instance-id>user#root:/GateInWidgetWeb/StickerWidget/StickerWidget</instance-id> <application-type>GateInWidget</application-type> </application> <application> <instance-id>user#root:/GateInWidgetWeb/InfoWidget/InfoWidget1</instance-id> <application-type>GateInWidget</application-type> </application> </container> <container id="Calendar"> <name>Calendar</name> <description>Calendar's Description</description> <application> <instance-id>user#root:/GateInWidgetWeb/CalendarWidget/CalendarWidget</instance-id> <application-type>GateInWidget</application-type> </application> </container> </widgets>
Note that when you develop a portal, we advise you to use the XML instead of the User Interface as XML will allow you to provide a preconfigured package to your customer. But as each time you start the server the first time, the XML files are stored in the JCR, it will be necessary to remove the database (the jcr leverages a database). During the development phase using tomcat it simply means to delete the directory: exo-tomcat/temp
If you wish to add a link to a URL outside the portal you you first have to define a "page" which will not be used. Then add the URL to the navigation.
<node> <uri>http://wiki.exoplatform.com/xwiki/bin/view/Main/WebHome</uri> <name>documentation</name> <label>#{portal.classic.documentation}</label> <page-reference>portal::website::documentation</page-reference> </node>
To specify the initial Organization configuration, the content of
portal.war:WEB-INF/conf/organization/organization-configuration.xml
should be edited. This file complies with the XML GateIn configuration
schema. It lists several configuration plugins.
The plugin of type
org.exoplatform.services.organization.OrganizationDatabaseInitializer
specifies the list of users, groups and membership types to be
created. The initialization parameter named "checkDatabaseAlgorithm" determines how the creation is triggered. Thus, the value "entry" means that each user, group and membership listed in the configuration is checked each time GateIn is started. If not existing, it is created. The value "empty" means that the whole list of preconfigured users, groups and memberships is processed only if the database is empty.
The predefined membership types are specified in the "membershipType" field of the "OrganizationConfig" plugin parameter. {code} <field name="membershipType"> <collection type="java.util.ArrayList"> <value> <object type="org.exoplatform.services.organization.OrganizationConfig$MembershipType"> <field name="type"><string>member</string></field> <field name="description"><string>member membership type</string></field> </object> </value> <value> <object type="org.exoplatform.services.organization.OrganizationConfig$MembershipType"> <field name="type"><string>owner</string></field> <field name="description"><string>owner membership type</string></field> </object> </value> <value> <object type="org.exoplatform.services.organization.OrganizationConfig$MembershipType"> <field name="type"><string>validator</string></field> <field name="description"><string>validator membership type</string></field> </object> </value> </collection> </field> {code}
The predefined groups are specified in the "group" field of the "OrganizationConfig" plugin parameter. {code} <field name="group"> <collection type="java.util.ArrayList"> <value> <object type="org.exoplatform.services.organization.OrganizationConfig$Group"> <field name="name"><string>portal</string></field> <field name="parentId"><string></string></field> <field name="type"><string>hierachy</string></field> <field name="description"><string>the /portal group</string></field> </object> </value> <value> <object type="org.exoplatform.services.organization.OrganizationConfig$Group"> <field name="name"><string>community</string></field> <field name="parentId"><string>/portal</string></field> <field name="type"><string>hierachy</string></field> <field name="description"><string>the /portal/community group</string></field> </object> </value> ... </collection> </field> {code}
The predefined users are specified in the "membershipType" field of the "OrganizationConfig" plugin parameter.
<field name="user"> <collection type="java.util.ArrayList"> <value> <object type="org.exoplatform.services.organization.OrganizationConfig$User"> <field name="userName"><string>root</string></field> <field name="password"><string>exo</string></field> <field name="firstName"><string>root</string></field> <field name="lastName"><string>root</string></field> <field name="email"><string>exoadmin@localhost</string></field> <field name="groups"><string>member:/admin,member:/user,owner:/portal/admin</string></field> </object> </value> <value> <object type="org.exoplatform.services.organization.OrganizationConfig$User"> <field name="userName"><string>exo</string></field> <field name="password"><string>exo</string></field> <field name="firstName"><string>site</string></field> <field name="lastName"><string>site</string></field> <field name="email"><string>exo@localhost</string></field> <field name="groups"><string>member:/user</string></field> </object> </value> ... </collection> </field>
The plugin of type org.exoplatform.services.organization.impl.NewUserEventListener
specifies which groups should join all newly created users. It notably specifies the groups and memberships to be used. It also specifies a list of users that should be excepted.
<component-plugin> <name>new.user.event.listener</name> <set-method>addListenerPlugin</set-method> <type>org.exoplatform.services.organization.impl.NewUserEventListener</type> <description>this listener assign group and membership to a new created user</description> <init-params> <object-param> <name>configuration</name> <description>description</description> <object type="org.exoplatform.services.organization.impl.NewUserConfig"> <field name="group"> <collection type="java.util.ArrayList"> <value> <object type="org.exoplatform.services.organization.impl.NewUserConfig$JoinGroup"> <field name="groupId"><string>/user</string></field> <field name="membership"><string>member</string></field> </object> </value> </collection> </field> <field name="ignoredUser"> <collection type="java.util.HashSet"> <value><string>exo</string></value> <value><string>root</string></value> <value><string>company</string></value> <value><string>community</string></value> </collection> </field> </object> </object-param> </init-params> </component-plugin>
The User Workspace is give privileged users access to administration actions. Please refer to the User Workspace Guide to know more details.
The default configuration defines two groups:
anyone in these groups can access and use the User Workspace. The asterisk symbol stands for "any membership type".
If an administrator wants to allow someone to access the User Workspace, the admin can add the user to one of these groups or he or she modifies the workspace access configuration. This permission is set in the portal-configuration.xml file.
<component> <key>org.exoplatform.portal.config.UserACL</key> <type>org.exoplatform.portal.config.UserACL</type> <init-params> ... <value-param> <name>access.control.workspace</name> <description>groups with memberships that have the right to access the User Control Workspace</description> <value>*:/platform/administrators,*:/organization/management/executive-board</value> </value-param>
Modify the content of the <code>value</code> tag depending on your needs. The configuration is taken into account after you restarted the application server.
Please refer to User Workspace Guide to see the user workspace.
The permission configuration for the portal is defined in the file portal/WEB-INF/conf/portal/portal-configuration.xml. The component UserACL is described there along with other portal component configurations.
It defines 5 permissions types:
<component> <key>org.exoplatform.portal.config.UserACL</key> <type>org.exoplatform.portal.config.UserACL</type> <init-params> <value-param> <name>super.user</name> <description>administrator</description> <value>root</value> </value-param> <value-param> <name>portal.creator.groups</name> <description>groups with membership type have permission to manage portal</description> <value>*:/platform/administrators,*:/organization/management/executive-board</value> </value-param> <value-param> <name>navigation.creator.membership.type</name> <description>specific membership type have full permission with group navigation</description> <value>manager</value> </value-param> <value-param> <name>guests.group</name> <description>guests group</description> <value>/platform/guests</value> </value-param> <value-param> <name>access.control.workspace</name> <description>groups with memberships that have the right to access the User Control Workspace</description> <value>*:/platform/administrators,*:/organization/management/executive-board</value> </value-param> </init-params> </component>
1 Overwrite Portal Default Permissions In GateIn Portal 2.5 and later the UserACL component supports adding a PortalACLPlugin plugin that allows to overwrite portal default permissions.
<external-component-plugins> <target-component>org.exoplatform.portal.config.UserACL</target-component> <component-plugin> <name>addPortalACLPlugin</name> <set-method>addPortalACLPlugin</set-method> <type>org.exoplatform.portal.config.PortalACLPlugin</type> <description>setting some permission for portal</description> <init-params> <values-param> <name>access.control.workspace.roles</name> <value>*:/platform/administrators</value> <value>*:/organization/management/executive-board</value> </values-param> <values-param> <name>portal.creation.roles</name> <value>*:/platform/administrators</value> <value>*:/organization/management/executive-board</value> </values-param> </init-params> </component-plugin> </external-component-plugins>
GateIn Portal has two different database dependencies. One is the Hibernate service configuration, which depends on the the Hibernate and c3p0 projects. The other database dependency is Java content repository (JCR) service, which depends on the native JDBC API and it can integrate with any existing datasource implementation.
When you change the database configuration for the first time, GateIn will automatically generate the proper schema (assuming that the database user has the appropriate permissions).
You can find the database configuration in the portal/WEB-INF/conf/database/database-configuration.xml file (located in your application server's web application directory).
<?xml version="1.0" encoding="ISO-8859-1"?> <configuration> [...] <component> <key>org.exoplatform.services.database.HibernateService</key> <jmx-name>database:type=HibernateService</jmx-name> <type>org.exoplatform.services.database.impl.HibernateServiceImpl</type> <init-params> <properties-param> <name>hibernate.properties</name> <description>Default Hibernate Service</description> <property name="hibernate.show_sql" value="false"/> <property name="hibernate.cglib.use_reflection_optimizer" value="true"/> <property name="hibernate.connection.url" value="jdbc:hsqldb:file:../temp/data/exodb"/> <property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/> <property name="hibernate.connection.autocommit" value="true"/> <property name="hibernate.connection.username" value="sa"/> <property name="hibernate.connection.password" value=""/> <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/> <property name="hibernate.c3p0.min_size" value="5"/> <property name="hibernate.c3p0.max_size" value="20"/> <property name="hibernate.c3p0.timeout" value="1800"/> <property name="hibernate.c3p0.max_statements" value="50"/> </properties-param> </init-params> </component> <external-component-plugins> <target-component>org.exoplatform.services.naming.InitialContextInitializer</target-component> <component-plugin> <name>bind.datasource</name> <set-method>addPlugin</set-method> <type>org.exoplatform.services.naming.BindReferencePlugin</type> <init-params> <value-param> <name>bind-name</name> <value>jdbcexo</value> </value-param> <value-param> <name>class-name</name> <value>javax.sql.DataSource</value> </value-param> <value-param> <name>factory</name> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value> </value-param> <properties-param> <name>ref-addresses</name> <description>ref-addresses</description> <property name="driverClassName" value="org.hsqldb.jdbcDriver"/> <property name="url" value="jdbc:hsqldb:file:../temp/data/exodb"/> <property name="username" value="sa"/> <property name="password" value=""/> </properties-param> </init-params> </component-plugin> </external-component-plugins> [...] </configuration>
The first component configuration is for the Hibernate service. You can enter any additional properties in a hibernate.properties file, but GateIn will override hibernate.properties with values read in from this configuration file.
The second component configuration is for the JCR datasource. The InitialContextInitializer component will load the factory class, use the factory object to create a datasource, and bind that datasource in the JNDI tree with the value of the "bind-name" parameter. If you want to change the bind-name, for example "jdbcexo" to "myjdbc", you also need to change JCR repository configuration in order that the service picks up the right datasource.
There are two JCR configuration files that must be changed to support a different database. In both files, edit the dialect (and the data source name if necessary).
The first file is portal/WEB-INF/conf/jcr/jcr-configuration.xml:
[...] <component> <key>org.exoplatform.services.jcr.config.RepositoryServiceConfiguration</key> <type>org.exoplatform.services.jcr.impl.config.RepositoryServiceConfigurationImpl</type> <init-params> <value-param> <name>conf-path</name> <description>JCR configuration file</description> <value>war:/conf/jcr/repository-configuration.xml</value> </value-param> <properties-param> <name>working-conf</name> <description>working-conf</description> <property name="persisterClassName" value="org.exoplatform.services.jcr.impl.config.JDBCConfigurationPersister"/> <property name="sourceName" value="jdbcexo"/> <property name="dialect" value="hsqldb"/> </properties-param> </init-params> </component> [...]
The second file is portal/WEB-INF/conf/jcr/repository-configuration.xml:
[...] <workspaces> <workspace name="system" auto-init-root-nodetype="nt:unstructured" auto-init-permissions="*:/platform/administrators read;*:/platform/administrators add_node;*:/platform/administrators set_property;*:/platform/administrators remove" > <!-- for system storage --> <container class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer"> <properties> <property name="sourceName" value="jdbcexo"/> <property name="dialect" value="hsql"/> <!-- property name="db-type" value="mysql"/ --> <property name="multi-db" value="false"/> <property name="update-storage" value="true"/> <property name="max-buffer-size" value="204800"/> <property name="swap-directory" value="../temp/swap/system"/> </properties> [...] </workspace> <workspace name="collaboration" auto-init-root-nodetype="nt:unstructured" auto-init-permissions="any read;*:/platform/administrators read;*:/platform/administrators add_node;*:/platform/administrators set_property;*:/platform/administrators remove" > <!-- for system storage --> <container class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer"> <properties> <property name="sourceName" value="jdbcexo"/> <property name="dialect" value="hsqldb"/> <property name="multi-db" value="false"/> <property name="update-storage" value="true"/> <property name="max-buffer-size" value="204800"/> <property name="swap-directory" value="../temp/swap/collaboration"/> </properties> [...] </workspace> <workspace name="backup" auto-init-root-nodetype="nt:unstructured" auto-init-permissions="any read;*:/platform/administrators read;*:/platform/administrators add_node;*:/platform/administrators set_property;*:/platform/administrators remove" > <!-- for system storage --> <container class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer"> <properties> <property name="sourceName" value="jdbcexo"/> <property name="dialect" value="mysql"/> <!-- property name="db-type" value="mysql"/ --> <property name="multi-db" value="false"/> <property name="update-storage" value="true"/> <property name="max-buffer-size" value="204800"/> <property name="swap-directory" value="../temp/swap/backup"/> </properties> </workspace> [...] </workspaces> [...]
Data-injector is an utility to initialize enterprise data for Portal. It is packed in a .jar and deployed under $TOMCATHOME/lib. It is started automatically when Tomcat starts.
OrganizationInitializer is the service that allows creating a large organization with many groups and users. It also creates portal navigation and page(s) for each group, each user.
<configuration> <component> <key>org.exoplatform.portal.initializer.organization.OrganizationInitializer</key> <type>org.exoplatform.portal.initializer.organization.OrganizationInitializer</type> <init-params> <value-param> <name>auto.create.group.page.navigation</name> <description>true or false</description> <value>true</value> </value-param> <value-param> <name>auto.create.user.page.navigation</name> <description>number of pages per user</description> <value>10</value> </value-param> <object-param> <name>organization</name> <description>description</description> <object type="org.exoplatform.portal.initializer.organization.OrganizationConfig"> <field name="groups"> <collection type="java.util.ArrayList"> <value> <object type="org.exoplatform.portal.initializer.organization.OrganizationConfig$GroupsConfig"> <field name="group"> <object type="org.exoplatform.services.organization.OrganizationConfig$Group"> <field name="name"><string>province</string></field> <field name="parentId"><string>/africa/tanzania</string></field> <field name="description"><string>Tanzania's province</string></field> <field name="label"><string>Province</string></field> </object> </field> <field name="from"><string>1</string></field> <field name="to"><string>10</string></field> </object> </value> </collection> </field> <field name="users"> <collection type="java.util.ArrayList"> <value> <object type="org.exoplatform.portal.initializer.organization.OrganizationConfig$UsersConfig"> <field name="user"> <object type="org.exoplatform.services.organization.OrganizationConfig$User"> <field name="userName"><string>user</string></field> <field name="password"><string>GateInPlatform</string></field> <field name="firstName"><string>First-Name</string></field> <field name="lastName"><string>Last-Name</string></field> <field name="email"><string>exo@localhost</string></field> <field name="groups"><string>member:/africa</string></field> </object> </field> <field name="from"><string>0</string></field> <field name="to"><string>9</string></field> </object> </value> </collection> </field> </object> </object-param> </init-params> </component> </configuration>
The "auto.create.group.page.navigation" Parameter Value is true or false. If TRUE it automatically create portal navigation and page for each group. If FALSE it does not create portal navigation and page for each group.
The "auto.create.user.page.navigation" Parameter Value is number of pages that automatically created for each user.
GateIn provides support for skinning the entire portal User Interface (UI) including your own portlets. Skins are designed to help you pack and reuse common graphic resources.
Skins can be switched dynamically at runtime by the Skin Settings action in User Workspace .
When you switch, the whole portal will be repainted and new styles will be applied to the UI.
An GateIn skin contains css styles for GateIn portal's components but
also shares components that may be reused in portlets. When GateIn
generates a portal page markup, it inserts stylesheet links in the
page's
head
tag.
<head> ... <link id="CoreSkin" rel="stylesheet" type="text/css" href="/GateInResources/skin/Stylesheet.css" /> <link id="web_FooterPortlet" rel="stylesheet" type="text/css" href= "/web/skin/portal/webui/component/UIFooterPortlet/DefaultStylesheet.css" /> <link id="web_NavigationPortlet" rel="stylesheet" type="text/css" href= "/web/skin/portal/webui/component/UINavigationPortlet/DefaultStylesheet.css" /> <link id="web_HomePagePortlet" rel="stylesheet" type="text/css" href= "/portal/templates/skin/webui/component/UIHomePagePortlet/DefaultStylesheet.css" /> <link id="web_BannerPortlet" rel="stylesheet" type="text/css" href= "/web/skin/portal/webui/component/UIBannerPortlet/DefaultStylesheet.css" /> ... </head>
In the snipped code above, you can see two types of links :
id="CoreSkin"
).This is revealed easily by the main portal skin stylesheets. For example /GateInVistaSkin/skin/Stylesheet.css {code} @import url(/GateInResources/skin/PortletThemes/Stylesheet.css) ; @import url(VistaSkin/portal/webui/component/UIPortalApplicationSkin.css) ; @import url(VistaSkin/webui/component/Stylesheet.css) ; {code}
Portlets often require additionnal styles that may not be defined by the portal skin. GateIn allows portlets to define additional stylesheets for each portlet and will append the corresponding link
tags to the head
.
The link ID will be of the form {portletAppName}{}$$
PortletName
. For example: ContentPortlet
in content.war
, will give id="contentContentPortlet"
The SkinService is an GateIn service that manages portal skin, portlet styles and portlet themes (windows borders). The code snippet below is an excerpt of the API offered by this service.
/** * Register the stylesheet for a portal Skin. * @param module skin module identifier * @param skinName skin name * @param cssPath path uri to the css file. This is relative to the root context, use leading '/' * @param scontext the webapp's {@link ServletContext} */ public void addPortalSkin(String module, String skinName, String cssPath, ServletContext scontext) { [...] } /** * Register a portlet stylesheet for a Skin. * @param module skin module. Typically of the form 'portletAppName/portletName' . * @param skinName Name of the skin * @param cssPath path uri to the css file. This is relative to the root context, use leading '/' * @param scontext the webapp's {@link ServletContext} */ public void addSkin(String module, String skinName, String cssPath, ServletContext scontext) { [...] } /** * Get a skin configuration for a given Skin * @param module skin module such as registered in {@link #addSkin(String, String, String, ServletContext)} * @param skinName skin name * @return the skin configuration or, if not found try to find the default skin */ public SkinConfig getSkin(String module, String skinName) { [...] } /** * Register multiple portlet themes * @param categoryName portlet theme category * @param themesName names of the themes */ public void addTheme(String categoryName, List<String> themesName) { [...] }
Use the skin service to register your own portal skins, portlet styles and portlet themes.
GateIn provides a servlet listener that allows you to register your own skins and styles when your webapp starts up. Your first step is to add the listener to your portlet app web.xml
.
<web-app> [::] <listener> <listener-class>org.exoplatform.portal.webui.skin.SkinConfigListener</listener-class> </listener> [::] </web-app>
1.1 SkinConfigScript.groovy
The <tt>SkinListener</tt> looks for the groovy script file located in your war under :
In this script, you have full access to the <tt>SkinService</tt> and <tt>ServletContext</tt> which are bound as scripting variables under the same name. As an example, take a look at the following script. It can be found in the <tt>GateInResources.war</tt> and is used by GateIn to register the <tt>Default</tt> portal skin and some portlet themes.
SkinService.addPortalSkin("CoreSkin","Default", "/GateInResources/skin/Stylesheet.css", ServletContext); SkinService.addTheme("Simple", ["SimpleBlue","SimpleViolet","SimpleOrange","SimplePink","SimpleGreen"]); SkinService.addTheme("RoundConer", ["RoundConerBlue","RoundConerViolet","RoundConerOrange","RoundConerPink","RoundConerGreen"]); SkinService.addTheme("Shadow", ["ShadowBlue","ShadowViolet","ShadowOrange","ShadowPink","ShadowGreen"]); SkinService.addTheme("MacStyle", ["MacTheme","MacGray","MacGreenSteel","MacBlack"]); SkinService.addTheme("VistaStyle", ["VistaTheme","VistaBlue"]);
The syntax of addTheme() is: <tt>addTheme(String categoryName, List<String> themesName)</tt>
So, to provide your own skin you could use the following: {code} SkinService.addSkin("mywebapp/MyPortlet", "MyPortalSkin", "/mywebapp/skin/Stylesheet.css", ServletContext); {code}
This simple line would register a styleesheet for a portlet named <tt>MyPortlet</tt> in a portlet app named <tt>mywebapp</tt>. The stylesheet would be used when a skin named <tt>MyPortalSkin</tt> is selected in portal.
The syntax of addSkin() is: <tt>addSkin(String module, String skinName, String cssPath, ServletContext scontext, boolean overwrite)</tt>
Similarly, to configure a particular portal you can use the following : {code} SkinService.addSkin("myportalname", "skin", "/path/to/skin/Stylesheet.css", ServletContext); {code}
The syntax of addPortalSkin() is: <tt>addPortalSkin(String module, String skinName, String cssPath, ServletContext scontext, boolean overwrite)</tt>
1 Tips and Tricks
1.1 Easier css debugging
By default, CSS files are cached and their imports are merged, at the server side, into a single CSS file to reduce the number of HTTP requests from the browser to the server.
The <tt>ServletContext</tt> parameter is there to allow the direct access to the CSS files from the <tt>SkinService</tt>. The optimization code is quite simple as all the CSS files are parsed at the server startup time and all the @import and url(...) references are rewritten to support a single flat file. The result is stored in a cache directly used from the <tt>ResourceRequestFilter</tt>.
Although the optimization is useful for a production environments, you may find it easier to deactivate this optimization while debugging your stylesheets. For that, you simply need to set the java system property <tt>exo.product.developing</tt> to <tt>true</tt>.
For example, you can pass the property as a JVM parameter with the <tt>-D</tt> option in your <tt>GateIn.sh</tt> startup script: {code} EXO{code}
1.1 Change portlet icons
Each portlet is represented by an icon that you can see in the portlet registry, or the webos dock. You can change this icon by adding an image in the directory :
For example, in portal we have an account portlet named AccountPortlet, the icon is located in :
1.1 Set the default skin for Portal
When not configured, the default skin of portal is Default. If you want to change this value (to Mac skin, Vista skin, or your own), add a skin tag in the <tt>portal.xml</tt> that defines your portal:
<portal-config> <portal-name>classic</portal-name> <locale>en</locale> <factory-id>office</factory-id> <access-permissions>Everyone</access-permissions> <edit-permission>*:/platform/administrators</edit-permission> <skin>Mac</skin> <creator>root</creator> ...
GateIn relies heavily on CSS to create the layout and special effects for the UI. Below we explain some common techniques you may find often inside GateIn's markup. We explain them here to help you better understand GateIn generated markup, ease css issues fixing or get inspration for styling your own apps.
The decorator is a pattern to create a contour or a curve around an area. In order to achieve this effect you need to create 9 cells. The BODY is the central area that you want to decorate. The other 8 cells are distributed around the BODY cell. You can use the width, height and background image properties to achieve any decoration effect that you want.
~UWC_TOKEN_START~1255420331338~UWC_TOKEN_END~ | | | | | TopLeft | TopCenter | TopRight | | | | | ---- | | | | | | | | | CenterLeft | BODY | CenterRight | | | | | | | | | ~UWC_TOKEN_START~1255420331340~UWC_TOKEN_END~ | | | | | BottomLeft | BottomCenter | BottomRight | | | | | ~UWC_TOKEN_START~1255420331341~UWC_TOKEN_END~ <div class="Parent"> <div class="TopLeft"> <div class="TopRight"> <div class="TopCenter"><span></span></div> </div> </div> <div class="CenterLeft"> <div class="CenterRight"> <div class="CenterCenter">BODY</div> </div> </div> <div class="BottomLeft"> <div class="BottomRight"> <div class="BottomCenter"><span></span></div> </div> <div> </div>
Left margin left pattern is a technique to create 2 blocks side by side. The left block will have a fixed size and the right block will take the rest of the available space. When the user resizes the browser the added or removed space will be taken from the right block.
~UWC_TOKEN_START~1255420331342~UWC_TOKEN_END~ | | | | | | | |<--- fixed width --->| | will expand to right ----> | | | | | | | | | | ---- <div class="Parent"> <div style="float: left; width: 100px"> </div> <div style="margin-left: 105px;"> <div> <div style="clear: left"><span></span></div> </div>
WEB-INF/conf/script/groovy/SkinConfigScript.groovy
in your Ressource
(for example, in the project MyPortal, you can put it in GateInResourcesMyPortal
).SkinService.addPortalSkin("MyPortalSkin","MyPortal","/GateInResourcesMyPortal/skin/Stylesheet.css",ServletContext);
Secondly, you put all your new skin into folder skinyourSkin
and create new file Stylesheet.css
here. In this file, you will import all links to your CSS. For example in MyPortal project.
@import url(MyPortalSkin/portal/webui/component/UIPortalApplicationSkin.css) ; @import url(MyPortalSkin/webui/component/Stylesheet.css) ;
Finally, you have to definy the name of new skin and the image preview for the Skin Settings action in User Workspace.
By default, if you don not set new name for skin, its name is <t>label></tt>. Looking in the file and add yout new name here.
############################################################################# # Change Skin # ############################################################################# UIChangeSkin.action.save=Appliquer UIChangeSkin.action.close=Fermer UIChangeSkin.title.SkinSetting=Configuration des styles UIChangeSkin.MyPortal.label=Style MyPortal UIChangeSkin.Default.label=Style par d?faut UIChangeSkin.Mac.label=Style Mac UIChangeSkin.Vista.label=Style Vista Skin.title=Liste des styles Skin.left.title=Voir et s?lectionner un style
The image peeview can be set in file ressource/skin/DefaultSkin/portal/webui/component/customization/UIChangeSkinForm/Stylesheet.css
of Portal.
.UIChangeSkinForm .UIItemSelector .TemplateContainer .MyPortalImage { margin: auto; width: 329px; height:204px; background: url('background/MyPortal.jpg') no-repeat top; cursor: pointer ; }
And now, you copy your image MyPortal.jpg
(that you definy above) to the folder ressource/skin/DefaultSkin/portal/webui/component/customization/UIChangeSkinForm/background
and test your new skin.
Firstly, you have to definy the new theme in WEB-INF/conf/script/groovy/SkinConfigScript.groovy
in your Ressource
(for example, in the project MyPortal, you can put it in GateInResourcesCp060508
).
SkinService.addTheme("MyPortal-MacTheme", ["MacGray","MacBlue","MacBlack"]);
Secondly, you put all your new theme into folder skinyourSkin
and create new file Stylesheet.css
here. In this file, you will import all links to your CSS. For example in MyPortal project.
@import url(MyPortalSkin/PortletThemes/Stylesheet.css) ;
You can see here, in the GateInResourcesCp060508/skin/MyPortalSkin/PortletThemes/Stylesheet.css
, you put all your CSS of new theme.
/*---- MyPortalTheme ----*/ .MyPortalTheme .WindowBarCenter .WindowPortletInfo { margin-right: 80px; /* orientation=lt */ margin-left: 80px; /* orientation=rt */ } .MyPortalTheme .WindowBarCenter .ControlIcon { float: right;/* orientation=lt */ float: left;/* orientation=rt */ width: 24px; height: 17px; cursor: pointer; background-image: url('background/MyPortalTheme.png'); } .MyPortalTheme .ArrowDownIcon { background-position: center 20px; } .MyPortalTheme .OverArrowDownIcon { background-position: center 116px; } .MyPortalTheme .MinimizedIcon { background-position: center 44px; } .MyPortalTheme .OverMinimizedIcon { background-position: center 140px; } .MyPortalTheme .MaximizedIcon { background-position: center 68px; } .MyPortalTheme .OverMaximizedIcon { background-position: center 164px; } .MyPortalTheme .RestoreIcon { background-position: center 92px; } .MyPortalTheme .OverRestoreIcon { background-position: center 188px; } .MyPortalTheme .NormalIcon { background-position: center 92px; } .MyPortalTheme .OverNormalIcon { background-position: center 188px; } .UIPageDesktop .MyPortalTheme .ResizeArea { float: right;/* orientation=lt */ float: left;/* orientation=rt */ width: 18px; height: 18px; cursor: nw-resize; background: url('background/ResizeArea18x18.gif') no-repeat left top; /* orientation=lt */ background: url('background/ResizeArea18x18-rt.gif') no-repeat right top; /* orientation=rt */ } .MyPortalTheme .Information { height: 18px; line-height: 18px; vertical-align: middle; font-size: 10px; padding-left: 5px;/* orientation=lt */ padding-right: 5px;/* orientation=rt */ margin-right: 18px;/* orientation=lt */ margin-left: 18px;/* orientation=rt */ } .MyPortalTheme .WindowBarCenter .WindowPortletIcon { background-position: left top; /* orientation=lt */ background-position: right top; /* orientation=rt */ padding-left: 20px; /* orientation=lt */ padding-right: 20px; /* orientation=rt */ height: 16px; line-height: 16px; } .MyPortalTheme .WindowBarCenter .PortletName { font-weight: bold; color: #333333; overflow: hidden; white-space: nowrap; width: 100%; } .MyPortalTheme .WindowBarLeft { padding-left: 12px; background-image: url('background/MyPortalTheme.png'); background-repeat: no-repeat; background-position: left -148px; } .MyPortalTheme .WindowBarRight { padding-right: 11px; background-image: url('background/MyPortalTheme.png'); background-repeat: no-repeat; background-position: right -119px; } .MyPortalTheme .WindowBarCenter { background-image: url('background/MyPortalTheme.png'); background-repeat: repeat-x; background-position: left -90px; } .MyPortalTheme .WindowBarCenter .FixHeight { height: 21px; padding-top: 8px; } .MyPortalTheme .MiddleDecoratorLeft { padding-left: 12px; background: url('background/MMyPortalTheme.png') repeat-y left; } .MyPortalTheme .MiddleDecoratorRight { padding-right: 11px; background: url('background/MMyPortalTheme.png') repeat-y right; } .MyPortalTheme .MiddleDecoratorCenter { background: #ffffff; } .MyPortalTheme .BottomDecoratorLeft { padding-left: 12px; background-image: url('background/MyPortalTheme.png'); background-repeat: no-repeat; background-position: left -60px; } .MyPortalTheme .BottomDecoratorRight { padding-right: 11px; background-image: url('background/MyPortalTheme.png'); background-repeat: no-repeat; background-position: right -30px; } .MyPortalTheme .BottomDecoratorCenter { background-image: url('background/MyPortalTheme.png'); background-repeat: repeat-x; background-position: left top; } .MyPortalTheme .BottomDecoratorCenter .FixHeight { height: 30px; }
Manaing Javascript scripts in an application like GateIn Platform is a critical part of the configuration work if you want to get good response time.
Every portlet can have its own javscript code but in many cases it is more convenient to reuse some existing shared libraries. For that reason, GateIn has a mechanism to easily register the libraries that will be loaded when the first page will be rendered. To do so, every WAR deployed in GateIn can register the js files thanks to a groovy script "WEB-INF/conf/script/groovy/JavascriptScript.groovy". The next file is the one you can find in the GateInResources.war
JavascriptService.addJavascript("GateIn", "/javascript/GateIn.js", ServletContext); /* Animation Javascripts */ JavascriptService.addJavascript("GateIn.animation.ImplodeExplode", "/javascript/GateIn/animation/ImplodeExplode.js", ServletContext); /* Application descriptor */ JavascriptService.addJavascript("GateIn.application.ApplicationDescriptor", "/javascript/GateIn/application/ApplicationDescriptor.js", ServletContext); /* CORE Javascripts */ JavascriptService.addJavascript("GateIn.core.Utils", "/javascript/GateIn/core/Util.js", ServletContext); JavascriptService.addJavascript("GateIn.core.DOMUtil", "/javascript/GateIn/core/DOMUtil.js", ServletContext); JavascriptService.addJavascript("GateIn.core.Browser", "/javascript/GateIn/core/Browser.js", ServletContext); JavascriptService.addJavascript("GateIn.core.MouseEventManager", "/javascript/GateIn/core/MouseEventManager.js", ServletContext); JavascriptService.addJavascript("GateIn.core.UIMaskLayer", "/javascript/GateIn/core/UIMaskLayer.js", ServletContext); JavascriptService.addJavascript("GateIn.core.Skin", "/javascript/GateIn/core/Skin.js", ServletContext); JavascriptService.addJavascript("GateIn.core.DragDrop", "/javascript/GateIn/core/DragDrop.js", ServletContext); JavascriptService.addJavascript("GateIn.core.TemplateEngine", "/javascript/GateIn/core/TemplateEngine.js", ServletContext); /* Widget Javascripts */ JavascriptService.addJavascript("GateIn.widget.UIWidget", "/javascript/GateIn/widget/UIWidget.js", ServletContext); JavascriptService.addJavascript("GateIn.widget.UIAddWidget", "/javascript/GateIn/widget/UIAddWidget.js", ServletContext); JavascriptService.addJavascript("GateIn.widget.UIExoWidget", "/javascript/GateIn/widget/UIExoWidget.js", ServletContext); /* Desktop Javascripts */ JavascriptService.addJavascript("GateIn.desktop.UIDockbar", "/javascript/GateIn/desktop/UIDockbar.js", ServletContext); JavascriptService.addJavascript("GateIn.desktop.UIDesktop", "/javascript/GateIn/desktop/UIDesktop.js", ServletContext); /* WebUI Javascripts */ JavascriptService.addJavascript("GateIn.webui.UIItemSelector", "/javascript/GateIn/webui/UIItemSelector.js", ServletContext); JavascriptService.addJavascript("GateIn.webui.UIForm", "/javascript/GateIn/webui/UIForm.js", ServletContext); JavascriptService.addJavascript("GateIn.webui.UIPopup", "/javascript/GateIn/webui/UIPopup.js", ServletContext); JavascriptService.addJavascript("GateIn.webui.UIPopupSelectCategory", "/javascript/GateIn/webui/UIPopupSelectCategory.js", ServletContext); JavascriptService.addJavascript("GateIn.webui.UIPopupWindow", "/javascript/GateIn/webui/UIPopupWindow.js", ServletContext); JavascriptService.addJavascript("GateIn.webui.UIVerticalScroller", "/javascript/GateIn/webui/UIVerticalScroller.js", ServletContext); JavascriptService.addJavascript("GateIn.webui.UIHorizontalTabs", "/javascript/GateIn/webui/UIHorizontalTabs.js", ServletContext); JavascriptService.addJavascript("GateIn.webui.UIPopupMenu", "/javascript/GateIn/webui/UIPopupMenu.js", ServletContext); JavascriptService.addJavascript("GateIn.webui.UIDropDownControl", "/javascript/GateIn/webui/UIDropDownControl.js", ServletContext); /* Portal Javascripts */ JavascriptService.addJavascript("GateIn.portal.PortalHttpRequest", "/javascript/GateIn/portal/PortalHttpRequest.js", ServletContext); JavascriptService.addJavascript("GateIn.portal.UIPortal", "/javascript/GateIn/portal/UIPortal.js", ServletContext); JavascriptService.addJavascript("GateIn.portal.UIWorkspace", "/javascript/GateIn/portal/UIWorkspace.js", ServletContext); JavascriptService.addJavascript("GateIn.portal.UIPortalControl", "/javascript/GateIn/portal/UIPortalControl.js", ServletContext); JavascriptService.addJavascript("GateIn.portal.PortalDragDrop", "/javascript/GateIn/portal/PortalDragDrop.js", ServletContext); JavascriptService.addJavascript("GateIn.portal.UIPortalNavigation", "/javascript/GateIn/portal/UIPortalNavigation.js", ServletContext); JavascriptService.addJavascript("GateIn.portal.UIMaskWorkspace", "/javascript/GateIn/portal/UIMaskWorkspace.js", ServletContext); JavascriptService.addJavascript("GateIn.portal.UIExoStartMenu", "/javascript/GateIn/portal/UIExoStartMenu.js", ServletContext); /* Desktop Javascripts 2 */ JavascriptService.addJavascript("GateIn.desktop.UIWindow", "/javascript/GateIn/desktop/UIWindow.js", ServletContext);
Note that even if the you register dedicated javascripts, they will be merged into a single merged.js
file when the server will load in order to reduce the number of HTTP calls as seen in the home page source code:
<script type="text/javascript" src="/portal/javascript/merged.js"></script>
Although this optimization is useful for a production environment, you may find it easier to deactivate this optimization while debugging your javascript. For that, you simply need to set the java system property exo.product.developing
to true
. But if you want to see or use the merged file you have to set this property to false
. You can pass the property as a JVM parameter with the -D
option in your GateIn.sh
or GateIn.bat
startup script: {code} EXO{code}
Every javascript file is referenced with a module name of type "GateIn.core.DragDrop" which acts like a namespace. Inside the associated files, global javascript functions are used following the same namespace convention:
GateIn.core.DragDrop = new DragDrop() ;
It is also possible to use the GateIn.require() javascript method to lazy load and evaluate some javascript code. This is quite useful from the portlet or widget applications that will use this javascript only once. Otherwise, if the library is reusable in several places it is better to reference it in the groovy file.
In this article, you will learn:
Token service is used in authentication.
Using token helps preventing information such as user name, password into user request so the system will become more secure.
Token service provides the way to manipulate tokens such as create, delete, retrieve, clean ... Token service also defines the life-time of token. After the life-time, token has no more effect. The life-time definition must be configured.
All token services used in GateIn portal's authentication must be a subclass of an abstract class AbstractTokenService . So they must have these following methods:
public Token getToken(String id) throws PathNotFoundException, RepositoryException; public Token deleteToken(String id) throws PathNotFoundException, RepositoryException; public String[] getAllTokens(); public long getNumberTokens() throws Exception; public String createToken(Credentials credentials) throws IllegalArgumentException,NullPointerException; public Credentials validateToken(String tokenKey, boolean remove) throws NullPointerException;
These methods show how the token-service manipulates its tokens.
Token services configuration is also known as specifying the life-time of token in the configuration file. The token service is configured as a portal component.
Examples:
<component> <key>org.exoplatform.web.security.security.CookieTokenService</key> <type>org.exoplatform.web.security.security.CookieTokenService</type> <init-params> <values-param> <name>tokenTimeout</name> <value>jcr-token</value> <value>7</value> <value>DAY</value> </values-param> </init-params> </component>
In this example, CookieTokenService is a subclass of AbstractTokenService so it has a property which specifies how long token can live.
Service will initiate this property by looking for an init-param named as "service.configuration". This property must have 3 values (service's name, amount of time, unit of time). In this case, we can see the service's name is "jcr-token", the token's expiration time is a week.
At this time, GateIn Portal supports four timing units: SECOND, MINUTE, HOUR and DAY.
This document is an overview of Varnish configuration for GateIn SEA Portal. It is organized as follows:
Varnish is a HTTP/web accelerator, it was written from the beginning to be a high-performance open source reverse proxy caching implementation. Varnish, like other caching reverse HTTP proxy implementations, is most frequently used to alleviate/reduce origin web servers of undue load, giving you the ability to handle a higher number of concurrent hits.
Nowadays, more and more web sites present dynamic web pages consisting of a number of different elements. Combining these elements is both time consuming and CPU intensive. The bad news is that the same process is repeated for every individual user, even when the content is identical. Fortunately in such a case a solution like Varnish can help to improve web server performance. How can Varnish accomplish this? Varnish temporarily stores the most frequently requested pages in its cache. It is more effective to present these pages from the Varnish cache. Therefore, users are offered an improved service, and Content/Document Management System server requirements are reduced.
Before building Varnish, make sure that the following tools are installed :
If you are using a system with a graphical user interface, installation of Varnish 1.1.2 is quite easy via synaptic package manager. If not, you can run in a terminal by the following command to install Varnish on your computer:
You can also install Varnish from source, see the following web site for more information:
http://varnish.projects.linpro.no.
Varnish uses Varnish Configuration Language (VCL). The VCL language is a small domain-specific language designed to be used to define request handling and document caching policies for the Varnish HTTP accelerator. When a new configuration is loaded, the varnished management process translates the VCL code to C and compiles it to a shared object which is then dynamically linked into the server process.
Installation of Varnish automatically create two files named default.vcl and varnish in the repositories /etc/varnish/ and /etc/default respectively. One is VCL and another one contains values that will be passed as parameters to varnished . We will not make use of the first one, that is default.vcl. Create a new file named vcl.conf in /etc/varnish with the following contents:
Backend declaration, here we need to specify the web server host name and the listening http port.
backend default { set backend.host = "127.0.0.1"; set backend.port = "8080"; } # ## Called when a client request is received # sub vcl_recv { if (req.url ~ "^/$") { set req.url = regsub(req.url,"^/$","/portal"); set req.http.Accept-Language = "vi"; } if (req.url ~ ".*vnwebsite.*"){ set req.http.Accept-Language = "vi"; } else { set req.http.Accept-Language = "en"; } if (req.request!images/= "GET" && req.request!images/ = "HEAD") { pipe; } if (req.http.Expect) { pipe; } if (req.request == "GET" && req.url ~ "\.(jpg|jpeg|gif|ico|tiff|tif|svg|css|js|html)$") { set req.url = regsub(req.url, "\?.*", ""); remove req.http.cookie; remove req.http.authenticate; lookup; } if (req.http.Authenticate || req.http.Authorization) { pass; } if (req.http.Cache-Control ~ "no-cache") { set req.http.Cache-Control = regsub(req.http.Cache-Control, "no-cache", "set-cookie2"); } # force lookup even when cookies are present if (req.request == "GET" && req.http.cookie) { lookup; } lookup; }
In order to specify the default language for each web site, that is Vietnamese (vi) for vnwebsite and English (en) for enwebsite; the following statement set req.http.Accept-Language = "language code" is useful.
# ## Called when entering pipe mode # sub vcl_pipe { pipe; } # ## Called when entering pass mode # sub vcl_pass { pass; } # ## Called when the requested object was found in the cache # sub vcl_hit { if (req.url ~ ".*vnwebsite.*"){ set req.http.Accept-Language = "vi"; } else { set req.http.Accept-Language = "en"; } deliver; } ## Called when the requested object has been retrieved from the ## backend, or the request to the backend has failed sub vcl_fetch { if (!obj.valid) { error; } if (req.url ~ ".*vnwebsite.*"){ set req.http.Accept-Language = "vi"; } else { set req.http.Accept-Language = "en"; } if (req.http.Cache-Control ~ "no-cache") { set req.http.Cache-Control = regsub(req.http.Cache-Control, "no-cache", "set-cookie2"); } if(obj.cacheable){ remove req.http.Set-Cookie; set obj.http.Cache-Control = "no-cache"; remove obj.http.Etag; if(obj.ttl < 7d){ set obj.ttl = 7d; } insert; } insert; }
If the cookie is intended for use by a single user, the Set-Cookie2 header should not be cached. A Set-Cookie2 header that is intended to be shared by multiple users may be cached.
## Called before a cached object is delivered to the client sub vcl_deliver { deliver; } ## Called when an object nears its expiry time sub vcl_timeout { discard; } ## Called when an object is about to be discarded sub vcl_discard { discard; }
This configuration tells Varnish to always cache all cacheable objects and don't invalidate them for at least one week.
Then modify the file /etc/default/varnish and make yourself sure that its content is not too different to this one, particularly the DAEMONOPTS part. Note that we are using the advanced configuration, that is alternative 3.
# Configuration file for varnish # # /etc/init.d/varnish expects the variable $DAEMON_OPTS to be set from this # shell script fragment. # # Maximum number of open files (for ulimit -n) NFILES=131072 # Default varnish instance name is the local nodename. Can be overridden with # the -n switch, to have more instances on a single server. INSTANCE=$(uname -n) ## Alternative 3, Advanced configuration ## We choose advance configuration # # See varnishd(1) for more information. # # # Main configuration file. You probably want to change it :) VARNISH_VCL_CONF=/etc/varnish/default.vcl # # # Default address and port to bind to # # Blank address means all IPv4 and IPv6 interfaces, otherwise specify # # a host name, an IPv4 dotted quad, or an IPv6 address in brackets. VARNISH_LISTEN_ADDRESS=0.0.0.0 VARNISH_LISTEN_PORT=80 # # # Telnet admin interface listen address and port VARNISH_ADMIN_LISTEN_ADDRESS=127.0.0.1 VARNISH_ADMIN_LISTEN_PORT=6082 # # # The minimum number of worker threads to start VARNISH_MIN_THREADS=1 # # # The Maximum number of worker threads to start VARNISH_MAX_THREADS=2048 # # # Idle timeout for worker threads VARNISH_THREAD_TIMEOUT=120 # # # Cache file location VARNISH_STORAGE_FILE=/var/lib/varnish/$INSTANCE/varnish_storage.bin # # # Cache file size: in bytes, optionally using k / M / G / T suffix, # # or in percentage of available disk space using the % suffix. VARNISH_STORAGE_SIZE=5G # # # Backend storage specification VARNISH_STORAGE="file,${VARNISH_STORAGE_FILE},${VARNISH_STORAGE_SIZE}" # # # Default TTL used when the backend does not specify one VARNISH_TTL=7d # # # DAEMON_OPTS is used by the init script. If you add or remove options, make # # sure you update this section, too. DAEMON_OPTS="-a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT} \ -f ${VARNISH_VCL_CONF} \ -T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \ -t ${VARNISH_TTL} \ -w ${VARNISH_MIN_THREADS},${VARNISH_MAX_THREADS},${VARNISH_THREAD_TIMEOUT} \ -s ${VARNISH_STORAGE}"
When using an HTTP accelerator, it is important to know whether our web server performance has improved or not. Thus, this section shows the performance gained by the use of Varnish.
Our Varnish testbed consists of a desktop PC acting as a web server (WS), and 10 PC-based Linux acting as clients stations. The system hardware configuration is summarized in the following table. All machines except the WS use a Linux 2.6.27 kernel. The user-agent used on client stations is wget
The following table is the testbed summary:
Hardware | Processor | Frequency |
One x (WS) | Intel(R) Pentium(R) 4 | 3.00GHz |
Two x (PC) | Intel(R) Core(TM)2 Duo | 2.00GHz |
It is well known that performance of a software like varnish depends on part on the communication link between server host and client stations. So, without loss of generality, we assume that our wireless connection is fair.
In other to evaluate Vanish performance, we first access all pages of our web site through Varnish to ensure that all cacheable objects can be found in Varnish cache. It takes in average 6.9s. Then we simultaneously send 100 download requests from each of our 2 client stations to the web server using wget user-agent through Varnish. After this operation, we evaluate the average time required by each client station to perform a download request. The same process is done without using Varnish. We then compare the obtained results.
This part discuss about Varnish performance in term of time of response. That is the time that a given client should wait to get the requested object (or the server response). In this case the requested object is our entire web site. The collected measurements are summarized in the below table:
Host | Average waiting time using Varnish as reverse proxy | Average waiting time without use of Varnish | Number of trials | Data size |
First | 02. 791070 | 26.889563 | 100 | 104 files, 1.4M |
Second | 02.708190 | 26. 378669 | 100 | 104 files, 1.4M |
Measurements listed above obviously shows that our web server performance are considerably improved by the use of Varnish software. In average per user request, we gain from Varnish 24 (twenty-four) seconds. That is using Varnish, user requests are at least 10 times faster than previously (without Varnish).
This chapter describes the portal lifecycle from the application server start to its stop as well as how requests are handled.
An GateIn Portal instance is simply a web application deployed as a WAR in an application server. Each portlet is also part of an enhanced WAR that we call a portlet application. Hence, the portal web.xml file is the main entry point to grab information about how does the portal start.
The web.xml file contains several information such as a listener, a servlet as well as some security information.
In the web.xml we can find servlet listener:
<!- ================================================================== -> <!- LISTENER -> <!- ================================================================== -> <listener> <listener-class>org.exoplatform.portal.application.PortalSessionListener</listener-class> </listener>
That listener implements the HttpSessionListener which means it is called each time a session is created or destroyed; in other words, a session is created each time a user send a first request to the portal. That session is destroyed when he has not sent request to the portal for a long time or when he closes his browser.
public class PortalSessionListener implements HttpSessionListener
Only the destroy method of the Listener object is implemented and it is used to flush resources when a user portal session expires. Here is the code:
/** * This method is called when a HTTP session of a Portal instance is destroyed. * By default the session time is 30 minutes. * * In this method, we: * 1) first get the portal instance name from where the session is removed. * 2) Get the correct instance object from the Root container * 3) Put the portal instance in the Portal ThreadLocal * 4) Get the main entry point (WebAppController) from the current portal container * 5) Extract from the WebAppController the PortalApplication object which is the entry point to * the StateManager object * 6) Expire the portal session stored in the StateManager * 7) Finally, removes the WindowInfos object from the WindowInfosContainer container * 8) Flush the threadlocal for the PortalContainer * */ public void sessionDestroyed(HttpSessionEvent event) { try { String portalContainerName = event.getSession().getServletContext().getServletContextName() ; log.warn("Destroy session from " + portalContainerName + " portal"); RootContainer rootContainer = RootContainer.getInstance() ; PortalContainer portalContainer = rootContainer.getPortalContainer(portalContainerName) ; PortalContainer.setInstance(portalContainer); WebAppController controller = (WebAppController)portalContainer.getComponentInstanceOfType(WebAppController.class) ; PortalApplication portalApp = controller.getApplication(PortalApplication.PORTAL_APPLICATION_ID) ; portalApp.getStateManager().expire(event.getSession().getId(), portalApp) ; WindowInfosContainer.removeInstance(portalContainer, event.getSession().getId()); } catch(Exception ex) { log.error("Error while destroying a portal session",ex); } finally { PortalContainer.setInstance(null) ; } }
1.1 The Servlet
The servlet is the main entry point for incoming requests, it also includes some interesting init code when the portal is launched.
Here is its definition in the web.xml file:
<!-- ================================================================== --> <!-- SERVLET --> <!-- ================================================================== --> <servlet> <servlet-name>portal</servlet-name> <servlet-class>org.exoplatform.portal.application.PortalController</servlet-class> <init-param> <param-name>webui.configuration</param-name> <param-value>app:/WEB-INF/webui-configuration.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet>
The load-on-startup tag tells that the init method of the servlet is called when the application server starts. We also define some configuration for the portal at the path WEB-INF/webui-configuration.xml inside the portal WAR.
/** * The PortalContainer servlet is the main entry point for the GateIn Portal product. * * Both the init() and service() methods are implemented. The first one is used to configure all the * portal resources to prepare the platform to receive requests. The second one is used to handle them. * * Basically, this class is just dispatcher as the real business logic is implemented inside * the WebAppController class. */ @SuppressWarnings("serial") public class PortalController extends HttpServlet { protected static Log log = ExoLogger.getLogger("portal:PortalController"); /** * The init() method is used to prepare the portal to receive requests. * * 1) Create the PortalContainer and store it inside the ThreadLocal object. The PortalContainer is * a child of the RootContainer * 2) Get the WebAppController component from the container * 3) Create a new PortalApplication, init it with the ServletConfig object (which contains init params) * 4) Register that PortalApplication inside WebAppController * 5) Create a new PortalRequestHandler object and register it in the WebAppController * 6) Release the PortalContainer ThreadLocal */ @SuppressWarnings("unchecked") public void init(ServletConfig config) throws ServletException { super.init(config) ; try { RootContainer rootContainer = RootContainer.getInstance() ; PortalContainer portalContainer = rootContainer.getPortalContainer(config.getServletContext().getServletContextName()) ; portalContainer = rootContainer.createPortalContainer(config.getServletContext()) ; PortalContainer.setInstance(portalContainer) ; WebAppController controller = (WebAppController)portalContainer.getComponentInstanceOfType(WebAppController.class) ; PortalApplication application = new PortalApplication(config); application.onInit() ; controller.addApplication(application) ; controller.register(new PortalRequestHandler()) ; } catch (Throwable t){ throw new ServletException(t) ; } finally { try { PortalContainer.setInstance(null) ; } catch (Exception e) { log.warn("An error occured while cleaning the ThreadLocal", e); } } log.info("Init of PortalController Servlet successful"); } ...
We see that a PortalApplication class is instantiated, initialized and then referenced inside the WebAppController. Note that the WebAppController is a component located inside GateIn IoC service container (and hence registered in one of our service configuration XML file).
The <code><strong>PortalApplication</strong></code> extends the <code><strong>WebuiApplication</strong></code> which itself extends the <code><strong>Application</strong></code> abstract class.
public class PortalApplication extends WebuiApplication { protected static Log log = ExoLogger.getLogger("portal:PortalApplication"); final static public String PORTAL_APPLICATION_ID = "PortalApplication" ; private ServletConfig sconfig_ ; private String[] applicationResourceBundleNames_ ; /** * The constructor references resource resolvers that allows the ApplicationResourceResolver to * extract files from different locations such as the current war or external one such as the resource * one where several static files are shared among all portal instances. * * * @param config, the servlet config that contains init params such as the path location of * the XML configuration file for the WebUI framework */ public PortalApplication(ServletConfig config) throws Exception { sconfig_ = config ; ApplicationResourceResolver resolver = new ApplicationResourceResolver() ; resolver.addResourceResolver(new ServletResourceResolver(config.getServletContext(), "war:")) ; resolver.addResourceResolver(new ServletResourceResolver(config.getServletContext(), "app:")) ; resolver.addResourceResolver(new ServletResourceResolver(config.getServletContext(), "system:")) ; resolver.addResourceResolver(new ServletResourceResolver(config.getServletContext().getContext("/GateInResources"), "resources:")) ; setResourceResolver(resolver) ; } ...
The main goal of this constructor is to fill an <code><strong>ApplicationResourceResolver</strong></code> with several <code><strong>ResourceResolver</strong></code> object that will allow the application to check for files such as groovy templates into different locations. Here the goal of the <code><strong>ResourceResolver</strong></code> is to abstract the different mechanisms to extract files from different location. In the previous code sample the <code><strong>ServletResourceResolver</strong></code> is used and hence methods based on the servlet context object are defined. Note that the <code><strong>ApplicationResourceResolver</strong></code> is also a class of type <code><strong>ResourceResolver</strong></code> but a special one as it can also contains several <code><strong>ResourceResolver</strong></code> itself.
Then the <code><strong>onInit()</strong></code> method of the <code><strong>PortalApplication</strong></code> is called.
/** * This method first calls the super.onInit() of the WebuiApplication. That super method parse the XML * file and stores its content in the ConfigurationManager object. It also set up he StateManager and * init the application lifecycle phases. * * Then we get all the properties file that will be used to create ResourceBundles */ public void onInit() throws Exception { super.onInit() ; applicationResourceBundleNames_ = getConfigurationManager().getApplication().getInitParams(). getParam("application.resource.bundle").getValue().split(","); for(int i = 0; i < applicationResourceBundleNames_.length; i++) { applicationResourceBundleNames_[i] = applicationResourceBundleNames_[i].trim() ; } }
The <code><strong>ConfigurationManager</strong></code> object parses the XML configuration file. The idea of the framework, once again, is to abstract the type of <code><strong>webapplication</strong></code> in used. Hence the <code><strong>webui-configuration.xml</strong></code> file is used by both the portal and portlet applications.
Here is the <code><strong>webui-configuration</strong></code>:
<webui-configuration> <application> <init-params> <param> <name>application.resource.bundle</name> <value>locale.portal.expression, locale.portal.services, locale.portal.webui</value> </param> </init-params> <ui-component-root>org.exoplatform.portal.webui.workspace.UIPortalApplication</ui-component-root> <state-manager>org.exoplatform.portal.application.PortalStateManager</state-manager> <application-lifecycle-listeners> <listener>org.exoplatform.portal.application.PortalStatisticLifecycle</listener> <listener>org.exoplatform.portal.application.PortalApplicationLifecycle</listener> <listener>org.exoplatform.webui.application.MonitorApplicationLifecycle</listener> </application-lifecycle-listeners> <events> <event> <event-name>portal.application.lifecycle.event</event-name> <listener>org.exoplatform.webui.event.ConsoleEventMonitorListener</listener> </event> <event> <event-name>portal.execution.lifecycle.event</event-name> <listener>org.exoplatform.webui.event.ConsoleEventMonitorListener</listener> </event> </events> </application> </webui-configuration>
In the previous XML file we see that we define several tags such as:
1.1.1 The ui-component-root
Here it is the class <code><strong>org.exoplatform.portal.webui.workspace.UIPortalApplication</strong></code> which is a class that extends the <code><strong>UIApplication</strong></code> and hence is a sibling of <code><strong>UIPortletApplication</strong></code> (used by any GateIn Portlets as the Parent class to build the portlet component tree).
The <code><strong>UIPortalApplication</strong></code> is responsible for building its subtrees - at request time according to some configuration parameters. If all components are displayed it is composed of 3 UI components:
The <code><strong>UIPortalApplication</strong><code> constructor is shown next and is the starting point to build the UI Component tree to which Pages and Portlets will also be mounted. We will not describe that behavior here.
/** * The constructor of this class is used to build the tree of UI components that will be aggregated * in the portal page. * * 1) The component is stored in the current PortalRequestContext ThreadLocal * 2) The configuration for the portal associated with the current user request is extracted from the * PortalRequestContext * 3) Then according to the context path, either a public or private portal is initiated. Usually a public * portal does not contain the left column and only the private one has it. * 4) The skin to use is setup * 5) Finally, the current component is associated with the current portal owner * * @throws Exception */ public UIPortalApplication() throws Exception { log = ExoLogger.getLogger("portal:UIPortalApplication"); PortalRequestContext context = PortalRequestContext.getCurrentInstance() ; userPortalConfig_ = (UserPortalConfig)context.getAttribute(UserPortalConfig.class); if(userPortalConfig_ == null) throw new Exception("Can't load user portal config"); // dang.tung - set portal language by user preference -> browser -> default //---- String portalLanguage = null ; LocaleConfigService localeConfigService = getApplicationComponent(LocaleConfigService.class) ; OrganizationService orgService = getApplicationComponent(OrganizationService.class) ; LocaleConfig localeConfig = localeConfigService.getLocaleConfig(userPortalConfig_.getPortalConfig().getLocale()); String user = context.getRemoteUser(); if(user!images/= null) { UserProfile userProfile = orgService.getUserProfileHandler().findUserProfileByName(user) ; if(userProfile!images/= null) { portalLanguage = userProfile.getUserInfoMap().get("user.language") ; } else { if (log.isWarnEnabled()) log.warn("Could not load user profile for " + user + ". Using default portal locale."); } } localeConfig = localeConfigService.getLocaleConfig(portalLanguage) ; if(portalLanguage == null ||!images/portalLanguage.equals(localeConfig.getLanguage())) { // if user language no support by portal -> get browser language if no -> get portal portalLanguage = context.getRequest().getLocale().getLanguage() ; localeConfig = localeConfigService.getLocaleConfig(portalLanguage) ; if(!portalLanguage.equals(localeConfig.getLanguage())) { localeConfig = localeConfigService.getLocaleConfig(userPortalConfig_.getPortalConfig().getLocale()) ; } } setLocale(localeConfig.getLocale()) ; setOrientation(localeConfig.getOrientation()); //---- context.setUIApplication(this); UserACL acl = getApplicationComponent(UserACL.class); if(acl.hasAccessControlWorkspacePermission(context.getRemoteUser())) addChild(UIControlWorkspace.class, UIPortalApplication.UI_CONTROL_WS_ID, null) ; addWorkingWorkspace() ; String currentSkin = userPortalConfig_.getPortalConfig().getSkin(); if(currentSkin!images/= null && currentSkin.trim().length() > 0) skin_ = currentSkin; setOwner(context.getPortalOwner()); } ...
1.1.1 The StateManager
The <code><strong>StateManager</strong></code> here is in the <code><strong>org.exoplatform.portal.application</strong></code> package which is an abstract class.
abstract public class StateManager { abstract public UIApplication restoreUIRootComponent(WebuiRequestContext context) throws Exception ; abstract public void storeUIRootComponent(WebuiRequestContext context) throws Exception ; abstract public void expire(String sessionId, WebuiApplication app) throws Exception ; }
The goal of the <code><strong>StateManager</strong></code> is to abstract the way <code><strong>UIApplication</strong></code> are stored and restored for all the user session lifetime. The expire method is called from the listener we have introduced before in this chapter.
1.1.1 The application-lifecycle-listeners
There are 2 lifecycle listeners in the Portal, one for the real business logic (<code><strong>PortalApplicationLifecycle</strong></code>), the other one for some monitoring issues. They both implement the interface <code><strong>ApplicationLifecycle<E extends RequestContext></strong></code>.
public interface ApplicationLifecycle<E extends RequestContext> { public void onInit(Application app) throws Exception ; public void onStartRequest(Application app, E context) throws Exception ; public void onEndRequest(Application app, E context) throws Exception ; public void onDestroy(Application app) throws Exception ; }
Each registered lifecycle listener will then be able to get events when several states of the portal lifecycle are reached.
1.1 The Request Handler
Once started and fully configured, the portal application WAR can handle HTTP requests.
The entry point is for sure the PortalController servlet we have already seen in the current chapter and defined in the <code><strong>web.xml</strong></code> of the portal context.
... /** * This method simply delegates the incoming call to the WebAppController stored in the Portal Container object */ public void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { try { ServletConfig config = getServletConfig() ; RootContainer rootContainer = RootContainer.getInstance() ; PortalContainer portalContainer = rootContainer.getPortalContainer(config.getServletContext().getServletContextName()) ; PortalContainer.setInstance(portalContainer) ; WebAppController controller = (WebAppController)portalContainer.getComponentInstanceOfType(WebAppController.class) ; controller.service(req, res) ; } catch (Throwable t){ throw new ServletException(t) ; } finally { try { PortalContainer.setInstance(null) ; } catch (Exception e) { log.warn("An error occured while cleaning the ThreadLocal", e); } } ...
The <code><strong>WebAppController</strong></code> is also a simple class on which several handlers can be bound. We have already seen that the <code><strong>PortalRequestHandler</strong></code> was already added in the init method of the servlet.
... /** * The WebAppControler along with the PortalRequestHandler defined in the init() method of the * PortalController servlet (controller.register(new PortalRequestHandler())) also add the * CommandHandler object that will listen for the incoming /command path in the URL * * @throws Exception */ public WebAppController() throws Exception { applications_ = new HashMap<String, Application>() ; attributes_ = new HashMap<String, Object>() ; handlers_ = new HashMap<String, WebRequestHandler>() ; register(new CommandHandler()) ; } ...
Then the service method - modelled according to the servlet specification is called:
... /** * This is the first method - in the GateIn web framework - reached by incoming HTTP request, it acts like a * servlet service() method * * According to the servlet path used the correct handler is selected and then executed. * * The event "exo.application.portal.start-http-request" and "exo.application.portal.end-http-request" are also sent * through the ListenerService and several listeners may listen to it. * * Finally a WindowsInfosContainer object using a ThreadLocal (from the portlet-container product) is created */ public void service(HttpServletRequest req, HttpServletResponse res) throws Exception { WebRequestHandler handler = handlers_.get(req.getServletPath()) ; if(log.isDebugEnabled()) { log.debug("Servlet Path: " + req.getServletPath()); log.debug("Handler used for this path: " + handler); } if(handler!images/= null) { ExoContainer portalContainer = ExoContainerContext.getCurrentContainer(); List<ComponentRequestLifecycle> components = portalContainer.getComponentInstancesOfType(ComponentRequestLifecycle.class) ; try { for(ComponentRequestLifecycle component : components) { component.startRequest(portalContainer); } WindowInfosContainer.createInstance(portalContainer, req.getSession().getId(), req.getRemoteUser()); handler.execute(this, req, res) ; } finally { WindowInfosContainer.setInstance(null); for(ComponentRequestLifecycle component : components) { try { component.endRequest(portalContainer); } catch (Exception e) { log.warn("An error occured while calling the endRequest method", e); } } } } ...
The handler in the portal case is the <code><strong>PortalRequestHandler</strong></code> which extends <code><strong>WebRequestHandler</strong></code> and that implement the abstract methods, mainly the execute() one.
/** * Created by The GateIn Platform SAS * Mar 21, 2007 * * Abstract class that one must implement if it want to provide a dedicated handler for a custom servlet path * * In case of portal the path is /portal but you could return your own from the getPath() method and hence the * WebAppController would use your own handler * * The execute method is to be overideen and the buisness logic should be handled here */ abstract public class WebRequestHandler { public void onInit(WebAppController controller) throws Exception{ } abstract public String[] getPath() ; abstract public void execute(WebAppController app, HttpServletRequest req, HttpServletResponse res) throws Exception ; public void onDestroy(WebAppController controler) throws Exception { } }
Here is the main class and the entire algorithm is described in the javadoc:
/** * Created by The GateIn Platform SAS * Dec 9, 2006 * * This class handle the request that target the portal paths /public and /private * */ public class PortalRequestHandler extends WebRequestHandler { protected static Log log = ExoLogger.getLogger("portal:PortalRequestHandler"); static String[] PATHS = {"/public", "/private"} ; public String[] getPath() { return PATHS ; } /** * This method will handle incoming portal request. It gets a reference to the WebAppController * * Here are the steps done in the method: * * 1) set the header Cache-Control to no-cache * 2) Get the PortalApplication reference from the controller * 3) Create a PortalRequestContext object that is a convenient wrapper on all the request information * 4) Set that context in a ThreadLocal to easily access it * 5) Get the collection of ApplicationLifecycle referenced in the PortalApplication and defined in the * webui-configuration.xml of the portal application * 6) Call onStartRequest() on each ApplicationLifecycle object * 7) Get the StateManager object from the PortalApplication (also referenced in the XML file) * 8) Use the StateManager to get a reference on the root UI component: UIApplication; the method used is * restoreUIRootComponent(context) * 9) If the UI component is not the current one in used in the PortalContextRequest, then replace it * 10) Process decode on the PortalApplication * 11) Process Action on the PortalApplication * 12) Process Render on the UIApplication UI component * 11) call onEndRequest on all the ApplicationLifecycle * 12) Release the context from the thread * */ @SuppressWarnings("unchecked") public void execute(WebAppController controller, HttpServletRequest req, HttpServletResponse res) throws Exception { log.debug("Session ID = " + req.getSession().getId()); res.setHeader("Cache-Control", "no-cache"); PortalApplication app = controller.getApplication(PortalApplication.PORTAL_APPLICATION_ID) ; WebuiRequestContext context = new PortalRequestContext(app, req, res) ; ; WebuiRequestContext.setCurrentInstance(context) ; List<ApplicationLifecycle> lifecycles = app.getApplicationLifecycle(); try { for(ApplicationLifecycle lifecycle : lifecycles) lifecycle.onStartRequest(app, context) ; UIApplication uiApp = app.getStateManager().restoreUIRootComponent(context) ; if(context.getUIApplication()!images/= uiApp) context.setUIApplication(uiApp) ; if(uiApp!images/= null) app.processDecode(uiApp, context) ; if(!images/context.isResponseComplete() &&!images/ context.getProcessRender()) { app.processAction(uiApp, context) ; } if(!context.isResponseComplete()) uiApp.processRender(context) ; if(uiApp!images/= null) uiApp.setLastAccessApplication(System.currentTimeMillis()) ; } catch(Exception ex){ log.error("Error while handling request",ex); } finally { try { for(ApplicationLifecycle lifecycle : lifecycles) lifecycle.onEndRequest(app, context) ; } catch (Exception exception){ log.error("Error while ending request on all ApplicationLifecycle",exception); } WebuiRequestContext.setCurrentInstance(null) ; } }
The PortalRequestContext class is an important one as it is used in many places. The PortalRequestContext class wraps most of the request information. Accessing it from everywhere is quite simple as the object is stored in a ThreadLocal one, which means it bound to the current request thread. Hence a single call to WebuiRequestContext.getCurrentContext() will return the correct PortalRequestContext.
As you can see, the PortalRequestContext extends the WebuiRequestContext one which also extends the abstract class RequestContext. Once again this hierarchy is to abstract the type of context in use , would it be a portal or portlet one.
/** * Created by The GateIn Platform SAS * May 7, 2006 * * This abstract class is a wrapper on top of the request information such as the Locale in use, * the application (for instance PortalApplication, PortletApplication...), an access to the JavascriptManager * as well as a reference to the URLBuilder in use. * * It also contains a ThreadLocal object for an easy access. * * Context can be nested and hence a getParentAppRequestContext() is also available * */ abstract public class RequestContext { final static public String ACTION = "op"; private static ThreadLocal<RequestContext> tlocal_ = new ThreadLocal<RequestContext>() ; private Application app_ ; protected RequestContext parentAppRequestContext_ ; private Map<String, Object> attributes ; protected URLBuilder urlBuilder; public RequestContext(Application app) { app_ = app ; } public Application getApplication() { return app_ ; } public Locale getLocale() { return parentAppRequestContext_.getLocale() ; } public ResourceBundle getApplicationResourceBundle() { return null; } abstract public String getRequestParameter(String name) ; abstract public String[] getRequestParameterValues(String name) ; public JavascriptManager getJavascriptManager() { return getParentAppRequestContext().getJavascriptManager() ; } abstract public URLBuilder getURLBuilder() ; public String getRemoteUser() { return parentAppRequestContext_.getRemoteUser() ; } public boolean isUserInRole(String roleUser) { return parentAppRequestContext_.isUserInRole(roleUser) ; } abstract public boolean useAjax() ; public boolean getFullRender() { return true; } public ApplicationSession getApplicationSession() { throw new RuntimeException("This method is not supported"); } public Writer getWriter() throws Exception { return parentAppRequestContext_.getWriter() ; } final public Object getAttribute(String name) { if(attributes == null) return null ; return attributes.get(name) ; } final public void setAttribute(String name, Object value) { if(attributes == null) attributes = new HashMap<String, Object>() ; attributes.put(name, value) ; } final public Object getAttribute(Class type) { return getAttribute(type.getName()) ; } final public void setAttribute(Class type, Object value) { setAttribute(type.getName(), value) ; } public RequestContext getParentAppRequestContext() { return parentAppRequestContext_ ; } public void setParentAppRequestContext(RequestContext context) { parentAppRequestContext_ = context ; } @SuppressWarnings("unchecked") public static <T extends RequestContext> T getCurrentInstance() { return (T)tlocal_.get() ; } public static void setCurrentInstance(RequestContext ctx) { tlocal_.set(ctx) ; } }
The WebuiRequestContext abstract class extends the RequestContext one and adds method for a Web environment such as accesses to the request and response objects or a list of components to update when using an Ajax call. More in the following header of the class:
/** * Created by The GateIn Platform SAS * May 7, 2006 * * The main class to manage the request context in a webui environment * * It adds: * - some access to the root UI component (UIApplication) * - access to the request and response objects * - information about the current state of the request * - the list of object to be updated in an AJAX way * - an access to the ResourceResolver bound to an uri scheme * - the reference on the StateManager object */ abstract public class WebuiRequestContext extends RequestContext { protected UIApplication uiApplication_ ; protected String sessionId_ ; protected ResourceBundle appRes_ ; private StateManager stateManager_ ; private boolean responseComplete_ = false ; private boolean processRender_ = false ; private Throwable executionError_ ; private ArrayList<UIComponent> uicomponentToUpdateByAjax ; public WebuiRequestContext(Application app) { super(app) ; } public String getSessionId() { return sessionId_ ; } protected void setSessionId(String id) { sessionId_ = id ;} @SuppressWarnings("unchecked") public UIApplication getUIApplication() { return uiApplication_ ; } public void setUIApplication(UIApplication uiApplication) throws Exception { uiApplication_ = uiApplication ; appRes_ = getApplication().getResourceBundle(uiApplication.getLocale()) ; } public Locale getLocale() { return uiApplication_.getLocale() ;} public ResourceBundle getApplicationResourceBundle() { return appRes_ ; } public String getActionParameterName() { return WebuiRequestContext.ACTION ; } public String getUIComponentIdParameterName() { return UIComponent.UICOMPONENT; } abstract public String getRequestContextPath() ; abstract public <T> T getRequest() throws Exception ; abstract public <T> T getResponse() throws Exception ; public Throwable getExecutionError() { return executionError_ ; } public List<UIComponent> getUIComponentToUpdateByAjax() { return uicomponentToUpdateByAjax ; } public boolean isResponseComplete() { return responseComplete_ ;} public void setResponseComplete(boolean b) { responseComplete_ = b ; } public boolean getProcessRender() { return processRender_ ;} public void setProcessRender(boolean b) { processRender_ = b; } public void addUIComponentToUpdateByAjax(UIComponent uicomponent) { if(uicomponentToUpdateByAjax == null) { uicomponentToUpdateByAjax = new ArrayList<UIComponent>() ; } uicomponentToUpdateByAjax.add(uicomponent) ; } public ResourceResolver getResourceResolver(String uri) { Application app = getApplication() ; while(app!images/= null) { ApplicationResourceResolver appResolver = app.getResourceResolver() ; ResourceResolver resolver = appResolver.getResourceResolver(uri) ; if(resolver !images/= null) return resolver ; RequestContext pcontext = getParentAppRequestContext() ; if(pcontext!images/= null) app = pcontext.getApplication() ; else app =null ; } return null ; } public StateManager getStateManager() { return stateManager_; } public void setStateManager(StateManager manager) { stateManager_ = manager ; } }
The PortalRequestContext mainly implements the abstract method already shown and only add few ones such as a reference to the portal owner or some information on the current navigation node path and the state of the portal (PUBLIC or PRIVATE ones)
The PortalRequestHandler then tries to restore the UI component tree by calling the method restoreUIRootComponent(). The first time, there is nothing to restore and in that case the following part of code in the method is used:
if(state == null) { synchronized(uiApplications) { ConfigurationManager cmanager = app.getConfigurationManager() ; String uirootClass = cmanager.getApplication().getUIRootComponent() ; Class type = Thread.currentThread().getContextClassLoader().loadClass(uirootClass) ; UserPortalConfig config = getUserPortalConfig(pcontext) ; if(config == null) { HttpServletResponse response = pcontext.getResponse(); response.sendRedirect("/portal/portal-warning.html"); pcontext.setResponseComplete(true); return null; } pcontext.setAttribute(UserPortalConfig.class, config); UIPortalApplication uiApplication = (UIPortalApplication)app.createUIComponent(type, config.getPortalConfig().getFactoryId(), null, context) ; state = new PortalApplicationState(uiApplication, pcontext.getAccessPath()) ; uiApplications.put(context.getSessionId(), state) ; PortalContainer pcontainer = (PortalContainer) app.getApplicationServiceContainer() ; pcontainer.createSessionContainer(context.getSessionId(), uiApplication.getOwner()) ; } }
The configuration manager object bound to the PortalApplication one is used to get the type for the root component which is then instanciated. the UserPortalConfig object - which is wrapper around the portal information for a given user - is also used and stored as an attribute in the PortalRequestContext. The UIPortalApplication is then created using the method createUIComponent() that is responsible of instanciating the component but also to configure it.
public <T extends UIComponent> T createUIComponent(Class<T> type, String configId, String id, WebuiRequestContext context) throws Exception{ Component config = configManager_.getComponentConfig(type, configId) ; if(config == null) { throw new Exception("Cannot find the configuration for the component " + type.getName() + ", configId " +configId) ; } T uicomponent = Util.createObject(type, config.getInitParams()); uicomponent.setComponentConfig(id, config) ; config.getUIComponentLifecycle().init(uicomponent, context) ; return type.cast(uicomponent) ; }
The ConfigurationManager method getComponentConfig() returns the Component object filled, it is a wrapper that contains all the information on the parameters for the class. Annotations are used to configure the instance as shown here:
@ComponentConfigs({ @ComponentConfig ( lifecycle = UIPortalApplicationLifecycle.class, template = "system:/groovy/portal/webui/workspace/UIPortalApplication.gtmpl", initParams = @ParamConfig(name = "public.showControlWorkspace", value = "true" ) ), @ComponentConfig ( id = "office" , lifecycle = UIPortalApplicationLifecycle.class, template = "system:/groovy/portal/webui/workspace/UIPortalApplication.gtmpl", initParams = @ParamConfig( name = "public.showControlWorkspace", value = "false" ) ) })
The processDecode() method of the UIPortalApplication is doing 3 actions:
The first case it simply does nothing. Note that the super.processDecode() goes up to the UIComponent which also calls the processDecode() method on the Lifecycle object that can be associated with the UIComponent
The processAction() method of the UIPortalApplication is then called, as there is no method in the object itself it will call the processAction() of the UIPortalApplicationLifecycle bound to the UI component:
public void processAction(UIComponent uicomponent, WebuiRequestContext context) throws Exception { UIPortalApplication uiApp = (UIPortalApplication) uicomponent ; String componentId = context.getRequestParameter(context.getUIComponentIdParameterName()) ; if(componentId == null) return; UIComponent uiTarget = uiApp.findComponentById(componentId); if(uiTarget == null) return ; if(uiTarget == uicomponent) super.processAction(uicomponent, context) ; uiTarget.processAction(context) ; }
If no uicomponent object is targeted, which is the case the first time (unless a bookmarked link is used) then nothing is done. Otherwise, the targeted component is extracted and a call of its processAction() method is executed.
Then it is time to render the content and this is done inside the processRender() method. The method of the UIPortalApplication is shown here and it is the one that handles either full portal generation or AJAX request:
/** * The processrender() method handles the creation of the returned HTML either for a full * page render or in the case of an AJAX call * * The first request, Ajax is not enabled (means no ajaxRequest parameter in the request) and * hence the super.processRender() method is called. This will hence call the processrender() of * the Lifecycle object as this method is not overidden in UIPortalApplicationLifecycle. There we * simply render the bounded template (groovy usually). Note that bounded template are also defined * in component annotations, so for the current class it is UIPortalApplication.gtmpl * * On second calls, request have the "ajaxRequest" parameter set to true in the URL. In that case * the algorithm is a bit more complex: * * a) The list of components that should be updated is extracted using the * context.getUIComponentToUpdateByAjax() method. That list was setup during the process action * phase * b) Portlets and other UI components to update are split in 2 different lists * c) Portlets full content are returned and set with the tag <div class="PortalResponse"> * d) Block to updates (which are UI components) are set within * the <div class="PortalResponseData"> tag * e) Then the scripts and the skins to reload are set in the <div class="PortalResponseScript"> * */ public void processRender(WebuiRequestContext context) throws Exception { Writer w = context.getWriter() ; if(!context.useAjax()) { super.processRender(context) ; } else { PortalRequestContext pcontext = (PortalRequestContext)context; List<UIComponent> list = context.getUIComponentToUpdateByAjax() ; List<UIPortlet> uiPortlets = new ArrayList<UIPortlet>(3); List<UIComponent> uiDataComponents = new ArrayList<UIComponent>(5); if(list!images/= null) { for(UIComponent uicomponent : list) { if(uicomponent instanceof UIPortlet) uiPortlets.add((UIPortlet)uicomponent) ; else uiDataComponents.add(uicomponent) ; } } w.write("<div class=\"PortalResponse\">") ; if(!context.getFullRender()) { for(UIPortlet uiPortlet : uiPortlets) { uiPortlet.processRender(context) ; } } w. write("<div class=\"PortalResponseData\">"); for(UIComponent uicomponent : uiDataComponents) { renderBlockToUpdate(uicomponent, context, w) ; } String skin = getAddSkinScript(list); w. write("</div>"); w. write("<div class=\"PortalResponseScript\">"); w. write(pcontext.getJavascriptManager().getJavascript()); w. write("GateIn.core.Browser.onLoad();\n"); w. write(pcontext.getJavascriptManager().getCustomizedOnLoadScript()) ; if(skin!images/= null){ w. write(skin) ; } w. write("</div>") ; w.write("</div>") ; } }
The RTL framework (Right-To-Left framework) provides a set of tools that can be leveraged by the user interface components to handle directionality gracefully.
<object width="400" height="300"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clipid=2870309&server=vimeo.com&showtitle=1&showbyline=1&showportrait=0&color=&fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clipid=2870309&server=vimeo.com&showtitle=1&showbyline=1&showportrait=0&color=&fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="300"></embed></object><br /><a href="http://vimeo.com/">GateIn Portal: RTL - Arabic support</a> from <a href="http://vimeo.com/user896168">Benjamin Mestrallet</a> on <a href="http://vimeo.com">Vimeo</a>.
The orientation depends on the current locale and during a portal request the current orientation is made available by various means. The orientation is a Java 5 enum that provides a set of functionalities:
LT, // Western Europe RT, // Middle East (Arabic, Hebrew) TL, // Japanese, Chinese, Korean TR; // Mongolian public boolean isLT() { ... } public boolean isRT() { ... } public boolean isTL() { ... } public boolean isTR() { ... } }{code} The object defining the current Orientation for the current request is the UIPortalApplication. However it should be accessed at runtime using the RequestContext that delegates to the UIPortalApplication. In the case of a PortalRequestContext it is a direct delegate as the PortalRequestContext has a reference to the current UIPortalApplication. In case of a different context such as the PortletRequestContext, it delegates to the parent context given the fact that the root RequestContext is always a PortalRequestContext. h1. Usage in different layers h2. Java Orientation is obtained from the RequestContext:
Orientation is obtained from implicit variables defined by the groovy binding context:
The skin service handles stylesheet rewriting to accommodate the orientation. It works by appending -lt or -rt to the stylesheet name. For instance /web/skin/portal/webui/component/UIFooterPortlet/DefaultStylesheet-rt.css will return the same stylesheet as /web/skin/portal/webui/component/UIFooterPortlet/DefaultStylesheet.css but processed for the RT orientation. Obviously the -lt suffix is optional.
Stylesheet authors can annotate their stylesheet to create content that depends on the orientation.
In the example we need to use the orientation to modify the float attribute that will make the horizontal tabs either float on left or on right:
float: left; /* orientation=lt */ float: right; /* orientation=rt */ font-weight: bold; text-align: center; white-space: nowrap; }{code} The LT output will be:
float: left; /orientation=lt{/ font-weight: bold; text-align: center; white-space: nowrap; }{code}
The RT output will be:
float: right; /* orientation=rt */ font-weight: bold; text-align: center; white-space: nowrap; }{code} In this example we need to modify the padding according to the orientation:
color: white; line-height: 24px; padding: 0px 5px 0px 0px; /orientation=lt/ padding: 0px 0px 0px 5px; /orientation=rt{/ }{code}
The LT output will be:
color: white; line-height: 24px; padding: 0px 5px 0px 0px; /* orientation=lt */ }{code} The RT output will be:
color: white; line-height: 24px; padding: 0px 0px 0px 5px; /orientation=rt{/ }{code}
Sometime it is necessary to create an RT version of an image that will be used from a template or from a stylesheet. However symmetric images can be automatically generated avoiding the necessity to create a mirrored version of an image and furthermore avoiding maintenance cost.
The web resource filter uses the same naming pattern than the skin service does. When an image ends with the -rt suffix the portal will attempt to locate the original image and create a mirror of it. For instance requesting the image /GateInResources/skin/DefaultSkin/webui/component/UITabSystem/UITabs/background/NormalTabStyle-rt.gif returns a mirror of the image /GateInResources/skin/DefaultSkin/webui/component/UITabSystem/UITabs/background/NormalTabStyle.gif and it works perfectly because the image is symmetric.
Here is an example combining stylesheet and images:
line-height: 24px; background: url('background/NavigationTab.gif') no-repeat right top; /* orientation=lt */ background: url('background/NavigationTab-rt.gif') no-repeat left top; /* orientation=rt */ padding-right: 2px; /* orientation=lt */ padding-left: 2px; /* orientation=rt */ }{code} h2. Client side JavaScript Just use the *GateIn.core.I18n* object that provides the following methods: * getOrientation() : returns either the string lt or rt * getDir() : returns either the string ltr or rtl * isLT() : returns true for LT * isRT() : returns true of RT
All aspects of internationalization in GateIn products are covered. You should have a general knowledge of Internationalization in Java products. Sun created a good internationalization tutorial .
You should notice that
The executive-boarden.properties{code:none}{code} The keys (example: ~~organization.newstaff~~) can have any name but must not contain spaces. The values (~~New Staff~~) contain the translation to the language of the resource file. The suffix "en" means in this case "English".
1 LocalesConfig
<component> <key>org.exoplatform.services.resources.LocaleConfigService</key> <type>org.exoplatform.services.resources.impl.LocaleConfigServiceImpl</type> <init-params> <value-param> <name>locale.config.file</name> <value>war:/conf/common/locales-config.xml</value> </value-param> </init-params> </component>
The configuration points to the locale configuration file like this one: ::/WEB-INF/conf/common/locales-config:xml {code:xml} <locale-config> <locale>ar</locale> <output-encoding>UTF-8</output-encoding> <input-encoding>UTF-8</input-encoding> <description>Default configuration for the Arabic locale</description> <orientation>rt</orientation> </locale-config> {code}
The locale has to be defined using ISO 639 > http:--ftp.ics.uci.edu-pub-ietf-http-related-iso639.txt, in this example "ar" is Arabic.
This configuration defines also the list of languages in the "Change Language" section of the portal.
1.1 Encoding It's highly recommended to always use UTF-8. You should also encode all property files in UTF-8.
In the java implementation, the encoding parameters will be used for the request response stream. The input-encoding parameter will be used for request setCharacterEncoding(..).
1.1 Orientation The default orientation of text and images is Left-To-Right. As you know GateIn support Right-To-Left orientation. Therefore for Arabic you define
1 ResourceBundleService
The resource bundle service is configured here: // http://fisheye.exoplatform.org/browse/projects/portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/common/common-configuration.xml?r=28705
Caution: Other GateIn products like DMS use dedicated configuration file called "resource-bundle-configuration.xml".
A typical configuration looks like this one: {code:xml} <component> <key>org.exoplatform.services.resources.ResourceBundleService</key> <type>org.exoplatform.services.resources.jcr.ResourceBundleServiceImpl</type> <init-params>
<values-param> <name>classpath.resources</name> <description>The resources that start with the following package name should be loaded from file system</description> <value>locale.portlet</value> </values-param>
<values-param> <name>init.resources</name> <description>Store the following resources in the DB for the first launch </description> <value>locale.portal.expression</value> <value>locale.portal.services</value> <value>locale.portal.webui</value> <value>locale.portal.custom</value>
<value>locale.navigation.portal.classic</value> <value>locale.navigation.group.platform.administrators</value> <value>locale.navigation.group.platform.users</value> <value>locale.navigation.group.platform.guests</value> <value>locale.navigation.group.organization.management.executive-board</value> </values-param>
<values-param> <name>portal.resource.names</name> <description>The properties files of the portal, these files will be merged into one ResoruceBundle properties </description> <value>locale.portal.expression</value> <value>locale.portal.services</value> <value>locale.portal.webui</value> <value>locale.portal.custom</value> </values-param>
</init-params> </component>
There are three parameters: *classpath.resources*, *init.resources*, and *portal.resource.names*. We will talk later about _classpath.resources_. In _init.resources_ you have to define _*all resources*_ that you want use in the product, independently of the fact that they belong to the portal or to the navigation. All these resources are stored in JCR at the first launch of your product. After that, you only can modify these resources using the [Portal:Internationalization Portlet]. h2. Portal Resource Bundle The parameter *portal.resource.names* defines all resources that belong to the *Portal Resource Bundle*. This means that these resources are merged to a *single resource bundle* which is accessible from anywhere in GateIn products. As mentioned, all these keys are located in the same bundle, which is separated from the navigation resource bundles. h2. Navigation Resource Bundles There is a resource bundle for each navigation. A navigation can exist for user, groups, and portal. In the example above you see bundle definitions for the navigation of the classic portal and of four different groups. Each of these resource bundles lives in a different sphere, they are independent of each other and they do not belong to the portal.resource.names parameter (because they are not mentioned in _portal.resource.names_). As you learned in the introduction you must put the properties for a group in the _WEB-INF/classes/locale/navigation/group/_ folder. Example: *.../portal/trunk/web/portal/src/main/webapp/WEB-INF/classes/locale/navigation/group/organization/management/executive-board_en.properties* The folder and file names must correspond to the group hierarchy. The group name "executive-board" is followed by the iso 639 code. For each language you defined in the LocalesConfig you must provide a resource file. If you ever change the name of a group you also need to change the name of the folder and/or files of the correspondent navigation resource bundles. You already know the content of _executive-board_en.properties_: {code:none} organization.title=Organization organization.newstaff=New Staff organization.management=Management
This resource bundle is only accessible for the navigation of the ~~organization.management.executive-board~~ group.
1 Portlet
1.1 classpath.resources
Portlets are independent application and they deliver their own resource files. You can find an example for the GadgetPortlet: .../WEB-INF/classes/locale/portlet/gadget/GadgetPortleten.properties > http:--fisheye.exoplatform.org-browse-projects-portal-trunk-portlet-dashboard-src-main-webapp-WEB-INF-classes-locale-portlet-gadget-GadgetPortleten.properties?r=24413
All portlet resources are located in the locale/portlet subfolder. The ResourceBundleService parameter classpath.resources defines exactly this subfolder. Doing so the resource file that are in ~~locale/portlet~~ will never be stored in the JCR and reloaded at each start of the application server.
<values-param> <name>classpath.resources</name> <description>The resources that start with the following package name should be loaded from file system</description> <value>locale.portlet</value> </values-param>
Let's suppose you want to add a Spanish translation to the GadgetPortlet.
Create the file in:
In portlet.xml, add Spanish as a supported-locale, the resource-bundle is already declared and is the same for all languages : {code:xml} <supported-locale>en</supported-locale> <supported-locale>es</supported-locale> <resource-bundle>locale.portlet.gadget.GadgetPortlet</resource-bundle> {code}
1.1 Standard Portlet Resource Keys There are three standard keys defined : Title, Short Title and Keywords. Keywords contain a comma-separated list of keywords.
javax.portlet.title=Breadcrumbs Portlet javax.portlet.short-title=Breadcrumbs javax.portlet.keywords=Breadcrumbs, Breadcrumb
Whenever you want to display a property in the user language you use its key. Using the below access method the translation is returned in the preferred language of the current http session:
WebuiRequestContext context = WebuiRequestContext.getCurrentInstance() ; ResourceBundle res = context.getApplicationResourceBundle() ; String translatedString = res.getString(key);
When an application needs to be translated, it is never obvious to find out the right key for a given translated property. When the portal is executed in debug mode it is possible to select among the available languages a special language called Magic locale.
This feature translates a key to the same key value. For instance, the translated value for the key "organization.title" is simply the value "organization.title". Selecting that language allows to use the portal and its applications with all the keys visible and it is easy to find out the correct key for a given label in the portal page.
Usually resource bundles are stored in property files however as property files are plain files it raise issues with the encoding of the file. The XML resource bundle format has been developped to provide an alternative to property files.
In order to be loaded by the portal at runtime (actually the resource bundle service), the name of the file must be the same as a property file but instead of ending with the .properties suffix, it ends with the .xml suffix. For instance AccountPortlet ar.xml instead of AccountPortlet ar.properties .
The XML format is very simple and has been developed based on the DRY (Don't Repeat Yourself) principle. Usually resource bundle keys are hierarchically defined and we can leverage the hierarchic nature of the XML for that purpose. Here is an example of turning a property file into an XML resource bundle file:
<STYLE type="text/css"> .code {width: 97%} </STYLE>
UIAccountForm.tab.label.AccountInputSet = ... UIAccountForm.tab.label.UIUserProfileInputSet = ... UIAccountForm.label.Profile = ... UIAccountForm.label.HomeInfo= ... UIAccountForm.label.BusinessInfo= ... UIAccountForm.label.password= ... UIAccountForm.label.Confirmpassword= ... UIAccountForm.label.email= ... UIAccountForm.action.Reset= ...
<?xml version="1.0" encoding="UTF-8"?> <bundle> <UIAccountForm> <tab> <label> <AccountInputSet>...</AccountInputSet> <UIUserProfileInputSet>...</UIUserProfileInputSet> </label> </tab> <label> <Profile>...</Profile> <HomeInfo>...</HomeInfo> <BusinessInfo>...</BusinessInfo> <password>...</password> <Confirmpassword>...</Confirmpassword> <email>...</email> </label> <action> <Reset>...</Reset> </action> </UIAccountForm> </bundle>
Indeed, the usual way of rendering a portal page is a static one where you need a template, usually a jsp page, for each layout (2 columns, 3 columns and so on). That makes you depend on the integrator or developers as for each new layout you will need to ask for a custom development.
GateIn, with its dynamic way that creates a tree of nested UI containers that contain portlets as shown in the picture below. Each container is responsible for rendering its children. In the picture, the main container renders its children in several rows while the nested container displays them as columns.
Furthermore, by manipulating the tree using the WYSIWYG editor, it allows you to create new containers, define how they will render their children, add new portlets.
As most portal use the static layout mechanism, they can only drag portlets from one static location, let's say a column, to another one.
With GateIn Portal, it is possible to also drag the UI containers and the portlets and drop them in containers that are deeper or upper in the Portal component tree. This feature is unique and not just a tool!
With this innovative concept of dynamic layout, you can easily create portal pages with complex layout.
This kind of communication is made to allow applications within a page to exchange data. This library is made for broadcasting messages on topic. This is basically based on 3 functions : subscribe, publish and unsubscribe.
When you subscribe to a topic, you receive all the subtopic message. for example, if I subscribe to "/GateIn/application", and an application send a message on "/GateIn/application/map", i will receive it, but if another application send a message on "/GateIn", i will not receive it.
It contains all the events generated by the platform.
When a message is sent on this topic, a popup message appears on the top right of the screen.
Send a message on this channel to change (and to be notified) the title of the portal.
Receive a message when a page is loaded.
Receive a message when a page is unloaded.
Receive a message when an application is loaded in the page.
Receive a message when an application is unloaded in the page.
The inter application communication http://fisheye.exoplatform.org/projects/browse/projects/portal/trunk/web/GateInResources/src/main/webapp/javascript/GateIn/core/Topic.js
subscribe is used to subscribe a callback to a topic *Parameters:* * topic is the topic that will be listened * obj is the context object * funcName is the name of the function of obj to call when a message is received on the topic funcName have to be a function that take an Object in parameter. the event received have this format: {code:javascript} { senderId:senderId, message:message, topic: topic }
publish is used to publish an event to the other subscribers to the given channels *Parameters:* * senderId is a string that identify the sender * topic is the topic that the message will be published * message is the message that's going to be delivered to the subscribers to the topic
unsubscribe is used to unsubscribe a callback to a topic
In this article, you will learn how to :
The service is defined by the class : org.exoplatform.upload.UploadService;
You can configure it with the following xml code :
<component> <type>org.exoplatform.upload.UploadService</type> <init-params> <value-param> <name>upload.limit.size</name> <description>Maximum size of the file to upload in MB</description> <value>10</value> </value-param> </init-params> </component>
As you can see, you can configure a default upload size limit for the service. The value unit is in MegaBytes. This limit will be used by default by all applications if no specific limit is set. You will see in the next chapter how to set a different limit for your application.
If you set the value at 0, the upload size will be unlimited.
To use the component, you must create an object of type org.exoplatform.webui.form.UIFormUploadInput, using one of the two available constructors :
public UIFormUploadInput(String name, String bindingExpression)
or:
public UIFormUploadInput(String name, String bindingExpression, int limit)
Here is an example using the second form : {code} PortletRequestContext pcontext = (PortletRequestContext)WebuiRequestContext.getCurrentInstance(); PortletPreferences portletPref = pcontext.getRequest().getPreferences(); int limitMB = Integer.parseInt(portletPref.getValue("uploadFileSizeLimitMB", "").trim()); UIFormUploadInput uiInput = new UIFormUploadInput("upload", "upload", limitMB) ;
To get the limit from the xml configuration, you can add this piece of code in the files portlet.xml or portlet-preferences.xml : {code:xml} <preference> <name>uploadFileSizeLimitMB</name> <value>30</value> <read-only>false</read-only> </preference>
Again, a 0 value means unlimited upload size, and the value unit is set in MegaBytes.
To get the uploaded data use the ~~getUploadDataAsStream()~~ method: {code} UIFormUploadInput input = (UIFormUploadInput)uiForm.getUIInput("upload"); InputStream inputStream = input.getUploadDataAsStream(); ... jcrData.setValue(inputStream) ; {code}
1 Clean the uploaded file
The upload service stores a temporary file on the filesystem during the process. When the upload is finished, you must clean the service in order to :
To do that, use the ~~removeUpload()~~ method defined in the upload service, like this :
UploadService uploadService = uiForm.getApplicationComponent(UploadService.class) ; UIFormUploadInput uiChild = uiForm.getChild(UIFormUploadInput.class) ; uploadService.removeUpload(uiChild.getUploadId()) ;
In this article, you will learn:
To generate script to make an asynchronous ajax-call, we use uicomponent.doAsync() method instead of uicomponent.event() method.
Here is an example:
<a href="<%=uicomponent.doAsync(action, beanId, params)%>" alt="">Asynchronous</a>
Method doAsync() automatically adds a parameter into parameters list. Parameter asyncparam = new Parameter(AJAXASYNC,"true"); (AJAXASYNC == "ajaxasync")
After all, its call method event() to generate script that make Ajax Request. This request is asynchronous and ajax-loading mask will not displayed.
Note:
1. You still also make an asynchronous request by using method uicomponent.event(). By this way, you must add asyncparam manually.
2. GUI is blocked so that user can do only one action at a time (Request seems to be synchronous). But in fact ajax request always be asynchronous. See Synchronous issue section.
Almost web browser such as (IE, Chrome, Safari .. ) told that ajax request may used in two modes: Synchronous / Asynchronous with boolean value of bAsyn parameter. View reference.
var bAsync = false; // Synchronous
request.open(instance.method, instance.url, bAsync);
But Mozilla say no. They doesn't support synchronous request. var bAsync = false; // Synchronous
request.open(instance.method, instance.url, bAsync); // Firefox will not execute
So we decide to set bAsync always true (Ajax request always be asynchronous).
// Asynchronous request
request.open(instance.method, instance.url, true);
It is cause that Ajax Request always be asynchronous.
To retrieve the logged in user you can do as follows :
// Alternative context: WebuiRequestContext context = WebuiRequestContext.getCurrentInstance() ; PortalRequestContext context = PortalRequestContext.getCurrentInstance() ; // Get the id of the user logged String userId = context.getRemoteUser(); // Request the information from OrganizationService: OrganizationService orgService = getApplicationComponent(OrganizationService.class) ; if(userId!images/= null) { User user = orgService.getUserHandler().findUserByName(userId) ; if (user!images/= null) { String firstName = user.getFirstName(); String lastName = user.getLastName(); String email = user.getEmail(); } }
Alternatives for retrieving the Organization Service
WebUI is the name of GateIn's own webframework. GateIn Portal is built with it and also many applications available in the GateIn platform suites. In its concepts, the WebUI framework is similar to JSF as it is a component tree based framework. The key aspects of WebUI are :
It is very easy to create and manage Ajax calls in our framework. Just a few lines to write in your template file and your java class. For simple Ajax update of a component, you don't even have to write any line of JavaScript.
Our portlets can use specific <code>ActionListener</code>s to receive and process Ajax calls. To do that, you must create an inner static class named following this convention : action name followed by ActionListener
Example : <code>ParentClass</code> is the class in which you are writing.
static public class SaveActionListener extends EventListener<ParentClass>
Don't forget to declare this listener in the configuration of your portlet, with this :
listeners = ParentClass.SaveActionListener.class{code}
in the correct annotation <code>ComponentConfig</code>, <code>EventConfig</code>, etc.,
For example, the configuration of <code><strong>UIAccountForm</strong></code>:
... @ComponentConfig( lifecycle = UIFormLifecycle.class, template = "system:/groovy/webui/form/UIFormTabPane.gtmpl", initParams = { @ParamConfig( name = "AccountTemplateConfigOption", value = "app:/WEB-INF/conf/uiconf/account/webui/component/model/AccountTemplateConfigOption.groovy" ), @ParamConfig( name = "help.UIAccountFormQuickHelp", value = "app:/WEB-INF/conf/uiconf/account/webui/component/model/UIAccountFormQuickHelp.xhtml" ) }, events = { @EventConfig(listeners = UIAccountForm.SaveActionListener.class ), @EventConfig(listeners = UIAccountForm.ResetActionListener.class, phase = Phase.DECODE), @EventConfig(listeners = UIAccountForm.SearchUserActionListener.class, phase = Phase.DECODE) } ) ...
Inside this class, you will have to create an <code>execute</code> method like this :
public void execute(Event<ParentClass> event) throws Exception
This method is called every time the listener gets an event from the client, hence you can process this event in it, using the {style:type=span|font-family=courier new,courier}event {style}attibute. Use it to get parameters from a form in your client, to modify the status of your portlet, etc.,
Possible ways to use the event attribute : {code}
If your action has to update an element on your client's interface, you must call addUIComponentToUpdateByAjax() at the end of the <code>execute</code> method:
event.getRequestContext().addUIComponentToUpdateByAjax(uicomponent) ;
The target component must be provided as parameter (the component that will be updated). We will come back on this later.
You must create one inner action listener class for each Ajax call you want to handle on this portlet. All these classes must be declared in the configuration annotations of the main class, otherwise you will get an error.
It's done, your portlet is ready to accept Ajax calls from your client.
Your server being configured to receive Ajax calls, you must configure the client interface to make these calls.
In the groovy template file associated with your portlet class (<code>ParentClass</code> here), you just have to add :
uicomponent.event("YourOperation"); // YourOperation is the same as in the ActionListener class (Save in our example above)
in a groovy code block. The event function will create an url starting with {style:type=span|font-family=courier new,courier}javascript:{style} so you have to make sure this code can be executed in your environment.
If your operation must update the content of a component, you have to make sure that the target component is well rendered. Basically, just type this :
uicomponent.renderChild(UITargetComponent.class) ;
in a groovy code block. <code>UITargetComponent</code> is the class of the component that will be updated when
event.getRequestContext().addUIComponentToUpdateByAjax(uicomponent) ;
is called. Hence, <code>uicomponent</code> must be of type <code>UITargetComponent</code>. If this component is not rendered by default, when the portlet loads, don't forget to set its <code>rendered</code> attribute to false :
mycomponent.setRendered(false);
in the constructor of your portlet.
All the javascript is managed by the file GateIn.portal.PortalHttpRequest.js in the portal project.
In this class, you will find 4 functions/classes (detailed below):
* PortletResponse * PortalResponse * AjaxRequest * HttpResponseHandler
and 6 functions : {code}
This class doesn't contain any method. On creation, it just gets the response elements from the xml returned by Ajax, and store them in the corresponding attributes : {code}
You can access these attributes just by calling them from your <code>PortletResponse</code> instance.
Contains an array of <code>PortletResponse</code>s (<code>portletResponses</code>) and two other attributes : {code}
By far the most important class of this file. Wraps the XMLHttpRequest object with some functions and attributes, to make it easier to use. You can find the complete documentation here : http://www.ajaxtoolbox.com/request/documentation.php
This class provides methods to handle the Ajax response. {code}
{PortalResponse} | |--->{PortletResponse} | |--->{PortletResponse} | |-->{portletId} | |-->{portletTitle} | |-->{portletMode} | |-->{portletState} | | | |-->{Data} | | | | | |--->{BlockToUpdate} | | | |-->{blockId} | | | |-->{data} | | | | | |--->{BlockToUpdate} | |--->{Script} | |--->{Data} | | | |--->{BlockToUpdate} | | |-->{blockId} | | |-->{data} | | | |--->{BlockToUpdate} |--->{Script}
If you have several actions that need to appear in a popup, you can use this technique to manage the different popup windows easily:
addChild(UIPopupAction.class, null, null);
and render it in your template file:
uicomponent.renderChild(UIPopupAction.class) ;
By default, this just create an empty container (popup) that will receive the new content by Ajax.
UIPopupAction uiPopupAction = uiMainPortlet.getChild(UIPopupAction.class) ; uiPopupAction.activate(UIReferencesList.class, 600) ;
UIReferenceList is the component that will appear in the popup. You don't have to declare it in the main portlet class. The activate method takes care of the creation of the component, and its rendering in the popup window. See the javadoc for more information on this class.
event.getRequestContext().addUIComponentToUpdateByAjax(uiPopupAction) ;
For each component that you want that component to appear in a popup window, add a action listener class and repeat the steps above with the appropriate component type.
This article gives a glance at the Groovy language, and explains how to configure the portlet and and the groovy template.
It's recommended to read also AJAX in GateIn Framework in order to understand better the communication between the Groovy Template and the portlet.
The structure of a template is very easy :
The HTML code in the template doesn't have to contain the <code>html</code>, or <code>body</code> tags. Hence, you can use a groovy template for a component that will be rendered in another component.
Example : UIPortalApplication.gtmpl template (/GateInProjects/portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/workspace/)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <% import org.exoplatform.webui.core.UIComponent; def currentPage = uicomponent.getCurrentPage(); ... %> ... <div class="$uicomponent.skin" id="UIPortalApplication"> <%uicomponent.renderChildren();%>
Groovy is a scripting language for Java. Here are a few examples on how to use it, but you can find more information in the full documentation.
This language looks like Java a lot, so it's very easy to use. Examples :
Variables definition : {code} int min = 1; def totalPage = uicomponent.getAvailablePage(); String name = "uiPortlet"; categories = uicomponent.getItemCategories(); String ??? columns = uicomponent.getColumns(); {code} Other expressions : {code} for(category in categories) { ... } // easy to use for loop for(i in min..max) { ... } // min and max are int variables println "</div>" ; println """ <div class="Item"> <div class="OverflowContainer"> """; <%=uicomponent.getToolbarStyle();%> // <%= to avoid a call of println method import org.exoplatform.portal.config.model.PageNode; {code}
The configuration of a portlet is partly made with {style:type=span|font-family=courier new,courier}ComponentConfig {style}annotations (others are ComponentConfigs, EventConfig, etc). One of the parameters of this annotation is called {style:type=span|font-family=courier new,courier}template{style}, where you can define the path to the template file associated with this portlet.
To specify this parameter to your portlet, just add this statement to your configuration annotation, for example in /GateInProjects/portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/ you find UIApplicationForm.java:
@ComponentConfig( lifecycle = UIFormLifecycle.class, template = "system:/groovy/webui/form/UIFormWithTitle.gtmpl", events = { @EventConfig(listeners = UIApplicationForm.SaveActionListener.class), @EventConfig(phase = Phase.DECODE, listeners = UIApplicationForm.CancelActionListener.class) } )
You see that the path is in the namespace called "system", "system" is a reference to the portal webapp. In this webapp you find some reusable groovy templates, just open the folder /GateInProjects/portal/trunk/web/portal/src/main/webapp/groovy/webui/form/ to see them.
As you want to create your own template, create a groovy file in your webbapp and refer to it. Please use the namespace "app" for refering to the same webapp as your component. GateIn always puts the component templates in a folder like "/webapp/groovy/yourportletname/webui/component".
template = "app:/groovy/your_portlet_name/webui/component/your_component.gtmpl"
You can now edit your template file.
As we said before, the template file is composed of HTML code and groovy code blocks. There are a few things more that you need to know to fully link your portlet with your template.
If your template defines the UI of a component, you have an access to this component instance (the java object) using the variable {style:type=span|font-family=courier new,courier}uicomponent{style}. This should be the case almost all the time, but we recommend that you check that your java class inherits from UIComponent before you use this variable. With this {style:type=span|font-family=courier new,courier}uicomponent {style}variable, you can access all the attributes and functions of your component, to use them in your template. Example : UIPageIterator.gtmpl {code} <% def currentPage = uicomponent.getCurrentPage(); %> ... <a href="<%=uicomponent.event("ShowPage","$currentPage")%>" class="Icon LastTopPageIcon"><span></span></a> {code}
This example shows that {style:type=span|font-family=courier new,courier}uicomponent {style}can be used to make Ajax calls, thanks to the {style:type=span|font-family=courier new,courier}event {style}method. See AJAX in GateIn Framework for more details.
Another variable that you can use is {style:type=span|font-family=courier new,courier}{style}ctx. It gives access to the context in which the template is processed. Hence, you can get some elements like the request, the Javscript manager, or the resource resolver (ctx.appRes). Examples : {code} <% def rcontext = ctx.getRequestContext() ; rcontext.getJavascriptManager().importJavascript('GateIn.webui.UIPopupWindow');ctx.appRes(popupId + ".title."+ title); %> {code}
If you use your template to define the user interface of a component that includes a form, you can access the instance of UIForm in a variable named {style:type=span|font-family=courier new,courier}uiform{style}. The UIForm class provides the methods, {style:type=span|font-family=courier new,courier}begin(){style} and {style:type=span|font-family=courier new,courier}end(){style}, that write the HTML tags of the form. Your form class must inherit from UIForm
, in this class you add the input elements (fields, checkboxes, lists) which you wish to use in your form. In your groovy template you can render your input elements using {style:type=span|font-family=courier new,courier}{style}{code}{ uiform.renderField(field) }{code}
This example is based on the testPortlet in portal/trunk/portlet/test.
On Eclipse, create a new Java Project, and create this folder tree :
<pre> src | main | |- java | |- resources | |- webapp </pre>
Create the pom.xml, at root level of the project, like this :
<project> <parent> <groupId>org.exoplatform.portal</groupId> <artifactId>config</artifactId> <version>trunk</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>exo.portal.portlet.testRomain</artifactId> <packaging>war</packaging> <version>${org.exoplatform.portal.version}</version> <name>exo-portal.portlets.test Romain</name> <url>http://www.exoplatform.org</url> <description>Romain Test Portlet</description> <dependencies> <dependency> <groupId>org.exoplatform.portal</groupId> <artifactId>exo.portal.webui.portal</artifactId> <version>${org.exoplatform.portal.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.exoplatform.portal</groupId> <artifactId>exo.portal.webui.GateIn</artifactId> <version>${org.exoplatform.portal.version}</version> <scope>provided</scope> </dependency> </dependencies> <build> <finalName>testRomain</finalName> </build> </project>
1.1 UITestRomainPortlet.java
In java/testRomain/portlet/component/, we will create the UITestRomainPortlet.java file of the portlet :
package testRomain.portlet.component; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.core.lifecycle.UIApplicationLifecycle; import org.exoplatform.webui.core.UIPortletApplication; //this part is configuration of the portlet, we set the path to the template groovy. @ComponentConfig( lifecycle = UIApplicationLifecycle.class, template = "app:/groovy/testRomain/portlet/UITestRomainPortlet.gtmpl" ) public class UITestRomainPortlet extends UIPortletApplication { public UITestRomainPortlet() throws Exception { } }
In src/main/resources/tomcat/, create a testRomain.xml file : {code} <Context path="/test" docBase="../../../GateInProjects/portal/trunk/portlet/testPortletRomain/src/main/webapp" debug="0" reloadable="true" /> {code}
docBase must be set to webapp path of the portlet when you are in the tomcat bin directory.
In src/main/webapp, create the groovy template for the portlet. The path to this file must match the path you set in the java file, in our case : groovy/testRomain/portlet/UITestRomainPortlet.gtmpl
<div id="<%=uicomponent.getId();%>"> HelloWorld!images/!! </div>
Create the folder skin in src/main/webapp. We don't fill it now, but in this folder, you can put css stylesheet and images.
Create the folder WEB-INF/classes/locale in src/main/webapp. We don't fill it now, but in this folder, you can put language properties files. See Internationalization Configuration.
Create the file configuration.xml in WEB-INF/conf/portlet/testPortletRomain/. Content of tag <ui-component-root> must match your package organization.
<webui-configuration> <application> <ui-component-root>testRomain.portlet.component.UITestRomainPortlet</ui-component-root> <state-manager>org.exoplatform.webui.application.portlet.ParentAppStateManager</state-manager> </application> </webui-configuration>
1.1 portlet.xml
In WEB-INF, create file portlet.xml :
<?xml version="1.0" encoding="UTF-8"?> <portlet-app version="1.0" xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"> <portlet> <description xml:lang="EN">Test Portlet Romain</description> <portlet-name>TestRomain</portlet-name> <display-name xml:lang="EN">Test Portlet Romain</display-name> <portlet-class>org.exoplatform.webui.application.portlet.PortletApplicationController</portlet-class> <init-param> <name>webui.configuration</name> <!-- must match the path to configuration file --> <value>/WEB-INF/conf/portlet/testPortletRomain/configuration.xml</value> </init-param> <expiration-cache>0</expiration-cache> <supports> <mime-type>text/html</mime-type> <portlet-mode>help</portlet-mode> </supports> <supported-locale>en</supported-locale> <resource-bundle>locale.testRomainPortlet</resource-bundle> <portlet-info> <title>TestPortletRomain</title> <short-title>TestPortlet</short-title> <keywords>test</keywords> </portlet-info> </portlet> </portlet-app>
In WEB-INF, create file web.xml :
<?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <!-If define the Portlet Application name MUST end with .par-> <display-name>test</display-name> <description> This application is a portlet. It can not be used outside a portal. This web.xml file is mandatory in each .par archive file. </description> <listener> <listener-class>org.exoplatform.services.portletcontainer.impl.servlet.PortletApplicationListener</listener-class> </listener> <servlet> <servlet-name>PortletWrapper</servlet-name> <servlet-class>org.exoplatform.services.portletcontainer.impl.servlet.ServletWrapper</servlet-class> </servlet> <servlet-mapping> <servlet-name>PortletWrapper</servlet-name> <url-pattern>/PortletWrapper</url-pattern> </servlet-mapping> </web-app>
1 Use the Portlet
Compile your portlet, deploy it, and add it to the portal.
Now, we will add a button in the portlet. This button will open a popup with a message inside.
1.1 Add a button In the groovy template, add this code :
<div class="UIAction"> <div class="ActionContainer"> <div class="ActionButton"> <div class="LightBlueStyle"> <div class="ButtonLeft"> <div class="ButtonRight"> <div class="ButtonMiddle"> <a href="<%=uicomponent.event("OpenPopup", "")%>">Open Popup</a> </div> </div> </div> </div> </div> </div> </div>
1.1 Add a listener In the java file, in @ComponentConfig, add this code :
events = { @EventConfig(listeners = UITestRomainPortlet.OpenPopupActionListener.class) }
Remark : XXXActionLister.class XXX must match the name you set for the event in the groovy.
static public class OpenPopupActionListener extends EventListener<UITestRomainPortlet> { public void execute(Event<UITestRomainPortlet> event) throws Exception { System.out.println("HelloWorld"); } }
1.1 Redeploy
Redeploy the portlet and click on the button. You will see "HelloWorld" in your console. If you don't change in the portlet, try to redeploy and reboot the tomcat server.
1 Add a "HelloWorld" popup
Now, we will add a popup which say "HelloWorld" when you click on the button.
<div id="<%=uicomponent.getId();%>"> HelloWorld in a popup!images/!! </div>
import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.core.UIComponent; import org.exoplatform.webui.core.lifecycle.UIApplicationLifecycle;
@ComponentConfig( lifecycle = UIApplicationLifecycle.class, template = "app:/groovy/testRomain/portlet/UIHelloWorldPopupContent.gtmpl" )
public class UIHelloWorldPopupContent extends UIComponent
public UIHelloWorldPopupContent() throws Exception { }{ } {code}
{UIHelloWorldPopupContent popupContent = createUIComponent(UIHelloWorldPopupContent.class, null, null); popup.setUIComponent(popupContent); popup.setRendered(false); } {code}
At the beginning, we set the popup not visible. As you see, we add a children to the Portlet. So, if we want to see the content of it, we must add this in UITestPortletRomain.gtmpl :
<% uicomponent.renderChildren(); %>
This makes the portlet generate the content of all child components.
When user clicks on the button, the popup is shown.
The goal of this chapter is not to talk about the Portlet API specification lifecycle but more about GateIn UI framework to easily develop portlets.
The web framework used here has been completely developed by GateIn and perfectly suits the portal environment, it even allows to send events from the portlet UIComponents to the Portal ones.
Of course using the GateIn web framework to build portlets is not necessary and any other web framework that supports portlet environment can be used. But all GateIn portlets that are part of GateIn products are developed using that framework and we provide several UI components that can be used in different abstracted contexts such as the portal itself or some portlets.
This chapter is not a tutorial on how to write portlets, it will go in the details of the code implementation and logic; hence it is intended for advanced developers. It is also advised to read the Portal Lifecycle article before as the that article explains concepts that are similar and top hierarchy classes that are shared.
The main entry point for configuring a portlet is in the portlet.xml file located in the portlet application WAR. Every portlet that shall be built using the GateIn web framework must reference the PortletApplicationController . The portlet configuration such as the root component is defined in a configuration.xml file. The path to this configuration.xml file is defined in the init-param "webui.configuration" of porlet.xml.
<portlet> <description xml:lang="EN">Content Portlet</description> <portlet-name>ContentPortlet</portlet-name> <display-name xml:lang="EN">Content Portlet</display-name> <portlet-class>org.exoplatform.webui.application.portlet.PortletApplicationController</portlet-class> <init-param> <name>webui.configuration</name> <value>/WEB-INF/conf/portlet/content/ContentPortlet/webui/configuration.xml</value> </init-param>
The structure of the configuration.xml file is exactly the same as the webui-configuration.xmlwhich we have already introduced in the Portal Lifecycle article. In the case of the content portlet it looks like:
<webui-configuration> <application> <ui-component-root>org.exoplatform.content.webui.component.UIContentPortlet</ui-component-root> <state-manager>org.exoplatform.webui.application.portlet.ParentAppStateManager</state-manager> </application> </webui-configuration>
The PortletApplicationController class extends the GenericPortlet class defined in the Portlet API specification.
All methods like processAction() or render() are delegated to the PortletApplication. The creation and caching inside the WebController object is described in the following method:
/** * try to obtain the PortletApplication from the WebAppController. * * If it does not exist a new PortletApplication object is created, init and cached in the * controller */ private PortletApplication getPortletApplication() throws Exception { PortalContainer container = PortalContainer.getInstance() ; WebAppController controller = (WebAppController)container.getComponentInstanceOfType(WebAppController.class) ; PortletApplication application = controller.getApplication(applicationId_) ; if(application == null) { application = new PortletApplication(getPortletConfig()) ; application.onInit() ; controller.addApplication(application) ; } return application ; }
When a portlet, that is deployed in GateIn Portal, is using the GateIn web framework then all methods calls go through the PortletApplication object which extends the WebuiApplication.
The code of the method in PortletApplication is described here. The business logic is shown in the javadoc:
/** * The processAction() method is the one modelled according to the Portlet API specification * * The process is quite simple and here are te different steps done in the method: * * 1) The current instance of the WebuiRequestContext (stored in a ThreadLocal in the class) is referenced * 2) A new request context of type PortletRequestContext (which extends the class WebuiRequestContext) is * created as a child of the current context instance * 3) The new context is place inside the ThreadLocal and hence overides its parent one there, * only for the portlet request lifeciclye * 4) The method onStartRequest() is called in all the ApplicationLifecycle objects referenced in the webui * configuration XML file * 5) The StateManager object (in case of portlet it is an object of type ParentAppStateManager) is used to get the RootComponent * also referenced in the XML configuration file * 6) The methods processDecode(UIApplication, WebuiRequestContext) and processAction(UIApplication, WebuiRequestContext) * are then called * 7) Finally, a flag, to tell that the processAction phase was done, in the context is set to true and the parent * context is restored in the Threadlocal */ public void processAction(ActionRequest req, ActionResponse res) throws Exception { WebuiRequestContext parentAppRequestContext = WebuiRequestContext.getCurrentInstance() ; PortletRequestContext context = createRequestContext(req, res, parentAppRequestContext) ; WebuiRequestContext.setCurrentInstance(context) ; try { for(ApplicationLifecycle lifecycle : getApplicationLifecycle()) { lifecycle.onStartRequest(this, context) ; } UIApplication uiApp = getStateManager().restoreUIRootComponent(context) ; context.setUIApplication(uiApp) ; processDecode(uiApp, context) ; if(!images/context.isResponseComplete() &&!images/ context.getProcessRender()) { processAction(uiApp, context) ; } } finally { context.setProcessAction(true) ; WebuiRequestContext.setCurrentInstance(parentAppRequestContext) ; } }
The PortletRequestContext extends WebuiRequestContext class and acts as a wrapper on top of all the portlet request information:
/** * In this method we try to get the PortletRequestContext object from the attribute map of the parent * WebuiRequestContext. * * If it is not cached then we create a new instance, if it is cached then we init it with the correct * writer, request and response objects * * We finally cache it in the parent attribute map * */ private PortletRequestContext createRequestContext(PortletRequest req, PortletResponse res, WebuiRequestContext parentAppRequestContext) throws IOException { String attributeName = getApplicationId() + "$PortletRequest" ; PortletRequestContext context = (PortletRequestContext) parentAppRequestContext.getAttribute(attributeName) ; Writer w = null ; if(res instanceof RenderResponse){ RenderResponse renderRes = (RenderResponse)res; renderRes.setContentType("text/html; charset=UTF-8"); w = renderRes.getWriter() ; } if(context!images/= null) { context.init(w, req, res) ; } else { context = new PortletRequestContext(this, w, req, res) ; parentAppRequestContext.setAttribute(attributeName, context) ; } context.setParentAppRequestContext(parentAppRequestContext) ; return context; }
In the PortletApplication, the line
public class ParentAppStateManager extends StateManager { /** * This method simply delegate the call to the same method of the parent WebuiRequestContext */ @SuppressWarnings("unchecked") public UIApplication restoreUIRootComponent(WebuiRequestContext context) throws Exception { WebuiRequestContext pcontext = (WebuiRequestContext) context.getParentAppRequestContext() ; return pcontext.getStateManager().restoreUIRootComponent(context) ; }
Hence this is the PortalStateManager that will also handle the extraction of the root component.
public UIApplication restoreUIRootComponent(WebuiRequestContext context) throws Exception { context.setStateManager(this) ; WebuiApplication app = (WebuiApplication)context.getApplication() ; /* * If the request context is of type PortletRequestContext, we extract the parent context which will * allow to get access to the PortalApplicationState object thanks to the session id used as the key for the * syncronised Map uiApplications */ if(context instanceof PortletRequestContext) { WebuiRequestContext preqContext = (WebuiRequestContext) context.getParentAppRequestContext() ; PortalApplicationState state = uiApplications.get(preqContext.getSessionId()) ; PortletRequestContext pcontext = (PortletRequestContext) context ; String key = pcontext.getApplication().getApplicationId() ; UIApplication uiApplication = state.get(key) ; if(uiApplication!images/= null) return uiApplication; synchronized(uiApplications) { ConfigurationManager cmanager = app.getConfigurationManager() ; String uirootClass = cmanager.getApplication().getUIRootComponent() ; Class type = Thread.currentThread().getContextClassLoader().loadClass(uirootClass) ; uiApplication = (UIApplication)app.createUIComponent(type, null, null, context) ; state.put(key, uiApplication) ; } return uiApplication ; }
The render method business logic is quite similar to processAction().
/** * The render method business logic is quite similar to the processAction() one. * * 1) A PortletRequestContext object is created (or extracted from the cache if it already exists) * and initialized * 2) The PortletRequestContext replaces the parent one in the WebuiRequestContext ThreadLocal object * 3) If the portal has already called the portlet processAction() then the call to all onStartRequest of * the ApplicationLifecycle has already been made, otherwise we call them * 4) The ParentStateManager is also used to get the UIApplication, as we have seen it delegates the call * to the PortalStateManager which caches the UI component root associated with the current application * 5) the processRender() method of the UIPortletApplucaton is called * 6) Finally, the method onEndRequest() is called on every ApplicationLifecycle referenced in the portlet * configuration XML file and the parent WebuiRequestContext is restored * */ public void render(RenderRequest req, RenderResponse res) throws Exception { WebuiRequestContext parentAppRequestContext = WebuiRequestContext.getCurrentInstance() ; PortletRequestContext context = createRequestContext(req, res, parentAppRequestContext) ; WebuiRequestContext.setCurrentInstance(context) ; try { if(!context.hasProcessAction()) { for(ApplicationLifecycle lifecycle : getApplicationLifecycle()) { lifecycle.onStartRequest(this, context) ; } } UIApplication uiApp = getStateManager().restoreUIRootComponent(context) ; context.setUIApplication(uiApp) ; if(!context.isResponseComplete()) { UIPortletApplication uiPortletApp = (UIPortletApplication)uiApp; uiPortletApp.processRender(this, context) ; } uiApp.setLastAccessApplication(System.currentTimeMillis()) ; } finally { try { for(ApplicationLifecycle lifecycle : getApplicationLifecycle()) { lifecycle.onEndRequest(this, context) ; } } catch (Exception exception){ log.error("Error while trying to call onEndRequest of the portlet ApplicationLifecycle", exception); } WebuiRequestContext.setCurrentInstance(parentAppRequestContext) ; } }
The processRender() call made on the UIPortletApplication is shown now:
/** * The default processRender for an UIPortletApplication handles two cases: * * A. Ajax is used * ~UWC_TOKEN_START~1255420331108~UWC_TOKEN_END~ * If Ajax is used and that the entire portal should not be re rendered, then an AJAX fragment is * generated with information such as the portlet id, the portlet title, the portlet modes, the window * states as well as the HTML for the block to render * * B. A full render is made * ---- * a simple call to the method super.processRender(context) which will delegate the call to all the * Lifecycle components * */ public void processRender(WebuiApplication app, WebuiRequestContext context) throws Exception { WebuiRequestContext pContext = (WebuiRequestContext)context.getParentAppRequestContext(); if(context.useAjax() &&!images/pContext.getFullRender()) { Writer w = context.getWriter() ; Set<UIComponent> list = context.getUIComponentToUpdateByAjax() ; // if(list == null) list = app.getDefaultUIComponentToUpdateByAjax(context) ; if(list!images/= null) { if(getUIPopupMessages().hasMessage()) context.addUIComponentToUpdateByAjax(getUIPopupMessages()) ; for(UIComponent uicomponent : list) { renderBlockToUpdate(uicomponent, context, w) ; } return ; } } super.processRender(context) ; }
An gadget is a mini web application running on a platform and you can put it in a web page. This is a small application that helps users to do some private actions.
GateIn Portal supports some gadgets such as: Todo gadget, Calendar gadget, Calculator gadget, Weather Forecasts, RSS Reader gadget.
This is the reference to a remote gadget (stock one).
After referencing the gadget successfully, then import it into the local repository.
Edit it from the Web the imported Gadget to modify it:
Edit it from your IDE thanks to the WebDAV protocol:
View it from the Dashboard when you drag and drop the Gadget from listing to the dashboard.
GateIn recommend you to setup 2 different virtual hosts because it's the basis of the security model of gadgets. Having the gadget running on a different domain than the container (the website that 'contains' the app), the gadget can't read / modify / do anything nasty to GateIn Portal (like adding spam messages, stealing your cookies, whatever).
For example you can server the portal from http://www.sample.com and the gadgets from http://www.samplemodules.com
To do this, we need to configure a parameter with the name is gadgets.hostName , the value is the path/to/gadgetServer in GadgetRegisteryService service like following : {code:xml} <component> <key>org.exoplatform.application.gadget.GadgetRegistryService</key> <type>org.exoplatform.application.gadget.jcr.GadgetRegistryServiceImpl</type> <init-params> <value-param> <name>gadgets.hostName</name> <description>Gadget server url</description> <value>http://localhost:8080/GateInGadgetServer/gadgets/</value> </value-param> </init-params> </component> {code}
It's possible to have multiple rendering servers. That would help to balance the load across multiple servers.
If you still want to deploy it on the same server, make sure that it starts before anything that use the gadgets (for example the webapp GateInGadgets that use org.exoplatform.application.gadget.GadgetRegister)
1 Config 1.1 Security key A file key.txt has to be generated for every installation of GateIn to be secure. This file contains a secret key used to crypt the security token used for authenticating the user. in Tomcat this file is in nix command line will create an excellent key:
dd if=/dev/random bs=32 count=1 | openssl base64 > /tmp/key.txt
1.1 Gadget proxy and concat configuration These servers have to be on the same domain as the gadget server. you can configure it in {code}"link", "script", "embed", "img", "style"{, "expires": "86400", "proxy-url": "http://localhost:8080/GateInGadgetServer/gadgets/proxy?url=", "concat-url": "http://localhost:8080/GateInGadgetServer/gadgets/concat?" }{code}
1.1 Proxy if your server is behind a proxy and you want to allow external gadgets, you should configure the proxy of your JVM adding this code at the begining. {code}-Dhttp.proxyHost=proxyhostURL -Dhttp.proxyPort=proxyPortNumber -Dhttp.proxyUser=someUserName -Dhttp.proxyPassword=somePassword {code}
GateIn recommend you to setup 2 different virtual hosts because it's the basis of the security model of gadgets. Having the gadget running on a different domain than the container (the website that 'contains' the app), the gadget can't read / modify / do anything nasty to GateIn Portal (like adding spam messages, stealing your cookies, whatever).
For example you can server the portal from http://www.sample.com and the gadgets from http://www.samplemodules.com
It's possible to have multiple rendering servers. That would help to balance the load across multiple servers.
If you still want to deploy it on the same server, make sure that it starts before anything that use the gadgets (for example the webapp GateInGadgets that use org.exoplatform.application.gadget.GadgetRegister)
dd if=/dev/random bs=32 count=1 | openssl base64 > /tmp/key.txt
These servers have to be on the same domain as the gadget server. you can configure it in {code}"link", "script", "embed", "img", "style"{, "expires": "86400", "proxy-url": "http://localhost:8080/GateInGadgetServer/gadgets/proxy?url=", "concat-url": "http://localhost:8080/GateInGadgetServer/gadgets/concat?" }{code}
if your server is behind a proxy and you want to allow external gadgets, you should configure the proxy of your JVM adding this code at the begining. {code}-Dhttp.proxyHost=proxyhostURL -Dhttp.proxyPort=proxyPortNumber -Dhttp.proxyUser=someUserName -Dhttp.proxyPassword=somePassword {code}