public String getInputterHTML(String section, FieldDescriptor fd, Object defaultValue, Map options) {
if(options==null) options = new HashMap();
if(defaultValue!=null && defaultValue instanceof FileContext){
FileContext defaultFileContext = (FileContext)defaultValue;
ProcessDefinitionRemote pdr = (ProcessDefinitionRemote)options.get("definitionRemote");
ProcessVariable[] variables = pdr.getProcessVariableDescriptors();
for(int i=0; i<variables.length; i++){
if(variables[i].getName().equals(fd.getName()))
defaultFileContext = (FileContext)variables[i].getDefaultValue();
}
ProcessInstance instance = (ProcessInstance)options.get("instance");
if(defaultFileContext.isFtpFile()){
StringBuffer inputterHTML = new StringBuffer();
String defaultPath = defaultFileContext.getPath();
if(!UEngineUtil.isNotEmpty(defaultPath))
defaultPath = null;
if(defaultPath!=null){
if( defaultPath.indexOf("<") > -1
|| defaultPath.indexOf(">") > -1
|| defaultPath.indexOf("%") > -1
|| defaultPath.indexOf("=") > -1
) defaultPath = "";
}else{
if(instance != null)
try {
defaultPath = defaultFileContext.getFullSavingFTPURL(instance);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
inputterHTML
.append("input type=button value='Open'")
.append(" onclick=\"ftp_openFile('")
.append(defaultPath)
.append("','")
.append(defaultFileContext.getFtpAddress())
.append("','")
.append(defaultFileContext.getFtpDirectory())
.append("','")
.append(defaultFileContext.getFtpUserId())
.append("','")
.append(defaultFileContext.getFtpPassword())
;
if(options.containsKey("instanceId"))
inputterHTML
.append("','")
.append(options.get("instanceId"))
;
else
inputterHTML.append("','null");
if(options.containsKey("defVerId"))
inputterHTML
.append("','")
.append(options.get("defVerId"))
;
else
inputterHTML.append("','null");
inputterHTML
.append("','")
.append(fd.getName())
;
inputterHTML.append("')\"");
// inputterHTML = new StringBuffer(inputterHTML.toString().replaceAll("<","").replaceAll(">","").replaceAll("%",""));
inputterHTML
.insert(0, "<")
.append(">")
;
try{
StringBuffer hiddenInptter = new StringBuffer();
hiddenInptter
.append("input type=hidden")
.append(HTML.getAttrHTML("name", createNameAttribute(section, fd.getName())))
.append(" value='"+ (defaultPath!=null ? defaultPath : defaultFileContext.getFullSavingFTPURL(null)) +"'")
;
// hiddenInptter = new StringBuffer(hiddenInptter.toString().replaceAll("<","").replaceAll(">","").replaceAll("%","").replaceAll("=",""));
hiddenInptter