[VIVO-1309] [VIVO-1307] Update DWR to version 3.0.2 and remove dom4j

This commit is contained in:
Graham Triggs 2016-12-16 18:47:17 +00:00
parent 2efe4b4a87
commit 1a292d8011
8 changed files with 81 additions and 74 deletions

View file

@ -56,12 +56,12 @@
<artifactId>cxf-xjc-ts</artifactId>
<version>2.6.2</version>
</dependency>
<dependency>
<!-- Added for runtime -->
<!-- Added for runtime -->
<!-- dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>
</dependency -->
@ -202,7 +202,7 @@
<dependency>
<groupId>org.directwebremoting</groupId>
<artifactId>dwr</artifactId>
<version>2.0.M2.8</version><!-- Resolved from VIVO repository as not in central; newer causes errors -->
<version>3.0.2-RELEASE</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>

View file

@ -48,6 +48,8 @@
<!--</convert>-->
<convert converter="bean" match="Date"/>
<convert match="java.lang.Exception" converter="exception"/>
<convert match="java.lang.StackTraceElement" converter="bean"/>
</allow>

View file

@ -939,7 +939,7 @@
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<servlet-class>uk.ltd.getahead.dwr.DWRServlet</servlet-class>
<servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>

View file

@ -42,7 +42,7 @@ function monikerInit(){
function update(){ //updates moniker list when type is changed
DWRUtil.useLoadingMessage();
dwr.util.useLoadingMessage();
EntityDWR.monikers(createList, document.getElementById("VClassURI").value );
@ -62,7 +62,7 @@ function createList(data) { //puts options in moniker select list
var opt = new Option("[new moniker]","");
ele.options[ele.options.length] = opt;
DWRUtil.setValue("Moniker",getCurrentMoniker()); // getCurrentMoniker() is defined on jsp
dwr.util.setValue("Moniker",getCurrentMoniker()); // getCurrentMoniker() is defined on jsp
checkMonikers();
}
@ -111,7 +111,7 @@ function fillList(id, data, selectedtext) {
for (var i = 0; i < data.length; i++) {
var text = DWRUtil.toDescriptiveString(data[i]);
var text = dwr.util.toDescriptiveString(data[i]);
var value = text;

View file

@ -1,15 +1,15 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
/* this code uses:
dwrutil in util.js
dwr.util in util.js
vitro.js
detect.js
*/
dojo.require("dojo.io.*");
dojo.require("dojo.event.*");
//DWREngine.setErrorHandler(function(data){alert("DWREngine error: " + data);});
//DWREngine.setWarningHandler(function(data){alert("DWREngine warning: " + data);});
//dwr.engine.setErrorHandler(function(data){alert("dwr.engine error: " + data);});
//dwr.engine.setWarningHandler(function(data){alert("dwr.engine warning: " + data);});
/*
ents_edit.js has several tasks:
@ -68,7 +68,7 @@ function update( ) {
clearProp();
updateTable();
updateEntityAndPropHash();
var but = $("newPropButton");
var but = dwr.util.byId("newPropButton");
if( but ) { but.disabled = false; }
}
@ -78,11 +78,11 @@ function clearProp() {
var clearMap={sunrise:"",sunset: ""};
editingNewProp = false;
gVClassUri = null;
DWRUtil.setValues( clearMap );
clear($("propertyList"));
clear($("vClassList"));
dwr.util.setValues( clearMap );
clear(dwr.util.byId("propertyList"));
clear(dwr.util.byId("vClassList"));
var ele = $("entitiesList");
var ele = dwr.util.byId("entitiesList");
while( ele != null && ele.length > 0){
ele.remove(0);
}
@ -102,7 +102,7 @@ function updateEntityAndPropHash(){
//once we set the gEntity we can get the ents2ents properties.
//PropertyDWR.getAllPropInstByVClass(setPropertyHash, entityObj.VClassURI );
if( entityObj != null && 'URI' in entityObj )
PropertyDWR.getAllPossiblePropInstForIndividual(setPropertyHash, entityObj.URI);
PropertyDWR.getAllPossiblePropInstForIndividual(entityObj.URI, { callback:setPropertyHash });
//else
//alert("could not find an individual, usually this means that there is no type for the URI");
};
@ -126,7 +126,7 @@ function updateEntityAndPropHash(){
};
//get the gEntity and then build the gPropertyHash
EntityDWR.entityByURI(setGEntity, gEntityURI);
EntityDWR.entityByURI(gEntityURI, { callback:setGEntity });
}
/*****************************************************************
@ -139,7 +139,7 @@ function doNoPropsWarning(){
"The button you have clicked adds a new object property statement relating this individual " +
"to another individual. If you are looking to add new object properties to the " +
"system, look under the 'About' menu.");
var but = $("newPropButton");
var but = dwr.util.byId("newPropButton");
if( but ) { but.disabled = true; }
}
@ -149,18 +149,18 @@ because dwr calls are async we have a callback
function updateTable(callback) {
var cb = callback;
function fillTable(props) {
DWRUtil.removeAllRows("propbody");
dwr.util.removeAllRows("propbody");
/* This makes the row that gets added to the ents_edit form for each ents2ents object. */
addRows($("propbody"), props,
addRows(dwr.util.byId("propbody"), props,
[getDomain, getProperty, getRange, getEdit, getDelete],
makeTr);
var newPropTr = $("justwritenTr");
var newPropTr = dwr.util.byId("justwritenTr");
if( newPropTr != null ){
Fat.fade_element( "justwritenTr" );
}
if(cb !== undefined && cb !== null ) { cb(); }
}
PropertyDWR.getExistingProperties(fillTable,gEntityURI);
PropertyDWR.getExistingProperties(gEntityURI, { callback: fillTable });
}
/**************************************************************************/
@ -252,7 +252,7 @@ var makeTr = (function(){ /* outer func */
/* called when Edit button is clicked */
function editTable(inputElement, subjectURI, predicateURI, objectURI){
var rowIndex = inputElement.parentNode.parentNode.rowIndex-1 ;
var table = $("propbody");
var table = dwr.util.byId("propbody");
table.deleteRow( rowIndex );
table.insertRow(rowIndex);
table.rows[rowIndex].insertCell(0);
@ -261,7 +261,7 @@ function editTable(inputElement, subjectURI, predicateURI, objectURI){
table.rows[rowIndex].cells[0].colSpan = tableMaxColspan( table );
vform.style.display="block";
PropertyDWR.getProperty(fillForm, subjectURI, predicateURI, objectURI);
PropertyDWR.getProperty(subjectURI, predicateURI, objectURI, { callback: fillForm });
inputElement.parentNode.parentNode.style.display="none";
}
@ -270,7 +270,7 @@ function deleteProp( subjectURI, predicateURI, objectURI, objectName, predicateN
if( PropertyDWR.deleteProp ){
if (confirm("Are you sure you want to delete the property\n"
+ objectName + " " + predicateName + "?")) {
PropertyDWR.deleteProp(update, subjectURI, predicateURI, objectURI);
PropertyDWR.deleteProp(subjectURI, predicateURI, objectURI, { callback:update });
}
} else {
alert("Deletion of object property statements is disabled.");
@ -312,7 +312,7 @@ function newProp() {
fillForm( newP );
editingNewProp = true;
fillRangeVClassList();
var table = $("propbody");
var table = dwr.util.byId("propbody");
var tr = table.insertRow(0);
tr.id = "newrow";
appendPropForm( tr, tableMaxColspan( table ) );
@ -331,7 +331,7 @@ function fillForm(aprop) {
gProperty = aprop;
var vclass = gProperty.domainClass;
DWRUtil.setValues(gProperty);
dwr.util.setValues(gProperty);
toggleDisabled("newPropButton");
@ -346,7 +346,7 @@ function fillPropList(classId) {
/* This function fills up the form's select list with options
Notice that the option id is the propertyid + 'D' or 'R'
so that domain and range properties can be distinguished */
var propList = $("propertyList");
var propList = dwr.util.byId("propertyList");
clear(propList);
//add properties as options
@ -383,10 +383,10 @@ function fillPropList(classId) {
*****************************************************************/
function fillRangeVClassList( propId ){
//If propId is null then the one on the property select list will be used
if( propId == null ) { propId = DWRUtil.getValue("propertyList");}
if( propId == null ) { propId = dwr.util.getValue("propertyList");}
//clear the list and put the loading message up
var vclassListEle = $("vClassList");
var vclassListEle = dwr.util.byId("vClassList");
clear(vclassListEle);
vclassListEle.options[vclassListEle.options.length] = new Option("Loading...",-10);
//vclassListEle.options[0].selected = true;
@ -394,11 +394,11 @@ function fillRangeVClassList( propId ){
var prop = gPropertyHash[propId];
VClassDWR.getVClasses(
function(vclasses){
addVClassOptions( vclasses );
},
prop.domainClassURI, prop.propertyURI, prop.subjectSide);
VClassDWR.getVClasses(prop.domainClassURI, prop.propertyURI, prop.subjectSide,
function(vclasses){
addVClassOptions( vclasses );
}
);
}
/****************************************************************
@ -406,14 +406,14 @@ function fillRangeVClassList( propId ){
the entitiesList.
****************************************************************/
function addVClassOptions( vclassArray ){
// DWRUtil.addOptions("entitiesList",null);
var vclassEle = $("vClassList");
// dwr.util.addOptions("entitiesList",null);
var vclassEle = dwr.util.byId("vClassList");
clear( vclassEle );
vclassEle.disabled = false;
if( vclassArray == null || vclassArray.length < 1){
vclassEle.disabled = true;
entsEle = $("entitiesList");
entsEle = dwr.util.byId("entitiesList");
clear(entsEle);
var msg="There are no entities defined yet that could fill this role";
var opt = new Option(msg,-1);
@ -435,15 +435,15 @@ function addVClassOptions( vclassArray ){
//attempt to set the selected option to the current vclass
var vclassURI = null;
var prop = gPropertyHash[ DWRUtil.getValue("propertyList") ];
var prop = gPropertyHash[ dwr.util.getValue("propertyList") ];
if( gProperty.propertyURI == prop.propertyURI ){
vclassURI = gProperty.rangeClassURI;
DWRUtil.setValue(vclassEle, vclassURI );
dwr.util.setValue(vclassEle, vclassURI );
//here we were unable to set the vclass select option to the vclassid
//of the entity. this means that the vclass of the entity is not one that
//is permited by the PropertyInheritance and other restrictions.
if( DWRUtil.getValue(vclassEle) != vclassURI){
if( dwr.util.getValue(vclassEle) != vclassURI){
alert("This entity's class does not match the class of this property. This is usually the "+
"result of the class of the entity having been changed. Properties that were added when " +
"this entity had the old class still reflect that value.\n" +
@ -461,15 +461,15 @@ function addVClassOptions( vclassArray ){
*****************************************************************/
function fillEntsList( vclassEle ){
if( vclassEle == null )
vclassEle = $("vClassList");
var vclassUri = DWRUtil.getValue( vclassEle );
vclassEle = dwr.util.byId("vClassList");
var vclassUri = dwr.util.getValue( vclassEle );
if( vclassUri == gVClassUri )
return;
else
gVClassUri = vclassUri;
var entsListEle = $("entitiesList");
var entsListEle = dwr.util.byId("entitiesList");
clear(entsListEle);
entityOptToSelect = null;
@ -494,7 +494,7 @@ function fillEntsList( vclassEle ){
},
load: function(type, data, evt){
//clear here since we will be using addEntOptions for multiple adds
// var entsListEle = $("entitiesList");
// var entsListEle = dwr.util.byId("entitiesList");
// clear(entsListEle);
addEntOptions(data, -1);
},
@ -509,7 +509,7 @@ function fillEntsList( vclassEle ){
/** add entities in entArray as options elements to select element "Individual" */
function addEntOptions( entArray ){
var entsListEle = $("entitiesList");
var entsListEle = dwr.util.byId("entitiesList");
if( entArray == null || entArray.length == 0){
clear(entsListEle);
@ -623,12 +623,12 @@ function writeProp() {
return;
}
if( !validateForm() ) { return; }
var prop = gPropertyHash[DWRUtil.getValue("propertyList")];
var prop = gPropertyHash[dwr.util.getValue("propertyList")];
var newP = {};
var oldP = gProperty;
newP.propertyURI = prop.propertyURI;
var selected = DWRUtil.getValue("entitiesList");
var selected = dwr.util.getValue("entitiesList");
newP.subjectEntURI= gEntity.URI;
newP.objectEntURI = selected ;
@ -639,16 +639,17 @@ function writeProp() {
if( editingNewProp ){
newP.ents2entsId = -1;
PropertyDWR.insertProp(callback, newP );
PropertyDWR.insertProp(newP, { callback:callback } );
} else {
var afterDelete=
function(result){
PropertyDWR.insertProp(callback, newP);
PropertyDWR.insertProp(newP, { callback:callback });
};
PropertyDWR.deleteProp(afterDelete,
PropertyDWR.deleteProp(
gProperty.subjectEntURI,
gProperty.propertyURI,
gProperty.objectEntURI);
gProperty.objectEntURI,
{ callback:afterDelete });
}
}
@ -657,10 +658,10 @@ addEvent(window, 'load', update);
/********************* some utilities ***********************************/
/* this clones the property edit from a div on the ents_edit.jsp */
function getForm(){ return $("propeditdiv").cloneNode(true); }
function getForm(){ return dwr.util.byId("propeditdiv").cloneNode(true); }
/* a function to display a lot of info about an object */
function disy( obj, note ){ alert( (note!==null?note:"") + DWRUtil.toDescriptiveString(obj, 3));}
function disy( obj, note ){ alert( (note!==null?note:"") + dwr.util.toDescriptiveString(obj, 3));}
/* attempts to get the URI of the entity being edited */
function getEntityUriFromPage(){

View file

@ -30,7 +30,7 @@ function init(){
function update(){ //updates moniker list when type is changed
DWRUtil.useLoadingMessage();
dwr.util.useLoadingMessage();
EntityDWR.monikers(createList, document.getElementById("field2Value").value );
@ -50,7 +50,7 @@ function createList(data) { //puts options in moniker select list
var opt = new Option("[new moniker]","");
ele.options[ele.options.length] = opt;
DWRUtil.setValue("monikerSelect",getCurrentMoniker()); // getCurrentMoniker() is defined on jsp
dwr.util.setValue("monikerSelect",getCurrentMoniker()); // getCurrentMoniker() is defined on jsp
checkMonikers();
}
@ -96,7 +96,7 @@ function fillList(id, data, selectedtext) {
for (var i = 0; i < data.length; i++) {
var text = DWRUtil.toDescriptiveString(data[i]);
var text = dwr.util.toDescriptiveString(data[i]);
var value = text;

View file

@ -54,7 +54,7 @@ function encodeUrl(pstrString) {
*/
function addRows(ele, data, cellFuncs, rowFunc) {
var frag = document.createDocumentFragment();
if (DWRUtil._isArray(data)) {
if (dwr.util._isArray(data)) {
for (var i = 0; i < data.length; i++) {
frag.appendChild( makeRow( data[i], cellFuncs, rowFunc) );
}
@ -77,9 +77,9 @@ function makeRow( row, cellFuncs, rowFunc){
var func = cellFuncs[j]
var td
var reply = func(row)
if (DWRUtil._isHTMLElement(reply, "td")) {
if (dwr.util._isHTMLElement(reply, "td")) {
td = reply;
} else if (DWRUtil._isHTMLElement(reply, "a")) {
} else if (dwr.util._isHTMLElement(reply, "a")) {
td = document.createElement("td");
td.appendChild( reply );
} else {
@ -91,7 +91,7 @@ function makeRow( row, cellFuncs, rowFunc){
return tr;
}
/** added this from the DWRUtil.js */
/** added this from the dwr.util.js */
isDate = function(data) {
return (data && data.toUTCString) ? true : false;
};
@ -147,8 +147,8 @@ function date2iso8601( jdate ){
function setDateValue(ele, date, date2StrFunc){
if( date == null || ! isDate(date)) { return; }
if( date2StrFunc == null ) { date2StrFunc = date2iso8601; }
ele = $(ele);
DWRUtil.setValue(ele, date2StrFunc( date ));
ele = dwr.util.byId(ele);
dwr.util.setValue(ele, date2StrFunc( date ));
}
/* removes all children and if it can, removes options */
@ -160,7 +160,7 @@ function clear(ele){
}
function hideElementById(eleId){
var ele = $(eleId);
var ele = dwr.util.byId(eleId);
if( ele != null ){ ele.style.display="none"; }
}
@ -168,7 +168,7 @@ function makeEntLinkElement(entityURI, text){
link = document.createElement("a");
link.href = "entityEdit?uri=" + encodeUrl(entityURI);
link.innerHTML = text;
//DWRUtil.setValue(link, "test" + text);
//dwr.util.setValue(link, "test" + text);
return link;
}
@ -375,7 +375,7 @@ function adjustIFrameSize(id) {
}
function toggleDisabled(ele){
ele = $(ele);
ele = dwr.util.byId(ele);
if(ele == null) {return;}
ele.disabled = !ele.disabled ;
}
@ -403,16 +403,16 @@ and returns a value for use in the select option value.
textFun is a function that takes one parameter, an object,
and returns a value for use in the select option text.
This is based on the code in DWRUtil but lacks the error checking.
This is based on the code in dwr.util but lacks the error checking.
*/
addOptions = function(ele, data, valueFunc, textFunc) {
var orig = ele;
ele = $(ele);
ele = dwr.util.byId(ele);
if (ele == null) {
DWRUtil.debug("addOptions() can't find an element with id: " + orig + ".");
dwr.util.debug("addOptions() can't find an element with id: " + orig + ".");
return;
}
var useOptions = DWRUtil._isHTMLElement(ele, "select");
var useOptions = dwr.util._isHTMLElement(ele, "select");
if (data == null) return;
var text;

View file

@ -12,19 +12,23 @@ String context = request.getContextPath();
if (!(Boolean)request.getAttribute("dwrDisabled")) {
%>
<script type="text/javascript">
// DWR 3 is a better citizen for co-existing with jQuery.
// All of the ents_edit.js and vitro.js have been updated so that $(..) references use the dwr.util method directly
// As such, it should be possible to avoid the noConflict() mode.
// This then prevents a few errors that would otherwise occur in jQuery expecting JS on the same page
// relinquish jQuery's control of the $ variable to avoid conflicts with DWR
jQuery.noConflict();
// jQuery.noConflict();
</script>
<script type="text/javascript" xml:space="preserve">
var gEntityURI="${entity.URI}";
</script> <!-- There has got to be a better way to pass this to the js -->
<script type="text/javascript" src="<%=context%>/dwr/engine.js"></script>
<script type="text/javascript" src="<%=context%>/dwr/util.js"></script>
<script type="text/javascript" src="<%=context%>/dwr/interface/PropertyDWR.js"></script>
<script type="text/javascript" src="<%=context%>/dwr/interface/EntityDWR.js"></script>
<script type="text/javascript" src="<%=context%>/dwr/interface/VClassDWR.js"></script>
<script type="text/javascript" src="<%=context%>/dwr/engine.js"></script>
<script type="text/javascript" src="<%=context%>/dwr/util.js"></script>
<script type="text/javascript" src="<%=context%>/js/betterDateInput.js"></script>
<script type="text/javascript" src="<%=context%>/js/vitro.js"></script>
<script type="text/javascript" src="<%=context%>/dojo.js"></script>