How to set B2B Unit in session (Hybris)?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
How can I set B2B Unit in session. I have facade class which implements logic to set units in session (ex. When one user is login in storefront give me his units and set these units in session). This is my method in custom class which extedns DefaultCustomerFacade.class
@Override
public void loginSuccess()
Set<B2BUnitModel> allUserGroupsForUser = getUserService().getAllUserGroupsForUser(getCurrentUser(), B2BUnitModel.class);
List<String> b2bunitIds = allUserGroupsForUser.stream()
.map(B2BUnitModel::getName)
.collect(Collectors.toList());
if(!allUserGroupsForUser.isEmpty())
getSessionService().setAttribute("availableB2BUnits", b2bunitIds);
super.loginSuccess();
Then in storefront, I showed in select tag in jsp, drop-down with these units. Ok, so I have attribute now with these units which is in session and I want when I click for some B2B Unit, this one unit to set in session. I think, I shoud do some controller to implement logic ( set currentUnit in session ) and in one js file to make some ajax call with some method onChange, or some ajax api, but I don't know how to do this. Can someone help me, i am new in hybris and I will be glad if someone help me
java hybris
add a comment |
How can I set B2B Unit in session. I have facade class which implements logic to set units in session (ex. When one user is login in storefront give me his units and set these units in session). This is my method in custom class which extedns DefaultCustomerFacade.class
@Override
public void loginSuccess()
Set<B2BUnitModel> allUserGroupsForUser = getUserService().getAllUserGroupsForUser(getCurrentUser(), B2BUnitModel.class);
List<String> b2bunitIds = allUserGroupsForUser.stream()
.map(B2BUnitModel::getName)
.collect(Collectors.toList());
if(!allUserGroupsForUser.isEmpty())
getSessionService().setAttribute("availableB2BUnits", b2bunitIds);
super.loginSuccess();
Then in storefront, I showed in select tag in jsp, drop-down with these units. Ok, so I have attribute now with these units which is in session and I want when I click for some B2B Unit, this one unit to set in session. I think, I shoud do some controller to implement logic ( set currentUnit in session ) and in one js file to make some ajax call with some method onChange, or some ajax api, but I don't know how to do this. Can someone help me, i am new in hybris and I will be glad if someone help me
java hybris
Please see: Why is “Can someone help me?” not an actual question?
– Progman
Nov 15 '18 at 13:43
add a comment |
How can I set B2B Unit in session. I have facade class which implements logic to set units in session (ex. When one user is login in storefront give me his units and set these units in session). This is my method in custom class which extedns DefaultCustomerFacade.class
@Override
public void loginSuccess()
Set<B2BUnitModel> allUserGroupsForUser = getUserService().getAllUserGroupsForUser(getCurrentUser(), B2BUnitModel.class);
List<String> b2bunitIds = allUserGroupsForUser.stream()
.map(B2BUnitModel::getName)
.collect(Collectors.toList());
if(!allUserGroupsForUser.isEmpty())
getSessionService().setAttribute("availableB2BUnits", b2bunitIds);
super.loginSuccess();
Then in storefront, I showed in select tag in jsp, drop-down with these units. Ok, so I have attribute now with these units which is in session and I want when I click for some B2B Unit, this one unit to set in session. I think, I shoud do some controller to implement logic ( set currentUnit in session ) and in one js file to make some ajax call with some method onChange, or some ajax api, but I don't know how to do this. Can someone help me, i am new in hybris and I will be glad if someone help me
java hybris
How can I set B2B Unit in session. I have facade class which implements logic to set units in session (ex. When one user is login in storefront give me his units and set these units in session). This is my method in custom class which extedns DefaultCustomerFacade.class
@Override
public void loginSuccess()
Set<B2BUnitModel> allUserGroupsForUser = getUserService().getAllUserGroupsForUser(getCurrentUser(), B2BUnitModel.class);
List<String> b2bunitIds = allUserGroupsForUser.stream()
.map(B2BUnitModel::getName)
.collect(Collectors.toList());
if(!allUserGroupsForUser.isEmpty())
getSessionService().setAttribute("availableB2BUnits", b2bunitIds);
super.loginSuccess();
Then in storefront, I showed in select tag in jsp, drop-down with these units. Ok, so I have attribute now with these units which is in session and I want when I click for some B2B Unit, this one unit to set in session. I think, I shoud do some controller to implement logic ( set currentUnit in session ) and in one js file to make some ajax call with some method onChange, or some ajax api, but I don't know how to do this. Can someone help me, i am new in hybris and I will be glad if someone help me
java hybris
java hybris
asked Nov 15 '18 at 13:05
rrusevrrusev
439
439
Please see: Why is “Can someone help me?” not an actual question?
– Progman
Nov 15 '18 at 13:43
add a comment |
Please see: Why is “Can someone help me?” not an actual question?
– Progman
Nov 15 '18 at 13:43
Please see: Why is “Can someone help me?” not an actual question?
– Progman
Nov 15 '18 at 13:43
Please see: Why is “Can someone help me?” not an actual question?
– Progman
Nov 15 '18 at 13:43
add a comment |
1 Answer
1
active
oldest
votes
You have already halfway through as you have already populated availableB2BUnits from the backend(Façade) to the frontend(JSP). Similarly, you have to send back the "b2bunitIds" to the backend.
Implement the following steps:
Find/ create the javascript file from where you can make ajax (or normal post) call. Make sure that js file is loaded for the current page on which you need all these actions to be performed otherwise your javascript method won't be executed.
Write required logic in above js file to obtain b2bunitId from the selection made. Use b2bunitId to invoke Controller's method (RequestMapping).
From the invoked method of the Controller set the selected b2bunitId in session as you did it in the above method (
getSessionService().setAttribute("availableB2BUnits", b2bunitIds);).
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
);
);
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%2f53320155%2fhow-to-set-b2b-unit-in-session-hybris%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
You have already halfway through as you have already populated availableB2BUnits from the backend(Façade) to the frontend(JSP). Similarly, you have to send back the "b2bunitIds" to the backend.
Implement the following steps:
Find/ create the javascript file from where you can make ajax (or normal post) call. Make sure that js file is loaded for the current page on which you need all these actions to be performed otherwise your javascript method won't be executed.
Write required logic in above js file to obtain b2bunitId from the selection made. Use b2bunitId to invoke Controller's method (RequestMapping).
From the invoked method of the Controller set the selected b2bunitId in session as you did it in the above method (
getSessionService().setAttribute("availableB2BUnits", b2bunitIds);).
add a comment |
You have already halfway through as you have already populated availableB2BUnits from the backend(Façade) to the frontend(JSP). Similarly, you have to send back the "b2bunitIds" to the backend.
Implement the following steps:
Find/ create the javascript file from where you can make ajax (or normal post) call. Make sure that js file is loaded for the current page on which you need all these actions to be performed otherwise your javascript method won't be executed.
Write required logic in above js file to obtain b2bunitId from the selection made. Use b2bunitId to invoke Controller's method (RequestMapping).
From the invoked method of the Controller set the selected b2bunitId in session as you did it in the above method (
getSessionService().setAttribute("availableB2BUnits", b2bunitIds);).
add a comment |
You have already halfway through as you have already populated availableB2BUnits from the backend(Façade) to the frontend(JSP). Similarly, you have to send back the "b2bunitIds" to the backend.
Implement the following steps:
Find/ create the javascript file from where you can make ajax (or normal post) call. Make sure that js file is loaded for the current page on which you need all these actions to be performed otherwise your javascript method won't be executed.
Write required logic in above js file to obtain b2bunitId from the selection made. Use b2bunitId to invoke Controller's method (RequestMapping).
From the invoked method of the Controller set the selected b2bunitId in session as you did it in the above method (
getSessionService().setAttribute("availableB2BUnits", b2bunitIds);).
You have already halfway through as you have already populated availableB2BUnits from the backend(Façade) to the frontend(JSP). Similarly, you have to send back the "b2bunitIds" to the backend.
Implement the following steps:
Find/ create the javascript file from where you can make ajax (or normal post) call. Make sure that js file is loaded for the current page on which you need all these actions to be performed otherwise your javascript method won't be executed.
Write required logic in above js file to obtain b2bunitId from the selection made. Use b2bunitId to invoke Controller's method (RequestMapping).
From the invoked method of the Controller set the selected b2bunitId in session as you did it in the above method (
getSessionService().setAttribute("availableB2BUnits", b2bunitIds);).
answered Nov 16 '18 at 19:58
ApsAps
215
215
add a comment |
add a comment |
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.
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%2f53320155%2fhow-to-set-b2b-unit-in-session-hybris%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 see: Why is “Can someone help me?” not an actual question?
– Progman
Nov 15 '18 at 13:43