Selection Tray Widget

Selection Tray Widget lets you select objects and collect them in a tray. The widget is based on Prototype javascript library.

Features

  • Has two modes of interaction--thumbnail and list
  • Customizable look and feel

How to use

JavaScript code

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","selectionTray","selectionTray.js")%>'>
</script>
<script type="text/javascript" src="<%=dekoh.portal.util.StaticFilesURLGenerator.generateStaticFileURL(request, "widget","dialog","dialog.js")%>">
</script> 

HTML Code

Add the following code where you want to invoke the Selection Tray on the page:

<table>
        <tr>
            <td>
                    <div id='dekoh_selectedObjectTray'></div>
            </td>
            <td>
                <div id='dekoh_viewObjectTray'>
                    <!—setting the list header- -- >
                    <div id='dekoh_viewObjectTray_ListHeader' style="display:none;">
                        <table>
                            <tr>
                                <th width="40"> &nbsp;</th>
                                <th width="200"> Title</th>
                                <th> Description</th>
                            </tr>
                        </table>
                    </div>

                    <div class='dekoh_selectableObjects' id="OBJECT_ID_">
                    <!—setting the thumbnail section- -- >
                        <div class='dekoh_OL_ObjthumbnailView' style="display:none;" id="coll_thumb_OBJECT_ID_">
                            <!—put ur html code here to show thumbnail?
                                <div style="width:100px;height:100px;background:#eee;border:1px #000 solid;"></div>
                        </div>
                            <!—setting the list section- -- >
                        <div class='dekoh_OL_ObjListView' style="display:none;"id="coll_list__OBJECT_ID_">
                            <!—put ur html code here to show list?
                            <table>
                                    <tr>
                                        <td width="40"> &nbsp;</td>
                                        <td width="200"> Title of OBJECT_ID </td>
                                        <td> Description of OBJECT_ID </td>
                                    </tr>
                            </table>
                        </div>
                    </div>
                </div>
            </td>
        </tr>
    </table>

Initializing the Selection Tray

The JavaScript to initialize the widget is:

<script type="text/javascript">
//<![CDATA[
// create the unselected object array
unselectedObjArray[unselectedObjArray.length] =    new selTrayObj('OBJECT_ID_', true, 'OBJECT_URL_", OBJECT_NAME_"', 'OBJECT_CLICK_URL_', 'OBJECT_TYPE_(collection or simple object)');
//initialize the selection tray where the objects are going to get collected
var selTray = new SelectionTray('selTray', {selectMode:'dnd',actionMode:'edit', showSelectedItemUrl:'URL_TOSHOW_COLLECTED_OBJECT'});
//initialize the object tray
var objTray = new ObjectsTray('objTray', {selectionMode:'dnd',actionMode:'edit', showItemsOnPage:'TOTAL_ITEMS_TOSHOW',currentItemsPage:'CURRENT_PAGE',totalItems:'TOTAL_ITEMS',droppableSection:'dekoh_SelectedObjTrayDiv', showMode:'thumbnail', nextPageUrl:'NEXT_PAGE_URL_',prevPageUrl:'PREV_PAGE_URL'});
//]]>
</script>

Note: Place the JavaScript code after the div element in the page so that the element is registered in the DOM.

Parameters used by SelectionTray class

Required parameters

OptionsSinceDescriptionDefault
idV1.0Id of the selection tray initialized

Optional parameters

OptionsSinceDescriptionDefault
selectionModeV1.0Set the value as ‘dnd’ or ‘click’‘dnd’
showSelectedItemUrlV1.0Set the view url if user need to go to some other pagenull
showModeV1.0Set the value as ‘list’ or ‘thumbnail’thumbnail
showClicktoSelectActionV1.0Show or hide the click to select modetrue
getItemsLabelV1.0Label for bring all ‘bring all’

Functions

FunctionParametersDescription
changeSelectionMode-Change the mode of the selection from dnd to click and vice versa
selectAllObjects-Selects all the objects on the object tray
removeSelectedObjectidRemove the selected object
getSelectedDioIDsidGet the dioId of the selected object
getSelectionTrayItems-Returns all the selection tray objects
showRemoveEffect-The effect shown when the object is removed
addMessageInTray-Add the message in the tray when there are no objects in the tray
removeMessageInTray-Remove the message from the tray
removeAllSelectionObject-Remove all the selection object in the tray
processSelectedObject-After the object is selected, this method does processing
selectObjectobjEleId
isCollection objSrc objName objUrl objType|
showObjInfoe-event
objEle- Object Div element objSrc- the image source to be shown objName- object name|Show the object information on mouse-over
removeObjInfoobjEleRemove the object information on mouse-out
toggleView-Collapse or expand the selection tray

