how to fix the java script function that it get a json parameters and send it to the url
I have a java program for coupon system and one of the methods is to update company details the code in java:
public Company updateCompanyDetailes(Company companyToUpDate) throws CustomException {
Company companyFromDb = companyRpository.findById(companyToUpDate.getId()).get();
companyFromDb.setPassword(companyToUpDate.getPassword());
companyFromDb.setEmail(companyToUpDate.getEmail());
companyToUpDate = companyRpository.save(companyFromDb);
return companyToUpDate;
}
It works great but when i want to call this method from my HTML page the javascript is crashing all the time and not transfer the company details as an object,
$scope.companyToUpDate = function() {
$scope.hideAll();
$scope.UpdateComp = true;
$scope.executeForCompany = function() {
if ($scope.id == '') {
window.alert("You must enter ID")
}else {
alert("do you want update company?");
var id = $scope.id;
var password = $scope.password;
var email = $scope.email;
var company = {
companyId: id,
email: email,
password: password
};
$http.put('http://localhost:8999/rest/api/admin/updateCompany', company)
.then(function (response){
window.alert('updated');
// $scope.id = '';
//$scope.password = '';
// $scope.email= '';
$scope.hideAll();
$scope.WelcomePage =true;
}, function(error) {
alert('operation failed' + error.data);
});
}
}
}
As I try is rest when I send aJASON with the parameters id
, password
, and this is the HTML code:
<div class="col-md-9" ng-show="UpdateComp">
<h2>choose company id to update:</h2>
<input type="number" ng-model="id" min="1">ID</input>
<h4>fill the fields (Password is mandatory):</h4>
* Password<input type="text" ng-model="password">
</input>
Email<input
type="text" ng-model="email"></input>
<button type="button" class="btn btn-primary"
ng-click="executeForCompany()">UPD</button>
<div ng-show="UpdateComp" ng-model="company">
</div>
</div>
i am getting the companyId
from the user, all the Javascript are working beside this one
i get this error:
java.lang.IllegalArgumentException: The given id must not be null
javascript java html
New contributor
add a comment |
I have a java program for coupon system and one of the methods is to update company details the code in java:
public Company updateCompanyDetailes(Company companyToUpDate) throws CustomException {
Company companyFromDb = companyRpository.findById(companyToUpDate.getId()).get();
companyFromDb.setPassword(companyToUpDate.getPassword());
companyFromDb.setEmail(companyToUpDate.getEmail());
companyToUpDate = companyRpository.save(companyFromDb);
return companyToUpDate;
}
It works great but when i want to call this method from my HTML page the javascript is crashing all the time and not transfer the company details as an object,
$scope.companyToUpDate = function() {
$scope.hideAll();
$scope.UpdateComp = true;
$scope.executeForCompany = function() {
if ($scope.id == '') {
window.alert("You must enter ID")
}else {
alert("do you want update company?");
var id = $scope.id;
var password = $scope.password;
var email = $scope.email;
var company = {
companyId: id,
email: email,
password: password
};
$http.put('http://localhost:8999/rest/api/admin/updateCompany', company)
.then(function (response){
window.alert('updated');
// $scope.id = '';
//$scope.password = '';
// $scope.email= '';
$scope.hideAll();
$scope.WelcomePage =true;
}, function(error) {
alert('operation failed' + error.data);
});
}
}
}
As I try is rest when I send aJASON with the parameters id
, password
, and this is the HTML code:
<div class="col-md-9" ng-show="UpdateComp">
<h2>choose company id to update:</h2>
<input type="number" ng-model="id" min="1">ID</input>
<h4>fill the fields (Password is mandatory):</h4>
* Password<input type="text" ng-model="password">
</input>
Email<input
type="text" ng-model="email"></input>
<button type="button" class="btn btn-primary"
ng-click="executeForCompany()">UPD</button>
<div ng-show="UpdateComp" ng-model="company">
</div>
</div>
i am getting the companyId
from the user, all the Javascript are working beside this one
i get this error:
java.lang.IllegalArgumentException: The given id must not be null
javascript java html
New contributor
Please check theconsole
for any errors
– Hp_issei
yesterday
java.lang.IllegalArgumentException: The given id must not be null! this is the error that i get all the time buy i give those 3 parameters
– hvtmoshe
yesterday
So while sending data from the js your id value is not binding.Check for $scope.id
– Hp_issei
yesterday
You're sending the id ascompanyId
in yourcompany
object in javascript. In java you're callinggetId()
which usually means you're getting the variableid
, and notcompanyId
are you sure you're mapping those correctly?
– Mark
yesterday
yes i try it in the id and i try it as companyId i didn't find my error in this code in Javascript, when i work with rest PUT and send a body it work fine
– hvtmoshe
yesterday
add a comment |
I have a java program for coupon system and one of the methods is to update company details the code in java:
public Company updateCompanyDetailes(Company companyToUpDate) throws CustomException {
Company companyFromDb = companyRpository.findById(companyToUpDate.getId()).get();
companyFromDb.setPassword(companyToUpDate.getPassword());
companyFromDb.setEmail(companyToUpDate.getEmail());
companyToUpDate = companyRpository.save(companyFromDb);
return companyToUpDate;
}
It works great but when i want to call this method from my HTML page the javascript is crashing all the time and not transfer the company details as an object,
$scope.companyToUpDate = function() {
$scope.hideAll();
$scope.UpdateComp = true;
$scope.executeForCompany = function() {
if ($scope.id == '') {
window.alert("You must enter ID")
}else {
alert("do you want update company?");
var id = $scope.id;
var password = $scope.password;
var email = $scope.email;
var company = {
companyId: id,
email: email,
password: password
};
$http.put('http://localhost:8999/rest/api/admin/updateCompany', company)
.then(function (response){
window.alert('updated');
// $scope.id = '';
//$scope.password = '';
// $scope.email= '';
$scope.hideAll();
$scope.WelcomePage =true;
}, function(error) {
alert('operation failed' + error.data);
});
}
}
}
As I try is rest when I send aJASON with the parameters id
, password
, and this is the HTML code:
<div class="col-md-9" ng-show="UpdateComp">
<h2>choose company id to update:</h2>
<input type="number" ng-model="id" min="1">ID</input>
<h4>fill the fields (Password is mandatory):</h4>
* Password<input type="text" ng-model="password">
</input>
Email<input
type="text" ng-model="email"></input>
<button type="button" class="btn btn-primary"
ng-click="executeForCompany()">UPD</button>
<div ng-show="UpdateComp" ng-model="company">
</div>
</div>
i am getting the companyId
from the user, all the Javascript are working beside this one
i get this error:
java.lang.IllegalArgumentException: The given id must not be null
javascript java html
New contributor
I have a java program for coupon system and one of the methods is to update company details the code in java:
public Company updateCompanyDetailes(Company companyToUpDate) throws CustomException {
Company companyFromDb = companyRpository.findById(companyToUpDate.getId()).get();
companyFromDb.setPassword(companyToUpDate.getPassword());
companyFromDb.setEmail(companyToUpDate.getEmail());
companyToUpDate = companyRpository.save(companyFromDb);
return companyToUpDate;
}
It works great but when i want to call this method from my HTML page the javascript is crashing all the time and not transfer the company details as an object,
$scope.companyToUpDate = function() {
$scope.hideAll();
$scope.UpdateComp = true;
$scope.executeForCompany = function() {
if ($scope.id == '') {
window.alert("You must enter ID")
}else {
alert("do you want update company?");
var id = $scope.id;
var password = $scope.password;
var email = $scope.email;
var company = {
companyId: id,
email: email,
password: password
};
$http.put('http://localhost:8999/rest/api/admin/updateCompany', company)
.then(function (response){
window.alert('updated');
// $scope.id = '';
//$scope.password = '';
// $scope.email= '';
$scope.hideAll();
$scope.WelcomePage =true;
}, function(error) {
alert('operation failed' + error.data);
});
}
}
}
As I try is rest when I send aJASON with the parameters id
, password
, and this is the HTML code:
<div class="col-md-9" ng-show="UpdateComp">
<h2>choose company id to update:</h2>
<input type="number" ng-model="id" min="1">ID</input>
<h4>fill the fields (Password is mandatory):</h4>
* Password<input type="text" ng-model="password">
</input>
Email<input
type="text" ng-model="email"></input>
<button type="button" class="btn btn-primary"
ng-click="executeForCompany()">UPD</button>
<div ng-show="UpdateComp" ng-model="company">
</div>
</div>
i am getting the companyId
from the user, all the Javascript are working beside this one
i get this error:
java.lang.IllegalArgumentException: The given id must not be null
javascript java html
javascript java html
New contributor
New contributor
edited yesterday
Thelouras
3671314
3671314
New contributor
asked yesterday
hvtmoshe
12
12
New contributor
New contributor
Please check theconsole
for any errors
– Hp_issei
yesterday
java.lang.IllegalArgumentException: The given id must not be null! this is the error that i get all the time buy i give those 3 parameters
– hvtmoshe
yesterday
So while sending data from the js your id value is not binding.Check for $scope.id
– Hp_issei
yesterday
You're sending the id ascompanyId
in yourcompany
object in javascript. In java you're callinggetId()
which usually means you're getting the variableid
, and notcompanyId
are you sure you're mapping those correctly?
– Mark
yesterday
yes i try it in the id and i try it as companyId i didn't find my error in this code in Javascript, when i work with rest PUT and send a body it work fine
– hvtmoshe
yesterday
add a comment |
Please check theconsole
for any errors
– Hp_issei
yesterday
java.lang.IllegalArgumentException: The given id must not be null! this is the error that i get all the time buy i give those 3 parameters
– hvtmoshe
yesterday
So while sending data from the js your id value is not binding.Check for $scope.id
– Hp_issei
yesterday
You're sending the id ascompanyId
in yourcompany
object in javascript. In java you're callinggetId()
which usually means you're getting the variableid
, and notcompanyId
are you sure you're mapping those correctly?
– Mark
yesterday
yes i try it in the id and i try it as companyId i didn't find my error in this code in Javascript, when i work with rest PUT and send a body it work fine
– hvtmoshe
yesterday
Please check the
console
for any errors– Hp_issei
yesterday
Please check the
console
for any errors– Hp_issei
yesterday
java.lang.IllegalArgumentException: The given id must not be null! this is the error that i get all the time buy i give those 3 parameters
– hvtmoshe
yesterday
java.lang.IllegalArgumentException: The given id must not be null! this is the error that i get all the time buy i give those 3 parameters
– hvtmoshe
yesterday
So while sending data from the js your id value is not binding.Check for $scope.id
– Hp_issei
yesterday
So while sending data from the js your id value is not binding.Check for $scope.id
– Hp_issei
yesterday
You're sending the id as
companyId
in your company
object in javascript. In java you're calling getId()
which usually means you're getting the variable id
, and not companyId
are you sure you're mapping those correctly?– Mark
yesterday
You're sending the id as
companyId
in your company
object in javascript. In java you're calling getId()
which usually means you're getting the variable id
, and not companyId
are you sure you're mapping those correctly?– Mark
yesterday
yes i try it in the id and i try it as companyId i didn't find my error in this code in Javascript, when i work with rest PUT and send a body it work fine
– hvtmoshe
yesterday
yes i try it in the id and i try it as companyId i didn't find my error in this code in Javascript, when i work with rest PUT and send a body it work fine
– hvtmoshe
yesterday
add a comment |
1 Answer
1
active
oldest
votes
When you pass data in json from javascript and are catching that json in a Object(Company) then you need to be careful that the keys are the same as defined in class level.
There is an error for id, check that are you getting you data here
var id = $scope.id;
var password = $scope.password;
var email = $scope.email;
by printing or any means you use.
Also in $http.put('http://localhost:8999/rest/api/admin/updateCompany', company)
you passing object named company but receiving it as companyToUpDate
make them same.
New contributor
thank you finally it works
– hvtmoshe
yesterday
Always our pleasure :)
– ThunderMind
yesterday
1
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker.
– leftjoin
yesterday
ok, thanks for the direction
– ThunderMind
yesterday
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
hvtmoshe is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53943492%2fhow-to-fix-the-java-script-function-that-it-get-a-json-parameters-and-send-it-to%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
When you pass data in json from javascript and are catching that json in a Object(Company) then you need to be careful that the keys are the same as defined in class level.
There is an error for id, check that are you getting you data here
var id = $scope.id;
var password = $scope.password;
var email = $scope.email;
by printing or any means you use.
Also in $http.put('http://localhost:8999/rest/api/admin/updateCompany', company)
you passing object named company but receiving it as companyToUpDate
make them same.
New contributor
thank you finally it works
– hvtmoshe
yesterday
Always our pleasure :)
– ThunderMind
yesterday
1
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker.
– leftjoin
yesterday
ok, thanks for the direction
– ThunderMind
yesterday
add a comment |
When you pass data in json from javascript and are catching that json in a Object(Company) then you need to be careful that the keys are the same as defined in class level.
There is an error for id, check that are you getting you data here
var id = $scope.id;
var password = $scope.password;
var email = $scope.email;
by printing or any means you use.
Also in $http.put('http://localhost:8999/rest/api/admin/updateCompany', company)
you passing object named company but receiving it as companyToUpDate
make them same.
New contributor
thank you finally it works
– hvtmoshe
yesterday
Always our pleasure :)
– ThunderMind
yesterday
1
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker.
– leftjoin
yesterday
ok, thanks for the direction
– ThunderMind
yesterday
add a comment |
When you pass data in json from javascript and are catching that json in a Object(Company) then you need to be careful that the keys are the same as defined in class level.
There is an error for id, check that are you getting you data here
var id = $scope.id;
var password = $scope.password;
var email = $scope.email;
by printing or any means you use.
Also in $http.put('http://localhost:8999/rest/api/admin/updateCompany', company)
you passing object named company but receiving it as companyToUpDate
make them same.
New contributor
When you pass data in json from javascript and are catching that json in a Object(Company) then you need to be careful that the keys are the same as defined in class level.
There is an error for id, check that are you getting you data here
var id = $scope.id;
var password = $scope.password;
var email = $scope.email;
by printing or any means you use.
Also in $http.put('http://localhost:8999/rest/api/admin/updateCompany', company)
you passing object named company but receiving it as companyToUpDate
make them same.
New contributor
edited yesterday
Bhargav Rao♦
30.1k2087110
30.1k2087110
New contributor
answered yesterday
ThunderMind
816
816
New contributor
New contributor
thank you finally it works
– hvtmoshe
yesterday
Always our pleasure :)
– ThunderMind
yesterday
1
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker.
– leftjoin
yesterday
ok, thanks for the direction
– ThunderMind
yesterday
add a comment |
thank you finally it works
– hvtmoshe
yesterday
Always our pleasure :)
– ThunderMind
yesterday
1
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker.
– leftjoin
yesterday
ok, thanks for the direction
– ThunderMind
yesterday
thank you finally it works
– hvtmoshe
yesterday
thank you finally it works
– hvtmoshe
yesterday
Always our pleasure :)
– ThunderMind
yesterday
Always our pleasure :)
– ThunderMind
yesterday
1
1
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker.
– leftjoin
yesterday
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker.
– leftjoin
yesterday
ok, thanks for the direction
– ThunderMind
yesterday
ok, thanks for the direction
– ThunderMind
yesterday
add a comment |
hvtmoshe is a new contributor. Be nice, and check out our Code of Conduct.
hvtmoshe is a new contributor. Be nice, and check out our Code of Conduct.
hvtmoshe is a new contributor. Be nice, and check out our Code of Conduct.
hvtmoshe is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53943492%2fhow-to-fix-the-java-script-function-that-it-get-a-json-parameters-and-send-it-to%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Please check the
console
for any errors– Hp_issei
yesterday
java.lang.IllegalArgumentException: The given id must not be null! this is the error that i get all the time buy i give those 3 parameters
– hvtmoshe
yesterday
So while sending data from the js your id value is not binding.Check for $scope.id
– Hp_issei
yesterday
You're sending the id as
companyId
in yourcompany
object in javascript. In java you're callinggetId()
which usually means you're getting the variableid
, and notcompanyId
are you sure you're mapping those correctly?– Mark
yesterday
yes i try it in the id and i try it as companyId i didn't find my error in this code in Javascript, when i work with rest PUT and send a body it work fine
– hvtmoshe
yesterday