Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /* 
   * Copyright (C) 2010---2013 星星(wuweixing)<349446658@qq.com>
   * 
   * This file is part of Wabacus 
   * 
   * Wabacus is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Lesser General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 package com.wabacus.system.inputbox;
 
 
 public class DatePickerBox extends TextBox
 {
     private String dateformat;
 
     public DatePickerBox(String typename)
     {
         super(typename);
     }
 
     public String getInputboxInnerType()
     {
         return "datepicker1";
     }
     
     protected String getTextBoxExtraStyleProperty(ReportRequest rrequest,boolean isReadonly)
     {
         if(isReadonlyreturn super.getTextBoxExtraStyleProperty(rrequest,isReadonly);
         String dynstyleproperty=" onclick=\"try{WdatePicker(";
         if(!=null&&!.trim().equals(""))
         {
             dynstyleproperty=dynstyleproperty+this.;
         }
         dynstyleproperty=dynstyleproperty+");}catch(e){logErrorsAsJsFileLoad(e);}\"";
         return Tools.mergeHtmlTagPropertyString(super.getTextBoxExtraStyleProperty(rrequest,isReadonly),dynstyleproperty,1);
     }
     
     public String filledInContainer(String onblur)
     {
         StringBuffer resultBuf=new StringBuffer();
         resultBuf.append("var datepickerparams=null;var onclick_propertyvalue=null;");
         resultBuf.append("if(inputboxSpanObj!=null){");
         resultBuf.append("  datepickerparams=inputboxSpanObj.getAttribute('inputboxparams');onclick_propertyvalue=inputboxSpanObj.getAttribute('onclick_propertyvalue');");
         resultBuf.append("}");
         resultBuf.append("if(onclick_propertyvalue==null) onclick_propertyvalue='';");
         resultBuf.append("boxstr=\"<input type='text' value=\\\"\"+boxValue+\"\\\"\";");
         resultBuf.append(getInputBoxCommonFilledProperties());
         //先调用fillInpuboxValueToTd(),再调用onblurmethod,因为这种输入框一直是显示<td/>时即显示出来,不担心输入框消失后无法显示失去焦点时的出错提示,而且这种输入框一选中日期后还没将选中日期赋给输入框即失去焦点,进行客户端校验,因此必须将校验函数放在后面
         resultBuf.append("boxstr=boxstr+\" onblur=\\\"try{").append(onblur).append(";\"+onblurmethod+\"").append("}catch(e){logErrorsAsJsFileLoad(e);}\\\"\";");
         resultBuf.append("if(onfocusmethod!=null&&onfocusmethod!=''){boxstr=boxstr+\" onfocus=\\\"try{\"+onfocusmethod+\"}catch(e){logErrorsAsJsFileLoad(e);}\\\"\";}");
         resultBuf.append("onclick_propertyvalue=onclick_propertyvalue+\";WdatePicker(\";");
         resultBuf.append("if(datepickerparams!=null&&datepickerparams!=''){onclick_propertyvalue=onclick_propertyvalue+datepickerparams}");
         resultBuf.append("onclick_propertyvalue=onclick_propertyvalue+\");\";");
         resultBuf.append("boxstr=boxstr+\" onclick=\\\"try{\"+onclick_propertyvalue+\"}catch(e){logErrorsAsJsFileLoad(e);}\\\"\";");
         resultBuf.append("boxstr=boxstr+\">\";");
         return resultBuf.toString();
     }
     
     public void loadInputBoxConfig(IInputBoxOwnerBean ownerbean,XmlElementBean eleInputboxBean)
     {
         super.loadInputBoxConfig(ownerbean,eleInputboxBean);
         this.setTypePromptBean(null);
         if(eleInputboxBean!=null)
         {
             String dateformat=eleInputboxBean.attributeValue("dateformat");
             if(dateformat!=nullthis.=dateformat.trim();
             
         }
         String dynparams="";
         if(this.!=null&&!this..trim().equals(""))
         {
             dynparams=dynparams+"dateFmt:'"+this.+"',";
         }
         
         if(this.!=null&&!this..trim().equals(""))
         {
             if(this..equals(.))
             {
                 dynparams=dynparams+"lang:'zh-cn',";
             }else
             {
                 dynparams=dynparams+"lang:'en',";
             }
        }
        this.=Tools.mergeJsonValue(dynparams,this.);
        this.=this.==null?"":this..trim();
        if(!this..trim().equals(""))
        {
            this.="{"+this.+"}";
        }
    }
    
    {
        String resultStr="onkeypress='return onKeyEvent(event);'";
        if(this.hasDescription())
        {
            resultStr+=" class='cls-inputbox2' ";
        }else
        {
            resultStr+=" class='cls-inputbox2-full' ";
        }
        return resultStr;
    }
    
    {
        String onclick=Tools.getPropertyValueByName("onclick",this.,false);
        if(onclick!=null&&!onclick.trim().equals(""))
        {
            this..put("onclick",onclick);
        }
        this.=Tools.removePropertyValueByName("onclick",this.);
    }
    
    public void setDefaultFillmode(AbsReportType reportTypeObj)
    {
        this.=1;
    }
    public void doPostLoad(IInputBoxOwnerBean ownerbean)
    {
        super.doPostLoad(ownerbean);
        String jspick=.+"/webresources/component/My97DatePicker/WdatePicker.js";
        jspick=Tools.replaceAll(jspick,"//","/");
        ownerbean.getReportBean().getPageBean().addMyJavascriptFile(jspick,0);
    }
    
    
New to GrepCode? Check out our FAQ X