jetspeed開發實戰
這里假設monsys為web服務的名稱,其路徑在webapps/下面
1,jetspeed的圖片處理圖片默認放在monsys/images下面,
調用方法:$clink.setURI("images/test.jpg")
2,javascript處理 javascript默認放在monsys/javascript下
調用方法:$clink.setURI("javascript/test.css")
3,portlets的位置位于monsys/WEB-INF/templates/vm/portlets/html下面
4,頁面總體布局控制看JetspeedResources.properties
bottomnav.enable=true
bottomnav.vm=bottom.vm
leftnav.enable=true
leftnav.vm=left.vm
leftnav.width=10%
topnav.enable=true
topnav.vm=top.vm
topnav.logo.file=images/jetspeed-logo-1.5.gif
topnav.logo.url=
topnav.user_login.enable=true
topnav.user_creation.enable=true
topnav.my_pages.enable=true
5,portlets源代碼分析: portlet主要實現三個方法:
<1>,buildMaximizedContext最大化
<2>,buildConfigureContext顯示信息
<3>,buildNormalContext正常情況,也就是所看到的正常顯示時所要顯示的信息
<4>,調用時,在添加模塊時添加新參數action=portlets.GraphDailyAction
package org.apache.jetspeed.modules.actions.portlets;
import .............(N個,略)
public class GraphDailyAction extends VelocityPortletAction {
/**
* Subclasses should override this method if they wish to
* build specific content when maximized. Default behavior is
* to do the same as normal content.
*/
protected void buildMaximizedContext(VelocityPortlet portlet, Context context, RunData rundata) {
buildNormalContext(portlet, context, rundata);
String text = (String) context.get("text");
if (text == null) {
text = "Top Record of baccarat game";
}
context.put("text", text + " (Maximized !)");
}
/**
* Subclasses should override this method if they wish to
* provide their own customization behavior.
* Default is to use Portal base customizer action
*/
protected void buildConfigureContext(VelocityPortlet portlet, Context context, RunData rundata) {
buildNormalContext(portlet, context, rundata);
setTemplate(rundata, "hello-customize");
}
/**
* 這是主要部份
* Subclasses must override this method to provide default behavior
* for the portlet action
*/
protected void buildNormalContext(VelocityPortlet portlet, Context context, RunData rundata) {
String mode = portlet.getPortletConfig().getInitParameter("mode"); //讀取添加模塊時從配置文件傳來的參數
String searchdate = rundata.getParameters().getString("searchdate"); //取得從頁面提交得到的參數
context.put("mode", mode);
context.put("searchdate", searchdate) //輸出頁面要顯示的信息,支持輸出數組,對像,及容器等形式的數據
}
}
<5>寫好源代碼,并編譯,參考里的:
1,<3>所建的參數action,其值為portlets.GraphDailyAction,則系統會去執行這個類
(轉載文章請保留出處:Java家(www.javajia.com))
這里假設monsys為web服務的名稱,其路徑在webapps/下面
1,jetspeed的圖片處理圖片默認放在monsys/images下面,
調用方法:$clink.setURI("images/test.jpg")
2,javascript處理 javascript默認放在monsys/javascript下
調用方法:$clink.setURI("javascript/test.css")
3,portlets的位置位于monsys/WEB-INF/templates/vm/portlets/html下面
4,頁面總體布局控制看JetspeedResources.properties
bottomnav.enable=true
bottomnav.vm=bottom.vm
leftnav.enable=true
leftnav.vm=left.vm
leftnav.width=10%
topnav.enable=true
topnav.vm=top.vm
topnav.logo.file=images/jetspeed-logo-1.5.gif
topnav.logo.url=
topnav.user_login.enable=true
topnav.user_creation.enable=true
topnav.my_pages.enable=true
5,portlets源代碼分析: portlet主要實現三個方法:
<1>,buildMaximizedContext最大化
<2>,buildConfigureContext顯示信息
<3>,buildNormalContext正常情況,也就是所看到的正常顯示時所要顯示的信息
<4>,調用時,在添加模塊時添加新參數action=portlets.GraphDailyAction
package org.apache.jetspeed.modules.actions.portlets;
import .............(N個,略)
public class GraphDailyAction extends VelocityPortletAction {
/**
* Subclasses should override this method if they wish to
* build specific content when maximized. Default behavior is
* to do the same as normal content.
*/
protected void buildMaximizedContext(VelocityPortlet portlet, Context context, RunData rundata) {
buildNormalContext(portlet, context, rundata);
String text = (String) context.get("text");
if (text == null) {
text = "Top Record of baccarat game";
}
context.put("text", text + " (Maximized !)");
}
/**
* Subclasses should override this method if they wish to
* provide their own customization behavior.
* Default is to use Portal base customizer action
*/
protected void buildConfigureContext(VelocityPortlet portlet, Context context, RunData rundata) {
buildNormalContext(portlet, context, rundata);
setTemplate(rundata, "hello-customize");
}
/**
* 這是主要部份
* Subclasses must override this method to provide default behavior
* for the portlet action
*/
protected void buildNormalContext(VelocityPortlet portlet, Context context, RunData rundata) {
String mode = portlet.getPortletConfig().getInitParameter("mode"); //讀取添加模塊時從配置文件傳來的參數
String searchdate = rundata.getParameters().getString("searchdate"); //取得從頁面提交得到的參數
context.put("mode", mode);
context.put("searchdate", searchdate) //輸出頁面要顯示的信息,支持輸出數組,對像,及容器等形式的數據
}
}
<5>寫好源代碼,并編譯,參考里的:
1,<3>所建的參數action,其值為portlets.GraphDailyAction,則系統會去執行這個類
(轉載文章請保留出處:Java家(www.javajia.com))