Displaying Pop up window after successful login using Spring Security, Jquery, Spring MVC
Step 1.
Set the attribute in session in authentication success handler based on you business requirement
@Override
public void onAuthenticationSuccess(final HttpServletRequest request, final HttpServletResponse response,
final Authentication authentication) throws IOException, ServletException
{
if(<condition specific to your project>){
sessionService.setAttribute("displayPopup","Y");
}
}
Step 2.
add the attribute in model to read in JSP page using the Homepage controller java class.
model.addAttribute("displayPopup", sessionService.getAttribute("displayPopup"));Step 3:set this value as hidden field in homepage.jso to read it from jQuery code<input type="hidden" name="displayPopup" id="displayPopup" value="${displayPopup}">Step 4:jQuery code to display popup after 500 msvar displayPopup = $('#displayPopup ').val();
if( displayPopup == 'Y' ){
setTimeout(function(){
$("#StoreInfoModal").dialog("open");
},500);//modal will open after 500ms once page homepage loads
}
$("#StoreInfoModal").dialog({
autoOpen: false,
modal: true,
width: 550,
height: 240,
open : function(event,ui){
//add the custom logic based on your requirement if// anything to be performed when pop up opens
},
close :function(event,ui){
//add the custom logic based on your requirement// if anything to be performed when pop up closes
}
});
Comments
Post a Comment