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;
 
 import java.util.List;
 import java.util.Map;
 
 
 public abstract class AbsPopUpBox extends AbsInputBox
 {
     protected String poppageurl;
 
     protected Map<String,StringmDynParamColumns;
 
     protected Map<String,StringmDynParamConditions;
     
     protected String popupparams;
 
     protected String initsize;//初始大小,可配置值包括min/max/normal,分别表示最大化、最小化、正常窗口大小(即上面pagewidth/pageheight配置的大小)
     
     public AbsPopUpBox(String typename)
     {
         super(typename);
     }
     
     public String getPoppageurl()
     {
         return ;
     }
 
     public String getPopupparams()
     {
         return ;
     }
 
     public void setPopupparams(String popupparams)
     {
         this.=popupparams;
     }
 
     {
         String resultStr="onfocus='this.select();' onkeypress='return onKeyEvent(event);' onmouseover=\"this.style.cursor='pointer';\" readonly";
         if(this.hasDescription())
         {
             resultStr+=" class='cls-inputbox2' ";
         }else
         {
             resultStr+=" class='cls-inputbox2-full' ";
         }
         return resultStr;
     }
     
     public Map<String,StringgetMDynParamColumns()
     {
         return ;
     }
 
     {
         return ;
     }
 
     public String getIndependentDisplayString(ReportRequest rrequest,String value,String dynstyleproperty,Object specificDataObj,boolean isReadonly)
     {
        return null;
     }
    
    protected String getPopupUrlJsonString()
    {
        StringBuffer resultBuf=new StringBuffer();
        resultBuf.append("{pageid:\"").append(.getReportBean().getPageBean().getId()).append("\"");
        resultBuf.append(",reportid:\"").append(.getReportBean().getId()).append("\"");
        resultBuf.append(",popupPageUrl:\"").append(this.).append("\"");
        if(this.!=null&&this..size()>0)
        {
            resultBuf.append(",paramColumns:\"").append(getDynParamsAsJsonString(this.)).append("\"");
        }
        if(this.!=null&&this..size()>0)
        {
            resultBuf.append(",paramConditions:\"").append(getDynParamsAsJsonString(this.)).append("\"");
        }
        resultBuf.append(",popupparams:\"").append(this.).append("\"");
        resultBuf.append("}");
        return Tools.jsParamEncode(resultBuf.toString());
    }
    
    private String getDynParamsAsJsonString(Map<String,StringmDynParams)
    {
        if(mDynParams==null||mDynParams.size()==0) return "";
        StringBuffer paramsBuf=new StringBuffer();
        for(Entry<String,StringentryParamTmp:mDynParams.entrySet())
        {
            paramsBuf.append(entryParamTmp.getValue()).append(";");
        }
        if(paramsBuf.charAt(paramsBuf.length()-1)==';')
        {
            paramsBuf.deleteCharAt(paramsBuf.length()-1);
        }
        return paramsBuf.toString();
    }
    
    public void setDefaultFillmode(AbsReportType reportTypeObj)
    {
        this.=1;
    }
    
    public void loadInputBoxConfig(IInputBoxOwnerBean ownerbean,XmlElementBean eleInputboxBean)
    {
        super.loadInputBoxConfig(ownerbean,eleInputboxBean);
        String popupparams=eleInputboxBean.attributeValue("popupparams");
        if(popupparams!=null)  this.=popupparams.trim();
        String initsize=eleInputboxBean.attributeValue("initsize");
        if(initsize!=nullthis.=initsize.trim().toLowerCase();
        parseDynParamsInUrl();
    }
    
    private void parseDynParamsInUrl()
    {
        if(this.==null||this..trim().equals("")) return;
        this.=new HashMap<String,String>();
        this.=new HashMap<String,String>();
        String params=this.;
        if(params.indexOf('?')>0) params=params.substring(params.indexOf('?')+1);
        List<StringlstParams=Tools.parseStringToList(params,"&");
        String paramNameTmp,paramValueTmp;
        int idxTmp;
        for(String paramTmp:lstParams)
        {
            if(paramTmp==nullcontinue;
            idxTmp=paramTmp.indexOf("=");
            if(idxTmp<=0) continue;
            paramNameTmp=paramTmp.substring(0,idxTmp).trim();
            paramValueTmp=paramTmp.substring(idxTmp+1).trim();
            if(Tools.isDefineKey("@",paramValueTmp))
            {
                this..put(paramNameTmp,Tools.getRealKeyByDefine("@",paramValueTmp));
            }else if(Tools.isDefineKey("condition",paramValueTmp))
            {
                this..put(paramNameTmp,Tools.getRealKeyByDefine("condition",paramValueTmp));
            }
        }
    }
    
    public void doPostLoad(IInputBoxOwnerBean ownerbean)
    {
        super.doPostLoad(ownerbean);
        if(this.!=null&&this..size()>0)
        {
            DisplayBean dbean=this..getReportBean().getDbean();
            ColBean cbTmp;
            for(Entry<String,StringentryParamTmp:.entrySet())
            {
                cbTmp=dbean.getColBeanByColProperty(entryParamTmp.getValue());
                if(cbTmp==null)
                {
                    throw new WabacusConfigLoadingException("加载报表"+this..getReportBean().getPath()+"的输入框"+this..getInputBoxId()
                            +"失败,在弹出窗口URL的参数中指定的column为"+entryParamTmp.getValue()+"的列不存在");
                }
            }
        }
        if(this.!=null&&this..size()>0)
        {
            SqlBean sbean=this..getReportBean().getSbean();
            ConditionBean cbTmp;
            for(Entry<String,StringentryParamTmp:this..entrySet())
            {
                cbTmp=sbean.getConditionBeanByName(entryParamTmp.getValue());
                if(cbTmp==null)
                {
                    throw new WabacusConfigLoadingException("加载报表"+this..getReportBean().getPath()+"的输入框"+this..getInputBoxId()
                            +"失败,在弹出窗口URL的参数中指定的name为"+entryParamTmp.getValue()+"的查询条件不存在");
                }
                if(!cbTmp.isConditionWithInputbox())
                {
                    throw new WabacusConfigLoadingException("加载报表"+this..getReportBean().getPath()+"的输入框"+this..getInputBoxId()
                            +"失败,不能在弹出窗口URL的参数中指定没有输入框的条件做为动态参数值");
                }
            }
        }
        =WabacusAssistant.getInstance().addDefaultPopupParams(,this.,getDefaultWidth(),getDefaultHeight(),"closePopUpPageEvent");
    }
    
    protected abstract String getDefaultWidth();
    
    protected abstract String getDefaultHeight();
    
    protected void processStylePropertyAfterMerged(AbsReportType reportTypeObj,IInputBoxOwnerBean ownerbean)
    {
        super.processStylePropertyAfterMerged(reportTypeObj,ownerbean);
        
        if(this..toLowerCase().indexOf("readonly")<0) this.=this.+" readonly ";
    }
    
    {
        String onclick=Tools.getPropertyValueByName("onclick",this.,false);
        if(onclick!=null&&!onclick.trim().equals(""))
        {
            this..put("onclick",onclick);
        }
        this.=Tools.removePropertyValueByName("onclick",this.);
    }
    
    public String createSelectOkFunction(String realinputboxid,boolean isAutoincludejs)
    {
        boolean isConditionBox=false;
        String fillmode="";
        String paramname=null;
        if(this.getOwner() instanceof ConditionBean)
        {
            isConditionBox=true;
            paramname=((ConditionBean)this.getOwner()).getName();
        }else
        {
            isConditionBox=false;
            fillmode=String.valueOf(this.getFillmode());
            paramname=EditableReportAssistant.getInstance().getColParamName((ColBean)((EditableReportColBean)this.getOwner()).getOwner());
        }
        StringBuffer resultBuf=new StringBuffer();
        String parentWindowName,closeMeCodeString;
        if(Config.getInstance().getSystemConfigValue("prompt-dialog-type","artdialog").equals("artdialog"))
        {
            if(isAutoincludejs)
            {
                resultBuf.append("<script type=\"text/javascript\"  src=\""+.
                        +"webresources/component/artDialog/artDialog.js\"></script>");
                resultBuf.append("<script type=\"text/javascript\"  src=\""+.
                        +"webresources/component/artDialog/plugins/iframeTools.js\"></script>");
            }
            parentWindowName="artDialog.open.origin";
            closeMeCodeString="art.dialog.close();";
        }else
        {
            parentWindowName="parent";
            closeMeCodeString="parent.closePopupWin();";
        }
        resultBuf.append("<script language=\"javascript\">");
        resultBuf.append("function selectOK(value,name,label,closeme){");
        resultBuf.append("if(name==null||name==''||name=='"+paramname+"'){");
        resultBuf.append(parentWindowName+".setPopUpBoxValueToParent(value,'").append(realinputboxid).append("','").append(fillmode);
        resultBuf.append("','").append(this..getReportBean().getGuid()).append("','").append(this.getTypename()).append("');");
        resultBuf.append("}else{");
        if(isConditionBox)
        {
            resultBuf.append(parentWindowName+".setReportInputBoxValue(\""+this..getReportBean().getPageBean().getId()+"\",\""
                    +this..getReportBean().getId()+"\",true,"+parentWindowName+".getObjectByJsonString(\"{\"+name+\":\\\"\"+value+\"\\\"}\"));");
        }else
        {
            resultBuf.append("var newvalues=\"{\"+name+\":\\\"\"+value+\"\\\"\";");
            resultBuf.append("if(label!=null){newvalues=newvalues+\",\"+name+\"$label:\\\"\"+label+\"\\\"\";}");
            resultBuf.append("newvalues=newvalues+\"}\";");
            AbsReportType reportTypeObj=Config.getInstance().getReportType(this..getReportBean().getType());
            if(reportTypeObj instanceof EditableListReportType2)
            {
                resultBuf.append("var srcboxObj="+parentWindowName+".document.getElementById('"+realinputboxid+"');");//取到弹出窗口对应的源输入框对象,以便下面设置其它列的值时,可以取到其<tr/>对象
                resultBuf
                        .append(parentWindowName+".setEditableListReportColValueInRow(\""+this..getReportBean().getPageBean().getId()+"\",\""
                                +this..getReportBean().getId()
                                +"\","+parentWindowName+".getParentElementObj(srcboxObj,'TR'),"+parentWindowName+".getObjectByJsonString(newvalues));");
            }else
            {
                resultBuf.append(parentWindowName+".setEditableReportColValue(\""+this..getReportBean().getPageBean().getId()+"\",\""
                        +this..getReportBean().getId()+"\","+parentWindowName+".getObjectByJsonString(newvalues),null);");
            }
        }
        resultBuf.append("}");
        resultBuf.append("if(closeme!==false) "+closeMeCodeString+"}");
        resultBuf.append("</script>");
        return resultBuf.toString();
    }    
New to GrepCode? Check out our FAQ X