support display of client data in tab with ajax fetch of data.
This commit is contained in:
@@ -4,16 +4,13 @@ import java.io.Serializable;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
|
||||||
|
|
||||||
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
|
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
|
||||||
import org.codehaus.jackson.map.annotate.JsonFilter;
|
import org.codehaus.jackson.map.annotate.JsonFilter;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.joda.time.Days;
|
import org.joda.time.Days;
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
|
|
||||||
@XmlRootElement(name = "client")
|
@JsonIgnoreProperties({ "organisationId","organisationName"})
|
||||||
@JsonIgnoreProperties({ "organisationId", "organisationName" })
|
|
||||||
@JsonFilter("myFilter")
|
@JsonFilter("myFilter")
|
||||||
public class ClientData implements Serializable {
|
public class ClientData implements Serializable {
|
||||||
|
|
||||||
|
|||||||
+17
-1
@@ -64,7 +64,23 @@ $(document).ready(function() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
globalDate: function(localDateAsISOString) {
|
globalDate: function(dateParts) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
var year = dateParts[0];
|
||||||
|
var month = parseInt(dateParts[1]) - 1; // month is zero indexed
|
||||||
|
var day = dateParts[2];
|
||||||
|
|
||||||
|
var d = new Date();
|
||||||
|
d.setFullYear(year,month,day);
|
||||||
|
|
||||||
|
return Globalize.format(d,"dd MMMM yyyy");
|
||||||
|
} catch(e) {
|
||||||
|
return "??";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
globalDateAsISOString: function(localDateAsISOString) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var dateParts = localDateAsISOString.split("-")
|
var dateParts = localDateAsISOString.split("-")
|
||||||
var year = dateParts[0];
|
var year = dateParts[0];
|
||||||
|
|||||||
@@ -56,7 +56,23 @@ $(document).ready(function() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
globalDate: function(localDateAsISOString) {
|
globalDate: function(dateParts) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
var year = dateParts[0];
|
||||||
|
var month = parseInt(dateParts[1]) - 1; // month is zero indexed
|
||||||
|
var day = dateParts[2];
|
||||||
|
|
||||||
|
var d = new Date();
|
||||||
|
d.setFullYear(year,month,day);
|
||||||
|
|
||||||
|
return Globalize.format(d,"dd MMMM yyyy");
|
||||||
|
} catch(e) {
|
||||||
|
return "??";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
globalDateAsISOString: function(localDateAsISOString) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var dateParts = localDateAsISOString.split("-")
|
var dateParts = localDateAsISOString.split("-")
|
||||||
var year = dateParts[0];
|
var year = dateParts[0];
|
||||||
@@ -292,24 +308,52 @@ $(document).ready(function() {
|
|||||||
"ajaxOptions": {
|
"ajaxOptions": {
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
contentType: 'application/json',
|
contentType: 'application/json; charset=utf-8',
|
||||||
cache: false,
|
cache: false,
|
||||||
beforeSend: function(xhr) {
|
beforeSend: function(xhr) {
|
||||||
|
console.log("before send");
|
||||||
xhr.setRequestHeader("Authorization", "Basic " + base64);
|
xhr.setRequestHeader("Authorization", "Basic " + base64);
|
||||||
},
|
},
|
||||||
|
success: function(data, status, xhr) {
|
||||||
|
},
|
||||||
error: function(xhr, status, index, anchor) {
|
error: function(xhr, status, index, anchor) {
|
||||||
$(anchor.hash).html("error occured while ajax loading.");
|
$(anchor.hash).html("error occured while ajax loading.");
|
||||||
},
|
|
||||||
success: function(data, status, xhr) {
|
|
||||||
var clientObject = new Object();
|
|
||||||
clientObject.clients = data;
|
|
||||||
var tableHtml = $("#clientSearchTabTemplate").render(clientObject);
|
|
||||||
$("#searchtab").html(tableHtml);
|
|
||||||
|
|
||||||
$('#client').change(function() {
|
|
||||||
$('#viewClient').submit();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
select: function(event, ui) {
|
||||||
|
console.log("selected..");
|
||||||
|
},
|
||||||
|
load: function(event, ui) {
|
||||||
|
console.log("load..");
|
||||||
|
},
|
||||||
|
show: function(event, ui) {
|
||||||
|
console.log("show..");
|
||||||
|
|
||||||
|
var jqxhr = $.ajax({
|
||||||
|
url: baseApiUrl + 'clients',
|
||||||
|
type: 'GET',
|
||||||
|
contentType: 'application/json',
|
||||||
|
dataType: 'json',
|
||||||
|
cache: false,
|
||||||
|
beforeSend: function(xhr) {
|
||||||
|
xhr.setRequestHeader("Authorization", "Basic " + base64);
|
||||||
|
},
|
||||||
|
success: function(data) {
|
||||||
|
var clientObject = new Object();
|
||||||
|
clientObject.clients = data;
|
||||||
|
console.log(clientObject);
|
||||||
|
|
||||||
|
var tableHtml = $("#clientSearchTabTemplate").render(clientObject);
|
||||||
|
$("#searchtab").html(tableHtml);
|
||||||
|
|
||||||
|
$('#client').change(function() {
|
||||||
|
$('#viewClient').submit();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
error: function(jqXHR, textStatus, errorThrown) {
|
||||||
|
handleXhrError(jqXHR, textStatus, errorThrown, "#formErrorsTemplate", "#formerrors");
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -346,7 +390,7 @@ $(document).ready(function() {
|
|||||||
</sec:authorize>
|
</sec:authorize>
|
||||||
<div id="tabs">
|
<div id="tabs">
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="${baseApiUrl}clients" title="searchtab"><spring:message code="tab.search"/></a></li>
|
<li><a href="#searchtab" title="searchtab"><spring:message code="tab.search"/></a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<div id="searchtab"></div>
|
<div id="searchtab"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user