I'm making a method that when a person's name on a website is clicked, a request is triggered by using angularJS. The request should send the name as a string to the backend part of the app, that connects to an LDAP and extracts the info about the person using JSONobjects and then sends them back to the frontend part. I'm sure everything works because i tested it, the only problem i have is that i dont know how to pass the String value of the persons name to the backend request for the method. Here is the JS code that is triggered when the person's name is clicked:
var personApp = angular.module('personApp', [ 'ngRoute', 'ngCookies' ]);
personApp.controller('PersonController', function($scope, $http) {
$scope.showPerson = function(name){
$scope.name = name;
$http({
method : "POST",
url : "AMPServlet",
params : {
parameterType : "personName",
name:name
}
}).success(function(response) {
$scope.personLDAP = response.person;
console.log(response);
});
};
And here is the code of the servlet that calls the LDAP method and returns the info back to the JS part and then the front.
case "personName": {
log.info("primljen request za dohvacanje informacija o dezurnim osobama");
PersonADInfo info = new PersonADInfo();
try {
info = ldapAuthenticationServiceAccess.retrievePersonADInfo(session.getAttribute("ng-click").toString());
} catch (NullPointerException e) {
e.printStackTrace();
log.error(e);
}
jsonObject = new JSONObject();
tmpJSONObject = new JSONObject();
try {
tmpJSONObject = new JSONObject();
tmpJSONObject.put("name", info.getName());
tmpJSONObject.put("email", info.getEmail());
tmpJSONObject.put("department", info.getDepartment());
tmpJSONObject.put("workplace", info.getWorkplace());
tmpJSONObject.put("phone", info.getPhone());
tmpJSONObject.put("mobile", info.getMobile());
tmpJSONObject.put("vpn", info.getVPN());
tmpJSONObject.put("mobilevpn", info.getMobileVPN());
jsonObject.put("person", tmpJSONObject);
} catch (JSONException e) {
e.printStackTrace();
e.getMessage();
log.error(e.getStackTrace());
}
writer.println(jsonObject.toString());
}
break;
The part i need help with is this line of code:
info = ldapAuthenticationServiceAccess.retrievePersonADInfo(session.getAttribute("ng-click").toString());
To be exact, i'm unsure of what to put inside od getAttribute() to get the name of the person to be given to the method as a parameter. Any help is appreciated, thanks!