Invoke controller method from JSP - spring

How can I invoke a method from a controller of another model?
I.e.: I have a popup jsp, where a search button opens another popup with a form (this is binded to another model). In this new popup I can search for an address, which will be returned to the popup before. Any ideas, how this can work?
Thanks.

Related

Show bootstrap modal on server side validation

I have a ASP.Net Core MVC web application. I have a standard razor view which has a list of items with a delete button. What I want to do is if they user deletes an item from the grid go to the server calling an action which validates the item selected. IF invalid I want to return to the view and show a bootstrap modal explaining why the delete cannot be carried out. I call the delete routine using Controller / Action tag helpers and pass the unique Id to a controller event.
So basically if my delete validation fails show a modal dialog with a message. Any help please?
I ended up sorting this myself. Basically I set a viewbag property and give it a value of show. Then in my script section of my view I set the modal property to that viewbag.

spring form submission in a popup

I have a small problem in my first spring&hibernate application.
In my page, I would like to create a popup window (modal) which gives the possibility to send an email. So, this popup would display a spring form with a fied "subject" and a field "content".
The question is : how can I use the form binding mechanism of spring with this popup form if I don't want my main page (displayed behind the popup form) to be reloaded?
If i am not wrong, the content of the popup is a div present in the main page. So, If I submit the form in the popup, the whole page will be reloaded (through the mvc mechanism of spring) and this is exactly what I don't want.
Of course, I can submit my form via an ajax call to a spring controller, but in this case, how to handle the eventual errors in the form? I cannot use the spring form binding mechanism to display the errors on the popupform. Is it possible?
Do you know if there is a way to open a new window in a modal popup? So that this page and only this page would be reloaded during the submission of the form?
Actually, I am not sure of the best way to combine a popup containing a form and the form submission mechanism of spring. How to display the errors on the form in case of errors? after reload of the page, If there are some errors, I need to open my popup again in javascript and then display the errors on the popup, this is the only mean I see, but maybe there are easier solutions.
If you have, I would be happy to know it.
thanks a lot

Wicket: Modal Windows and callback functionality

I have a modal window that shows a panel which contains a form that has some textfields and a submit button
on submit an insert into the database occurs and then I have some ajax behaviour that i want to activate on the modal windows containing page on click of the button.
So flow is at present:
click link
modal window appears
user fills out form
user submits form
form data persisted to db
modal window closes
I need it to do this in addition:
activate some ajax behaviour on the page that contains the panel
any help on how best to do this in the wicket way is appreciated.
I resolved this by passing an instance of the page containing the panel to the panel (i.e. - in the constructor), then calling a method on the page from the panel to perform the Ajax update.
I would be interested to see what others have done or to hear if there are issues with the approach I have taken.
Set up a WindowClose callback.
In the WicketStuff project called ModelX (Disclaimer: I'm the developer of that) I have created an IWindowClosedListener interface which has a method:
void windowClosed(Panel panel, AjaxRequestTarget target)
So then any Page or Panel that can open a modal that needs to do something when that modal is closed simply implements that interface and its windowClosed method gets called at the right time.

Correct way to follow MVC pattern when doing an AJAX request

I'm using extjs mvc style to create a web application.
I don't have any direct issue but I'm not sure on how should I handle this code to keep following the mvc pattern.
This is my situation:
Controller, which detect click event
View, which has a changePassword method
I'm simply trying to make an ajax request to change the password of a user (notice that the code is currently working, I'm only thinking if I should move a part on the controller).
Currently the code behaves like this:
Controller detect click event and run changePassword method on the view with a record parameter it passes to
View open a prompt message that request to the user a new password
View runs an ajax call and show a successful/error message
What my idea is:
Controller detect click event and run View.showChangePassword prompt
View show the prompt and it returns the password insert there to the controller
Controller runs the ajax call
Controller runs a View.showChangePasswordResult with param: what is returned by ajax call
Is my idea better than what I'm currently using?
Yes. I would only move showChangePassword to the controller too.
Controller detects event
Controller create another view if necessary and subscribe to submit method of this view
Controller submits values via Ajax.

Using MVVM Light messaging instead of query strings in Windows Phone

I am trying to use MVVM light messaging to send a value from one page to another during Navigation (for example, send the id of an item that was selected to an edit page). So the list page's viewmodel sends a message and then sends a navigation message to the view which redirects to the edit page. The edit page's viewmodel gets created only when the navigation to the page happens. So when I register for this event in the edit page viewmodel, I never get the message? What is the best solution for this?
Thanks in advance.
Your best solution would be to use the querystring instead of messaging. If you don't use the querystring, you'll have to deal with situations like the application being deactivated (tomestoned), then the user clicking "back" and your application loads the second page without receiving the message.
However, if you want to continue down this path, you can modify your ViewModelLocator such that your page's ViewModel is created immediately (in ctor for instance) instead of as needed. Since the ViewModelLocator is created as soon as your App.xaml is loaded, you know that any view models will be created immediately. As long as your view model is registering for messages in it's constructor it should receive the message.

Resources