客户又开口了,一个小系统非要用Liferay。钱在人家的口袋里,要想掏出来还真得满口答应。当然心里也愤愤的想,改天也花点小钱让别人替我摸索新技术,省得总是吃的比猫少、干的比牛多、睡得比狗晚、起得比鸡早。

安装过程还是比较顺利的,除了缺少xalan.jar。没关系从Eclipse里找到拷过来。运行bin\startup.bat,访问
http://localhost,很顺利的就跑起来了。管理员用户名是:test@liferay.com,密码是:test。

逛也逛够了,雄心勃勃的开始分析代码,谁知道这就是灾难的开始呢?根据以前对Portal的了解,Portlet是重中之重,从这里下手准没错。看着里面Calendar不错,就拿它来开刀。

1、在liferay\WEB-INF\portlet.xml中找找看,果然发现了Calendar这个portlet的定义。

    <portlet>
        
<portlet-name>8portlet-name>
        
<display-name>Calendardisplay-name>
        
<portlet-class>com.liferay.portlet.StrutsPortletportlet-class>
        
<init-param>
            
<name>view-actionname>
            
<value>/calendar/viewvalue>
        
init-param>
        
<expiration-cache>0expiration-cache>
        
<supports>
            
<mime-type>text/htmlmime-type>
        
supports>
        
<resource-bundle>com.liferay.portlet.StrutsResourceBundleresource-bundle>
        
<portlet-preferences>
            
<preference>
                
<name>event-typename>
                
<value>value>
            
preference>
        
portlet-preferences>
        
<security-role-ref>
            
<role-name>power-userrole-name>
        
security-role-ref>
        
<security-role-ref>
            
<role-name>userrole-name>
        
security-role-ref>
    
portlet>

2、慢着,为什么是StrutsPortlet而不是CalendarPortlet?这和我以前了解到的情况不符。和其他Portlet的定义相比较,这里也缺了edit-action的定义,究竟怎么回事?虽然有所疑问,好歹structs我是知道的,打开liferay\WEB-INF\structs-config.xml看看究竟。搜索一下/calendar/view,发现定义如下:

        <action path="/calendar/view" forward="portlet.calendar.view" />

3、这个好像是在tiles里定义的,那么打开liferay\WEB-INF\tiles-defs.xml看看。搜索portlet.calendar.view,嗯找到了。

    <definition name="portlet.calendar.view" extends="portlet.calendar">
        
<put name="portlet_content" value="/portlet/calendar/view.jsp" />
    
definition>

4、终于发现我认识的东西了,是一个jsp文件。顾不上看看portlet.calendar对应的定义,先打开相应的jsp看看到底怎么写的。具体位置在liferay\html\portlet\calendar\view.jsp。不看不知道,一看吓一跳。在这个jsp文件中直接或间接include了四个jsp页面:
liferay\html\portlet\common\init.jsp:这个文件是用来
liferay\html\portlet\common\init-ext.jsp
liferay\html\portlet\calendar\init.jsp
liferay\html\portlet\common\calendar.jsp