Unable to close modal plugin on form submit - java

enter image description hereI am using bootstrap modal plugin for an inquiry form and am using "ng-submit" directive to save the details of the form, but when i click on the submit button the form gets submitted but the modal window does not gets closed. How can i close the modal when details have been submitted.
Please find the image for modal reference.
Thanks for help in advance

For a quick hack around, in your callBackUser() method in controller add the below piece of code,
$('#exampleModal').modal('hide');
Again not advisable to mix jQuery and Angular.
EDIT As per your comments, clear all your form data like this,
$scope.callback.firstName = "";
$scope.callback.useremail= ""
And so on.. for all the fields!

Related

This content cannot be displayed in a frame - eclipse (displayHelpResource(href))

I'm trying to open a URL in my application through the displayHelpResource(href) function.
But I'm being shown the following :
This content cannot be dispalyed in a frame
To help protect the security of information you enter into this website, the publisher of this content does not allow it to be displayed in a frame.
I've understood that the site is blocking the Frame access. What can be done to open the desired URL using the displayHelpResource(href) function.
You can add noframes=true to the href you stop frames being used
http:xxxxx?noframes=true
The noframes=true text is removed from the href by the help system before it is actually used.

Prevent form resubmit after pressing back button

I am in bit of a delicate situation here. In my organization we design stock management systems and it is a web application based on JSP pages and servlets which handles them.
I have been asked to fix a specific problem. We have a JSP page with an HTML form table where there are stock details. When user enters the details manually and submit the form, stock details updated in the database and it works fine.
Problem is this : When the user press the browser's back button, user can come to the previous page where he submitted the details. And when the user submit this, data is saved once more to the database.I need to prevent this behaviour.(Something likeclear and reload the page.)
Things I did so far : clear the browser cache.Code works fine but not the expected result.
Unfortunately I cannot share the code due to company regulations. What I need is a help to prevent this behaviour or a workaround.
Thanks in advance..
You can use a javascript function with the help of a hidden attribute to reload the web page. When the user press the back button,based on the value of the hidden attribute, page will be reloaded without loading the cached page.
Your approach of clearing cache is correct. Coupled with that, you can use this approach.
<input type="hidden" id="refreshed" value="no">
<script type="text/javascript">
onload=function(){
var e=document.getElementById("refreshed");
if(e.value=="no")e.value="yes";
else{e.value="no";location.reload();}
}
</script>
One drawback of this approach is if your clients' browsers have disabled JS, this will not work.Otherwise it should work.
When the user press the browser's back button, user can come to the
previous page where he submitted the details. And when the user submit
this, data is saved once more to the database.
According to how you described it, that is based on a doGet request. Which means every time you visit that URL, it will send the request with whatever parameters were added.
As someone already mentioned, if you switch the form to a post method and switch the Servlet to a doPost, you won't have this issue anymore.
Alternatively you can circumvent this with a javascript solution. Here are some options:
You can check if the user clicked the back button, disable form if true.
Another way is by storing a cookie which you check on page load, if it exists you can disable the form.
You can use this code also
$(document).ready(function() {
function disableBack() { window.history.forward() }
window.onload = disableBack();
window.onpageshow = function(evt) { if (evt.persisted) disableBack() }
});
You must use a Post-Redirect-Get pattern: https://en.m.wikipedia.org/wiki/Post/Redirect/Get.
Actually, every use of standard HTML forms with method="post" should be implemented with that pattern. It doesn't have any use for AJAX-posted forms, which actually could be another solution but will require more work and probably some architectural changes.
I had this same problem while building a django web app, and my solution was to not allow caching of the html that contains the form. In your request handler, do not allow the browser to cache the page. This will force the browser to get the page fresh from the document.
Which, in this case, you can just verify in your request handler if the requested form has already been submitted.
My code for reference:
from django.views.decorators.cache import never_cache
#never_cache
def GetForm(request, pk):
# Logic #
if (IsFormCompleted(pk)):
# Handle request #
Here is a solution.
give a random id in a hidden field on the form. Then on the server side, if the user resubmit, check if the random id already on the database. If so, redirect user.

how to stop spring security timeout from loading my login page in a div

I am having an issue with spring security's timeout facility. On my home JSP i have a table. each list item will allow the user to modify the data in this list element. when you click the edit icon a modal opens with the data from that list element so the user can edit it. the issue I am having is if this modal is open and the system times out and loads the login page. but it loads the login page into the table div. I am just wondering if anyone knows of any possible solutions to this problem?? I have increased the time out limit but will not fix the problem of the login page being displayed in my table div. any help is much appreciated.
hanks in advance Billy
You might need to check via javascript if the returned page is a login form and in that case open the proper login page, then retrieve the original url after a successful login.
An example is here: http://gal-levinsky.blogspot.it/2011/08/spring-security-3-ajax-login.html

How can I direct a user to a new page dynamically based on a dropdown list with plain Wicket?

Here is my situation: the user selects a section (for example from a dropdown) such as "Section1," "Section2" or "Section3." Then he clicks the OK button (or some link).
What I need to happen: after he clicks on that button/link, he will be redirected to the selected section, e.g. www.homepage.com/docs#section2.
So far, I have not been able to process the form from Link's onClick method, nor have I been able to call some clickLink on Link from the Button method onSubmit().
I would prefer not to use AJAX or JavaScript. How can I do this?
That's because a Link doesn't submit the form. It just acts as a link to somewhere. To access your formdata you'll need to submit the form first. Try using a SubmitLink instead of a Link and call
getRequestCycle().setRequestTarget
(new RedirectRequestTarget("www.homepage.com/docs#section2"));
from the onSubmit function of the SubmitLink.
Judging from the Javadoc this should work but I can't test it right now.
A RequestTarget that will send a redirect url to the browser. Use this if you
want to direct the browser to some external URL, like Google etc, immediately.
Or if you want to redirect to a Wicket page. If you want to redirect with a
delay the RedirectPage will do a meta tag redirect with a delay.
Did you try Link.setAnchor(Component)?

jquery and java communication

I have jquery pop form to upload a file, after on submit (the page refresh and the pop close) i check something about the file and then if there's something wrong i need to pop up that form again (from the java code?), how could i do that ?
You should use ( or must be using) ajax in jquery with a popup.
When the user hits "submit", control goes to server side code.
The code runs to upload the file.
Whatever the result of upload (success/failure), that message is sent to the popup with ajax automatically.
In case, there is problem in uploading the file then, along with the failure message, you can send in the div which contains your form.
I think rather than refreshing the page to close the popup, allow the user to close the popup with close button.
When "something is wrong" the server-side code (this applies to any language) should include within the HTML content Javascript that will trigger the "form" to be displayed again.
As I feel dizzy presently,can't write the code,but will try to break whole procedure in multiple steps:-
On Trigger(by some event) a pop up form will open from submission,which will have a button which will be calling a OnClick Event,which will be containing an Ajax call for client server communication
till the response don't close or fade out the Pop up box.
from server expect two tags SUCCESS or ERROR
a) On SUCCESS, remove form DIV and fade out/close the pop up
with a success message b)On Error,display a refreshed form DIV
And so on

Categories