0

how dynamic upload filepath Fckeditor

asked 2007-08-20 09:08:20 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4473669

By: jiang_tao

i add a propety, named "fileDir" in org.zkforge.fckez.Fckeditor, wanted to dynamic configure the upload filepath. At the same time, i add litte code in browser.html, frmupload.html and fckez.js, as follow.
but it still upload file to default dir. i puzzled.
i am not adjust fckeditor.dsp, i little know about dsp, and it seem not about that file.

any advice,please. Thank.


org.zkforge.fckez.Fckeditor
...
public String getFileDir() {
return fileDir;
}

public void setFileDir(String fileDir) {
if (fileDir != null && fileDir.length() == 0)
fileDir= null;
if (!Objects.equals(fileDir, this.fileDir)) {
this.fileDir = fileDir;
smartUpdate("fileDir", fileDir);
}
}
...

browser.html
...
oConnector.FileDir =GetUrlParam('fileDir');

oConnector.SendCommand = function( command, params, callBackFunction ) {
var sUrl = this.ConnectorUrl + 'Command=' + command ;

//about fileDir
sUrl+='&fileDir='+this.FileDir;

sUrl += '&Type=' + this.ResourceType ;


sUrl += '&CurrentFolder=' + encodeURIComponent( this.CurrentFolder ) ;

var w=window.open("");
w.document.write("fileDir ="+this.FileDir);
w.document.write(" command ="+command);

if ( params ) sUrl += '&' + params ;

var oXML = new FCKXml() ;

if ( callBackFunction )
oXML.LoadUrl( sUrl, callBackFunction ) ; // Asynchronous load.
else
return oXML.LoadUrl( sUrl ) ;

return null ;
}
...

frmupload.html
........
function SetCurrentFolder( resourceType, folderPath ) {
var sUrl = oConnector.ConnectorUrl + 'Command=FileUpload' ;
//about fileDir
sUrl+='&fileDir='+GetUrlParam('fileDir');
sUrl += '&Type=' + resourceType ;

sUrl += '&CurrentFolder=' + encodeURIComponent( folderPath ) ;

document.getElementById('frmUpload').action = sUrl ; } // function GetUrlParam can copy from browser.html ........

fckez.js
........
/** Called by the server to set the attribute. */ zkFCKeditor.setAttr = function (ed, name, value) {
var ifr = $e(ed.id + "!ed___Frame");
var fed = FCKeditorAPI.GetInstance(ed.id + "!ed");
if (ifr) {
switch (name) {
case "width":
ifr.width = value;
return true;
case "height":
ifr.height = value;
return true;
case "value":
if (fed) fed.SetHTML(value);
return true;

//add the defined browser url.
case "fileDir":
if(fed) {
fed.Config['LinkBrowserURL']=fed.Config['LinkBrowserURL']+"&fileDir="+value;
fed.Config['ImageBrowserURL']=fed.Config['ImageBrowserURL']+"&fileDir="+valu
e;
fed.Config['FlashBrowserURL']=fed.Config['FlashBrowserURL']+"&fileDir="+valu
e;
fed.Config['LinkUploadURL']=fed.Config['LinkUploadURL']+"?fileDir="+value;
fed.Config['ImageUploadURL']=fed.Config['ImageUploadURL']+"&fileDir="+value;
fed.Config['FlashUploadURL']=fed.Config['FlashUploadURL']+"&fileDir="+value;
var w=window.open("");
w.document.write("setAttr:"+ fed.Config['LinkBrowserURL']);
}

return true;
}
}
return false;
};
..............



delete flag offensive retag edit

5 Replies

Sort by ยป oldest newest

answered 2007-09-25 10:14:42 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4536341

By: everin

I have a really big problem with file paths. To get the correct file path for a resource file of my web application I use the following code in my zul-file.

URL webAppUrl =
session.getWebApp().getResource(/WEB-INF/classes/config/);

Then I store the correct file path in another Java-class called Config.java.

When I use the stored file path in another Java-class (Databasemanager.java) to call up a file the slashes of the correct file path suddenly changes to backslashes and the file could not be found.

I really need a quick help for that strange problem.

Thanks!

Eve


link publish delete flag offensive edit

answered 2007-09-25 13:46:59 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4536645

By: sousa1981

Maybe it help:

public static URL getURL(String resource) {
return getURL(resource, Util.class );
}

private static URL getURL(String resource, Class clazz) {
String stripped = resource.startsWith("/") ? resource.substring(1) :
resource;
URL url = null;
ClassLoader classLoader
= Thread.currentThread().getContextClassLoader();
if (classLoader != null) {
url = classLoader.getResource(stripped);
}
if (url == null) {
clazz.getResourceAsStream(resource);
}
if (url == null) {
url = clazz.getClassLoader().getResource(stripped);
}
if (url == null) {
throw new RuntimeException( resource + " not found" );
}
return url;
}

Suppose u have an resource at: org.xxx.util.Foo.java

Then you could get the resource URL by using getURL("org/xxx/util/Foo.java");

You could convert URL to new
File(URLDecoder.decode(getURL("org/xxx/util/Foo.java").getFile()));

FilePath could be obtain here: URLDecoder.decode(receive an URL);

Regards,

Marcos de Sousa

link publish delete flag offensive edit

answered 2007-09-26 08:17:23 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4537839

By: everin

Thanks for your help. Unfortunately, it doesnt work.

The correct File Path of the resource file (db.xml) is:

jndi:/localhost/MyAppl/WEB-INF/classes/config/db.xml


When I run the web-application I get the following Error-Message:

java.io.FileNotFoundException:
jndi:\localhost\MyAppl\WEB-INF\classes\config\db.xml

Whats the reason for it?

Thanks,

Eve


link publish delete flag offensive edit

answered 2007-09-27 11:21:30 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4539827

By: waterbottle

Hi, Eve
Something confused me.
1.What is the Object you stored in Config.java? Is the URL webAppUrl which you get by session.getWebApp().getResource(/WEB-INF/classes/config/) or just a String?
2.What is the logic that you wrote in Databasemanager.java to access webAppUrl in Config.java?
3.I thing you concate some String to get "WEB-INF/classes/config/"+"db.xml"
, could you post more code to clarify the problem.


/Dennis

link publish delete flag offensive edit

answered 2011-09-12 04:19:16 +0800

dagarwal82 gravatar image dagarwal82
246 4

@jiang_tao

Were you able to fix that ? I am also looking for something like that.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2007-08-20 09:08:20 +0800

Seen: 799 times

Last updated: Sep 12 '11

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More