codecharge,java 常用代码参考

***

//DoLogin_OnClick

  if (Utils.getUserId(e.getPage()) != null ) { 
     String userId = DBTools.toSql(Utils.getUserId(e.getPage()), JDBCConnection.TEXT, "Connection1");
     SessionStorage.getInstance(e.getPage().getRequest()).setAttribute("User_Name", 
	 DBTools.dLookUp("User_Name","Users","User_ID="+userId,"Connection1"));
 }
 
//Form1_Insert1_OnClick

  e.getPage().setRedirectString("InsertMessagePage.do");


//Form1_Update1_OnClick

  e.getPage().setRedirectString("UpdateMessagePage.do");

 
//Tasks_BeforeShowRow

  if(e.getGrid().getControl("Estimated_Time").getValue() != null && 
      Utils.convertToDouble(e.getGrid().getControl("Estimated_Time").getValue()).doubleValue()>0 ){
    e.getGrid().getControl("Task_Percent").setValue( 
      (Utils.convertToDouble(e.getGrid().getControl("Expended_Time").getValue()).doubleValue()*100)/Utils.convertToDouble(e.getGrid().getControl("Estimated_Time").getValue()).doubleValue()); 
  } else {
    e.getGrid().getControl("Task_Percent").setValue(0);
  }
 
//DoLogin_OnClick

  if (Utils.getUserId(e.getPage()) != null ) { 
     String userId = DBTools.toSql(Utils.getUserId(e.getPage()), JDBCConnection.TEXT, "Connection1");
     SessionStorage.getInstance(e.getPage().getRequest()).setAttribute("User_Name", 
	 DBTools.dLookUp("User_Name","Users","User_ID="+userId,"Connection1"));
 }
 
//Users BeforeShowRow

  Link link1 = e.getGrid().getLink("Link1");
  link1.setHrefSourceValue("UserPage.do");
  link1.setPreserveType(PreserveParameterType.GET);
  link1.clearParameters();
  LinkParameter userId = new LinkParameter("user_id", "", ParameterSource.EXPRESSION);
  userId.setValue("1");
  link1.addParameter(userId);
  link1.setValue(e.getGrid().getControl("First_Name").getValue() + " " + e.getGrid().getControl("Last_Name").getValue() );

 
//Registration_MonthBox_BeforeShow

  if (StringUtils.isEmpty(e.getPage().getParameter("MonthBox"))) {
    e.getControl().setValue(new java.text.SimpleDateFormat("M").format(new Date()));
  }
 
//Form1_BeforeShow

   if (e.getRecord().isEditMode()) {
    //Edit Mode
  } else {
    //Add Mode
  }
 
class LUI {
  public void lastUpdateInfo(Page page) {
    page.getRecord("Tasks").getControl("LastUpdateDate").setValue(new Date());
    page.getRecord("Tasks").getControl("LastUpdateUserid").setValue(Utils.getUserId(page));
  }
}
//Tasks_BeforeInsert

  new LUI().lastUpdateInfo(e.getPage());


//Tasks_BeforeUpdate

  new LUI().lastUpdateInfo(e.getPage());

 
 if ("profile".equals(e.getPage().getHttpGetParams().getParameter("mode"))) {
	((com.codecharge.util.ModelAttribute)e.getModel().getAttribute("disabled")).setValue("disabled");
  }
 
e.getControl().setValue(e.getPage().getResourceString("CCS_Today"));
 

***

 

你可能感兴趣的:(java)