Chiều nay: cấu tạo portlet, tạo Hello World Portlet
mất tập trung quá…
Packaging p.176
A portlet project is made up at a minimum of three components:
- Java Source
- Configuration files
- Client-side files (*.jsp, *.css, *.js, graphics, etc.)
These files are stored in a standard directory structure which looks like the following:
/PORTLET-NAME/
build.xml
/docroot/
icon.png
view.jsp
/css/
/js/
/WEB-INF/src/ (Java Source) //not created by default
liferay-display.xml
liferay-plugin-package.properties
liferay-portlet.xml
portlet.xml ()
web.xml
portlet.xml: là file quan trọng (vì sao quan trọng ?)
docroot/WEB-INF/portlet.xml
<portlet>
<portlet-name>my-greeting</portlet-name>
<display-name>My Greeting</display-name>
<portlet-class>com.liferay.util.bridges.mvc.MVCPortlet</portlet-class>
<init-param>
<name>view-jsp</name>
<value>/view.jsp</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
</supports>
<portlet-info>
<title>My Greeting</title>
<short-title>My Greeting</short-title>
<keywords>My Greeting</keywords>
</portlet-info>
<security-role-ref>
<role-name>administrator</role-name>
</security-role-ref>
<security-role-ref>
<role-name>guest</role-name>
</security-role-ref>
<security-role-ref>
<role-name>power-user</role-name>
</security-role-ref>
<security-role-ref>
<role-name>user</role-name>
</security-role-ref>
</portlet>
portlet-name
The portlet-name element contains the canonical name of the portlet. Each portlet name is unique within the portlet application. (This is also referred within Liferay Portal as the portlet id)
display-name
The display-name type contains a short name that is intended to be displayed by tools. It is used by display-name elements. The display name need not be unique.
portlet-class
The portlet-class element contains the fully qualified class name of the portlet.
init-param
The init-param element contains a name/value pair as an initialization param of the portlet.
expiration-cache
Expiration-cache defines expiration-based caching for this portlet. The parameter indicates the time in seconds after which the portlet output expires. -1 indicates that the output never expires.
supports
The supports element contains the supported mime-type. Supports also indicates the portlet modes a portlet supports for a specific content type. All portlets must support the view mode.
portlet-info
Portlet-info defines portlet information.
security-role-ref
The security-role-ref element contains the declaration of a security role reference in the code of the web application. Specifically in Liferay, the role-name references which role’s can access the portlet.
PLT.23.4 Directory Structure
A portlet application follows the same directory hierarchy structure as web applications.
In addition it must contain a /WEB-INF/portlet.xml deployment descriptor file.
Portlet classes, utility classes and other resources accessed through the portlet application classloader must reside within the /WEB-INF/classes directory or within a JAR file in the /WEB-INF/lib/ directory.
-In developing your own portlets you are free to use any framework you prefer,
such as Struts, Spring MVC, or JSF. For this portlet we will use the Liferay MVCPortlet
framework as it is simple, lightweight, and easy to understand.
framework? Struts, Spring MVC, JSF ?
Làm xong rồi, nhưng làm sao nó chạy được file class khi không có khai báo ???
Không có nhận xét nào:
Đăng nhận xét