Spring bind not working in velocity template - spring

I have added a object to the command in spring bean. I am using that command in y velocity template and trying to bind the new object i created using springFormInput. I am using velocity template. Here is the syntax
#springFormInput("command.newObject.newName", "class=s11")
I do not see that the data i am entering here as text in the form is not getting bind to the command.
Any idea on why this is not working. There are some other fields in form like checkbox and they are binding. Its only this new object that i created in the command does not seem to be working. Pls help.

I have something in the controller class where the controller has objects defined in it that allows binds. So when i specified the objects there under allow binding form, I could see the spring bind is working.

Related

how to access spring property placeholder generated properties object?

We are using property placeholder configurer in multiple apps(12-15) and would like to access final properties object prepared by propertly place holder to see what properties and its values being used by that app. In each app we want to have one page with ready only values displayed since each app has multiple propeeties file and environment properties so would like to see final state of that properties object.
Note: we are using spring 4.1 with spring web mvc and spring batch 3.x

Getting Laravel Workbench Package Config Values From Within ServiceProvider Registration

Within MymoduleServiceProvider->register(),
I want to be able to pull configuration values from the same package.
However whenever I
var_dump($app['config']['file.option']
I get a null value
I know that the file structure is correct because if I do:
Config::get('package::file.option');
from a controller, I get the correct value
How can I load my packages configuration values from within the ServiceProvider->register() method?
$app['config'] is an instance of Config stored in the IOC container.
So try using the get() method directly from the IOC container like so:
$app['config']->get('package::file.option');
as an equivalent to using the facade
\Config::get('package::file.option');

Spring validation in multiple forms

Can we display error messages in one jsp but in 2 different forms.I am validating my bean using spring validation.Its working fine but if there is an error in the binding results then I am able to display the error message in the form from where action is executed but not in the other resultant form.
is the error tag in spring validation is mapped to jsp form from where that action is called.
Your BindingResults is just an object, which you can put in your Model and use on the page however you want. You may need to put it into Session if you plan to use it on a separate form.

Spring - Adding element(checkbox) to Spring login page (with Spring-security)

In my web application I am using Spring login form (with Spring-security). By default the login form has the fields j_username and j_password. I need to add one more element(checkbox for Terms&Conditions). The current code doesn't have LoginForm as well as LoginController since Spring is internally handling it.
Can anyone please tell how to handle/override this?
I have seen this link Spring security custom login page
But I need to add the new element in LoginForm (which is not existing currently) - where I need to add this new element(in Form - .java file)
Also should I write a new controller (LoginController) or can I use any existing filter as given here? http://static.springsource.org/spring-security/site/docs/3.1.x/reference/springsecurity-single.html#filter-stack
Does the user just have to check the box in order to procede, or does it bind to a backing model object.
If it's the former, I'd just handle it through javascript. If the latter, the easiest way would probably be implementing an Authentication Filter, this area of the documentation might help:
http://static.springsource.org/spring-security/site/docs/3.0.x/reference/core-web-filters.html#form-login-filter

How to use annotated Spring controllers with Freemarker to return custom ajax respones

I primarily use annotated controllers that return ModelAndView object used by Spring and Freemarker to render and return pages to browsers - works great. I'd now like to respond to ajax gets and posts that return html fragments as payload inside an XML message.
The problem I'm having not returning a ModelAndView objects seems to confuse Spring WRT to #ModelAttribute (s) and session objects that support data to / and from forms.
I've had to hack the freemarker template to support i18n messages, etc. I'm finding that simply rendering an FTL file while also trying to utilize Spring's object rendering from froms is becoming quite a rabbit hole.
I'm trying to manually (guess what and) do the things that get done behind the scenes and it's not working optimally. To edit an object I'm manually placing the object in the session on rendering the edit form. When the post comes back there are residual/different values in the object I get back out of the session AND the ModelAttribute that Spring rendered for me.
Bottom line? Questions about Spring, Freemarker and custom non-ModelAndView responses that are rendered by Freemarker.
Add another instance of FreeMarkerViewResolver that only that has viewNames ='*.frg'. The viewClass should be your own class that renders the template the way you want by overriding the processTemplate method.

Resources