Parameters used by ObjectTray class

Required parameters

OptionsSinceDescriptionDefault
idV1.0Id of the object tray initialized

Optional parameters

OptionsSinceDescriptionDefault
totalItemsV1.0Total number of itemsnull
showModeV1.0Set the value as ‘list’ or ‘thumbnail’thumbnail
showItemsOnPageV1.0Number of items to be shown on the pagenull
currentItemsPageV1.0Current items on the pagenull
droppableSectionV1.0Droppable section where the objects will be droppednull
actionModeV1.0Set the value as ‘view’ or ‘edit’view
selectionModeV1.0Set the value as ‘dnd’ or ‘click’‘dnd’
prevPageUrlV1.0Previous page urlNull
nextPageUrlV1.0Next page urlNull
customActionsV1.0Set the custom code in html formatnull
showToolbarV1.0Set the toolbar to show up or nottrue

Functions

FunctionParametersDescription
handleMouseDownSelectedObjElement-object element e-eventHandle the mouse down event on the focused object
handleMouseUpSelectedObj-Handle the mouse up event on the focused object
handleMouseOverOnObjobjEleHandle the mouse over event on the focused object
handleMouseOutOnObjobjEleHandle the mouse out event on the focused object
changeSelectionMode-Change the selection mode ‘dnd’ or ‘click’
loadAllUnselectedObjects-Load all the unselected objects
toggleThumbnailObjViewmodeChange to the thumbnail view
toggleListObjViewmodeChange to list view
makeObjDraggableidMake the object draggable when in the drag and drop mode
makeObjUnDraggableidRemove the draggability from the object
showObjectViewView persistShow the objects in a specific view
getObjectTrayItems-Get all the object tray objects
persistViewviewPersist the view of either the list or thumbnail

DWR Implementation

    • Reference in web.xml

The DWR method mapping XML is included in web.xml

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

DWR XML

<!DOCTYPE dwr PUBLIC
    "-//GetAhead Limited//DTD Direct Web Remoting 1.0//EN"
    "http://www.getahead.ltd.uk/dwr/dwr10.dtd">
<dwr>
    <allow>

        <create creator="new" javascript="selectionTray">
            <param name="class" value="dekoh.portal.widget.selectionTray.SelectionTrayUtil"/>
            <include method="addToSelectionTray"/>
            <include method="getSelectedSelectionTrayObject"/>
            <include method="getSelectedSelectionTrayObjectOfMedia"/>
            <include method="deleteFromSelectionTray"/>
            <include method="deleteAllFromSelectionTray"/>
            <include method="setUserViewPreference"/>
        </create>
        <convert converter="bean" match="dekoh.portal.widget.selectionTray.SelectionTrayObject"/>

    </allow>
</dwr>

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 bean. Generally this means that JavaBean parameters will need a <convert ...> entry.

Convert-classdekoh.portal.widget.selectionTray.SelectionTrayObject
DescriptionJavaBean to holding the information about the digitalObject in selection tray.

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.

ClassNamedekoh.portal.widget.selectionTray.SelectionTrayObject
DescriptionClass will provide the functionality to cache the given digital object metadata and serve when requested. Created selection object are cached in ServletContext with attribute name “slectionObjectListParameter'.

Methods-functionality

Method nameFunctionality
addToSelectionTrayCreates the selectionTrayObject from the given details and caches under the current accessing user.
getSelectedSelectionTrayObjectGet the list of all selectionTrayObjects of the current accessing user.
getSelectedSelectionTrayObjectOfMediaGet the list of all selectionTrayObjects of the current accessing user of given media type.
deleteFromSelectionTrayDeletes the given digital Object selection tray object from cache.
deleteAllFromSelectionTrayClears the selection tray cache for the current accessing user.

Availability

Dekoh Portal Ver 0.4.2 or later.

Attachments