Thursday, August 15, 2013

How to integrate Oval validation with Spring 3

The way I see it. If you are currently doing validation in a spring mvc application by implementing
interface Validator undestanding spring oval intergration is supper easy. Anyway it doesn't matter you have any experiance on that or not you will understand how spring oval intergration can do at with this tutorial.

  • Oval what is oval?


  • Oval validation
  • spring support
  • oval class API


Need of a validator interface

public interface Validator {
boolean supports(Class clazz);
void validate(Object target, Errors errors);
}


Spring API to validate





Add this to your bean configuration file. Replace the highlighted configuration files with your ones.


<bean id="validator" class="net.sf.oval.integration.spring.SpringValidator">
<constructor-arg>
<bean id="validator" class="net.sf.oval.Validator">
<constructor-arg>
<util:list>
<bean class="net.sf.oval.configuration.xml.XMLConfigurer">
<constructor-arg>
<value type="java.io.InputStream">classpath:com/test/validation/oval1-config.xml</value>
</constructor-arg>
</bean>
<bean class="net.sf.oval.configuration.xml.XMLConfigurer">
<constructor-arg>
<value type="java.io.InputStream">classpath:com/test/validation/oval2-config.xml</value>
</constructor-arg>
</bean>
</util:list>
</constructor-arg>
</bean>
</constructor-arg>
</bean>

The class net.sf.oval.integration.spring.SpringValidator provides an implementation of Spring's org.springframework.validation.Validatorinterface and thus can be used for Spring Validation.




Wednesday, August 14, 2013

Resolve @Autowire from many candidates.

How to resolve @Autowire property from multiple instances?

or you got 'Spring finding multiple bean definition error' ?
Its simple.!

You need to use @Qualifier annotation here...!

public class MovieRecommender {
     @Autowired
    @Qualifier("main")
private MovieCatalog movieCatalog;
// ...
}

and your bean application context configuration will have this.

<context:annotation-config/>
<bean class="example.SimpleMovieCatalog">
<qualifier value="main"/>
<!-- inject any dependencies required by this bean -->
</bean>
<bean class="example.SimpleMovieCatalog">
<qualifier value="action"/>
<!-- inject any dependencies required by this bean -->
</bean>

Now you can switch between two qualifiers when ever you want too..! good luck.


Sunday, November 11, 2012

How to clean Netbeans cache

Check u'r  "C:\Documents and Settings\(user)\.netbeans\(version#)\var" directory and delete the content of this 'var' directory.

Sunday, November 4, 2012

USPS- I got a parcel locker key in my mail box.


This week I got a package from amazon and package tracker says USPS is delivering via priority mails. At the same time I find a key in my mail box.  Now what that can be? that is my parcel locker key. Now where is my parcel locker? There are no other mail box clusters in my apartment area. I have seen in some other apartments there are array of big mail boxes in the lobby or separate parking area. 

Now if I had observe my mail box cluster I would have find there is two medium size lager boxes underneath the cluster and there are two key holes. I was able to open one of these boxes using locker key. Viola.. ! there was my package. Now if you try to get the key out you can't get it out. I think postal clerk uses a special key to release it so the cycle continue for the next person comes in. 

Wednesday, September 12, 2012

Download VLC windows media player.

I was looking for download vlc player for windows. When you google for 'Down load VLC' you get hell lot of index links which are not what you looking for. If you check Wikipedia you will get the official VLC site and you can download the VLC player from there.

Wikipedia url             : http://en.wikipedia.org/wiki/VLC_media_player
VLC official web site  :http://www.videolan.org/

Saturday, December 24, 2011

Tuesday, August 23, 2011

Idea

There’s absolutely no point in having an idea if you don’t do something about it.

False fear

There is a figure they said She talks to me It's a mischievous voice I can't deny that love They say she is pretty Smart and wa...