2015年6月1日 星期一

Xpages use Java 計算日期

備忘: Xpages use Java  計算日期

var date:java.util.Date = getComponent("dateFrom").getValue();
var cal:java.util.Calendar = java.util.Calendar.getInstance();
cal.setTime(date);
getComponent("inputText1").setValue(cal.get(java.util.Calendar.DAY_OF_MONTH)); 
getComponent("inputText2").setValue(cal.get(java.util.Calendar.MONTH) + 1);  
getComponent("inputText4").setValue(cal.get(java.util.Calendar.DAY_OF_WEEK));

Calling CSJS from within SSJS in XPages

xe:dialog control. You can show and hide that dialog using SSJS.

Here are the SSJS and CSJS commands to show/hide the dialog:
SSJS:
var comp = getComponent("serverSideId");
//To Open the dialog
comp.show();
//To close the dialog
comp.hide();
CSJS
//To Open the dialog
XSP.openDialog("#{id:serverSideId}");
//To close the dialog
XSP.closeDialog("#{id:serverSideId}");
And just for fun, SSJS that executes CSJS:
//To Open the dialog
facesContext.getViewRoot().postScript("XSP.openDialog('#{id:serverSideId}')");
//To Close the dialog
facesContext.getViewRoot().postScript("XSP.closeDialog('#{id:serverSideId}')");
 
資料來源:stackoverflow