Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18

Thread: Context initialization failing due to inner class usage

  1. #11
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    so i dont think there is problem of version conflict...
    Well I really think there is... Why?

    spring.jar already contains everything which is in spring-beans.jar, spring-context.jar etc... So either remove spring-*.jar or remove the spring.jar.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  2. #12
    Join Date
    Nov 2005
    Location
    Reutlingen, Germany
    Posts
    2,098

    Default

    Quote Originally Posted by mdeinum View Post
    First when posting code please use the [ code][/code ] tags!!! It makes your post readable, which it really isn't right now.
    Second please don't hijack threads with a completely different topic. Nobody will be able to find the stuff they are looking for ...

    Joerg
    This post can contain insufficient information.

  3. #13
    Join Date
    Sep 2007
    Posts
    7

    Default Access Objects in validation.xml

    Hi,

    How do i access an object in validation.xml. I am using Bean Validation Framework.

    My class:
    Code:
    public class Employee {
    	
    	private String firstName;
    	private String lastName;
    	private Department department; 
    //with getters and setters
    }
    My employee-validation.xml

    Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <validation xmlns="http://www.springmodules.org/validation/bean" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://localhost:8080/BVF http://localhost:8080/BVF/validation.xsd">
    	
    	<class name="Employee">
    		<validator class="EmployeeValidator"/>
    		
    		<property name="firstName">
    			<not-blank message="FirstName cannot be left blank"/>
    			<length min="5" max="20" message="First Name Length cannot be less than 5 or more than 20"/>
    		</property>
    		
    		<property name="lastName">
    			<not-blank message="LastName cannot be left balnk"/>
    			<length min="5" max="20" message="Last Name Length cannot be less than 5 or more than 20"/>
    		</property>
    		
    		<property name="department.name">
    	            <not-blank message="Name cannot be blank"/>
    	            <length min="5" max="20" message="Name Length cannot be less than 5 or more than 20"/>
           		</property>
     
           		<property name="department.pinCode">
    	     	   <not-blank message="Pin Code cannot be left blank"/> 
    		        <regexp expression="^[A-Z\d{1}]\d{4}[\s\-]*\d*$" message="PinCode is invalid"/>       	
    		        <length min="5" max="10" message="Pincode length should be between 5 and 10"/>
            	
           		</property>
    	
    	</class>
    	
    </validation>
    can someone tell me how i can access the elements of department object. Code in bold doesnt seem to be working.

  4. #14
    Join Date
    Nov 2005
    Location
    Reutlingen, Germany
    Posts
    2,098

    Default

    Please start a new thread! Or to quote myself from just immediately before your post (I wonder if you posted by intention and just want to annoy us ):

    Quote Originally Posted by Jörg Heinicke View Post
    Second please don't hijack threads with a completely different topic.
    Joerg
    This post can contain insufficient information.

  5. #15
    Join Date
    Sep 2007
    Posts
    7

    Default

    I am so sorry... i didnt mean to annoy you

  6. #16
    Join Date
    Aug 2008
    Location
    Zürich
    Posts
    14

    Default It is possible to instanciate non static inner classes with spring

    I had a similar problem like the first post in this thread, but the solution making the class static was not valid for my problem. I wanted to call methods of the outer class directly from the inner class.
    Spring instantiates beans with reflection not with new, and with reflection you have a constructor for non static inner classes that takes an instance of the outer class as parameter.
    so the config should work for this example.

    <bean id="customerBean" class="com.models.CustomerBean" />
    <bean id="customerFormValidator" class="com.models.CustomerBean$CustomerBeanValidat or">
    <constructor-arg ref="customerBean" />
    </bean>

    for a longer explanation check my blog post about this:
    boris-dev.blogspot.com/2008/08/spring-and-inner-classes.html

  7. #17
    Join Date
    May 2005
    Location
    California, US
    Posts
    735

    Default

    Boris, you've replied to a thread that's just a few days away from being a year old!


  8. #18
    Join Date
    May 2005
    Location
    California, US
    Posts
    735

    Default

    And regarding your blog entry about being able to extend two classes, there's something you can do with Spring's AOP to get the same or similar effect. I've never used it and only know about it because I'm reading

    http://apress.com/book/view/1590599799

    and he goes over it in one of the chapters on AOP.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •