Location Chooser Widget

Location Chooser provides a way of choosing the location of files from the desktop. The widget uses Prototype library and implements DWR (Direct Web Remoting) to get data. Use the File Chooser to select files from the desktop.

Dependency

No dependencies. The File Chooser Widget depends on the Location Chooser Widget.

Features

  • Select the location on your desktop through this widget.

How to use

Add this code to the head section of the page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<style type="text/css" title="currentStyle" media="screen">
  @import '<%=dekoh.portal.util.StaticFilesURLGenerator.generateStaticFileURL(request, "theme","app","css.jsp?externalApp=true")%>';
</style>
<script src='/dekohportal/dwr/engine.js'>
</script>
<script src='/dekohportal/dwr/util.js'>
</script>
<script type='text/javascript' src='<%=dekoh.portal.util.StaticFilesURLGenerator.generateStaticFileURL(request, "common",null,"JSlibrary.jsp")%>'>
</script>
<script type="text/javascript" src="<%=dekoh.portal.util.StaticFilesURLGenerator.generateStaticFileURL(request, "widget","locationChooser","locationchooserdialog.js")%>">
</script>
<script type="text/javascript" src="<%=dekoh.portal.util.StaticFilesURLGenerator.generateStaticFileURL(request, "widget","locationChooser","locationchooser.js")%>">
</script>
<script type="text/javascript" src="<%=dekoh.portal.util.StaticFilesURLGenerator.generateStaticFileURL(request, "widget","dialog","dialog.js")%>">
</script>
<script src='/dekohportal/dwr/interface/locationchooser.js'>
</script>

JavaScript code

The basic syntax to initialize the Dialog widget is
<script type="text/javascript">
function handleLocationChooserOnClose(gDialogId, returnValue, servletUrl)
{
alert('selected folder is '+returnValue);
}
</script>

HTML code

Include the following code where you want to invoke the Location Chooser in page:
<input type="button" value="Select" class="dekoh_button" onclick="javascript:new LocationChooserDialog('dialog_ID',null,{fileSeparator:'\\'});"/>

Embedding the Location Chooser in the page

Add this code to the head section of the page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<style type="text/css" title="currentStyle" media="screen">
 @import '<%=dekoh.portal.util.StaticFilesURLGenerator.generateStaticFileURL(request, "theme","app","css.jsp?externalApp=true")%>';
</style>
<script src='/dekohportal/dwr/engine.js'>
</script>
<script src='/dekohportal/dwr/util.js'>
</script>
<script type='text/javascript' src='<%=dekoh.portal.util.StaticFilesURLGenerator.generateStaticFileURL(request, "common",null,"JSlibrary.jsp")%>'>
</script>
<script type="text/javascript" src="<%=dekoh.portal.util.StaticFilesURLGenerator.generateStaticFileURL(request,"widget","dialog","dialog.js")%>">
</script>
<script type="text/javascript" src="<%=dekoh.portal.util.StaticFilesURLGenerator.generateStaticFileURL(request,"widget","fileChooser","fileChooserDialog.js")%>">
</script>
<script type="text/javascript" src="<%=dekoh.portal.util.StaticFilesURLGenerator.generateStaticFileURL(request,"widget","locationChooser","locationchooser.js")%>">
</script>

Javascript code

The basic syntax to initialize the location chooser as an embedded widget in a page:
<script type="text/javascript">
function openLocationDialog()
{
new LocationChooser('locationChooserEmbedded','',{fileSeparator:"\\"});
}
</script>

HTML Code

Include the following code in the jsp/ html/ php page
<div id="locationChooserEmbedded"></div>
<input type="button" value="Select Files" onclick="javascript:openLocationDialog();"/>

Parameters for initializing the widget

Required parameters

OptionsSinceDescriptionDefault
IdV1.0Dialog Id-

Optional parameters

OptionsSinceDescriptionDefault
fileSeperatorV1.0This value is to be initialized for different operating systems

Functions

FunctionParametersDescription
initLCdialogId, bDontSetStatus, sFileSeparator-
createAddBookmark-Add bookmark for the location
removeAddBookmark--
checkBookmarkForDeletebookmarkListObj,strFileSeparator-
handleDeleteBookMarkcurrentBookmarkTxt-
handleNewBookmarkName--
createTreetargetEle, fullTree, bChildDirCall, marginLeft, currentEleObjRef, strFileSeparator-
isBookmarkedpathname, bookmarks, strFileSeparator-
resetBookmarksSelectBox--
checkCurrentfolderBookmarkcurrFolder-
getAllBookmarksrootDirectories-
sortSelectobj-
setActiveNode--
createNewFolder--
trimCurrentPathTextstrPath-
setCurrentLocationstrPath-
validateNewFolderNametxtBox-
setBookmarkDirname, Bookmark, sFileSeparator-
bookmarkSelectedxcurrentFolder, dialogId, strFileSeparator-
makeDirNamePrefix, suffix-
selectFolderservletUrl-

Parameters for running Location Chooser in dialog mode

Required parameters

OptionsSinceDescriptionDefault
IdV1.0Dialog Id-

Optional parameters

OptionsSinceDescriptionDefault
classNameV1.0The style classDekoh
headerMsgV1.0The message shown on the dialog'Select location on your desktop'
fileSeperatorV1.0This value is to be initialized for different operating systems'
'
titleV1.0Set the title here‘File Chooser’
widthV1.0Width of the dialog600
heightV1.0Height of the dialog450
xPosV1.0Specify the x position of the dialog in the document 0
yPosV1.0Specify the y position of the dialog in the document0
resizableV1.0Set whether the dialog is resizable or notfalse
minimizableV1.0Works with resizable value set to ‘true’. The value defined for this is ‘true’ or ‘false’ depends on whether you want to make dialog minimized False
maximizableV1.0Works with resizable value set to ‘true’. The value defined for this is ‘true’ or ‘false’ depends on whether you want to make dialog maximizedFalse
isModalV1.0Specify whether the dialog is modal or nottrue

DWR Implementation

Reference in web.xml

<init-param>
            <param-name>config-locationChooser</param-name>
            <param-value>widgets/locationChooser/dwr-locationchooser.xml</param-value>
</init-param>

DWR XML

<dwr>
    <allow>
        <create creator="new" javascript="locationchooser">
            <param name="class" 					value="dekoh.dekohportal.widget.locationchooser.LocationChooserUtil"/>
            <include method="getRootDirectories"/>
            <include method="saveLocationBookMark"/>
            <include method="saveFileBookMark"/>
            <include method="getAllLocationBookMarks"/>
            <include method="getAllFileBookMarks"/>
            <include method="getLocationBookMark"/>
            <include method="getFileBookMark"/>
            <include method="getCurrentFolderTree"/>
        </create>
        <convert converter="bean" match="dekoh.dekohportal.widget.locationchooser.LocationObject"/>
        <convert converter="bean" match="dekoh.dekohportal.widget.locationchooser.BookMarkObject"/>

    </allow>
</dwr>

Creators

Each class on which we execute methods, needs a <create ...> entry. There are several types of creator. The most common ones use either the 'new' keyword or the Spring framework. For more information, see the Creator documentation.

Methods-functionality

Method NameFunctionality
getRootDirectories-
saveLocationBookMark-
saveFileBookMark-
getAllLocationBookMarks-
getAllFileBookMarks-
getLocationBookMark-
getFileBookMark-
getCurrentFolderTree-

Converters

We need to ensure that all the parameters can be converted. Many of the types provided by the JDK are enabled for you, but you need to give DWR permission to convert your own code. Generally this means that JavaBean parameters will need a <convert ...> entry.

Availability

Dekoh Portal Ver 0.4.2 or later.

Attachments