Results 1 to 6 of 6

Thread: null argument to setter?

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

    Default null argument to setter?

    Could someone explain why the setWleDao() method was being called with a null argument in the following code? The only way I could get it to work (setting the wleDao field) was to change the bean wiring to use a constructor. I was under the impression that it should work with a setter or a constructor.

    Code:
    public class
    SignInCtlr extends SimpleFormController {
        private WleDao      wleDao;
    
        public
        SignInCtlr(WleDao wleDao) {
            setCommandClass(SignInFrmData.class);
            this.wleDao = wleDao;
        }
    
        protected ModelAndView
        onSubmit(Object cmd, BindException errs) throws Exception {
            SignInFrmData sifd = (SignInFrmData) cmd;
    
            String view = sifd.getView();
    
            sifd.setWle(wleDao.getWaitlistEntries());
    
            return(new ModelAndView(view, "sifd", sifd));
        }
    
        public void
        setWleDao(WleDao wledao) {
            this.wleDao = wleDao;
        }
    }
    This is the config from the xml file:

    Code:
        <bean id="signInCtlr"
            class="SignInCtlr">
            <constructor-arg>
                <ref bean="wleDao" />
            </constructor-arg>
            <property name="sessionForm">
                <value>true</value>
            </property>
            <property name="commandName">
                <value>sifd</value>
            </property>
            <property name="commandClass">
                <value>SignInFrmData</value>
            </property>
            <property name="validator">
                <ref bean="signInValidate" />
            </property>
            <property name="formView">
                <value>signInView</value>
            </property>
            <property name="successView">
                <value>signInFrmDataView</value>
            </property>
    <!--
            <property name="wleDao">
                <ref bean="wleDao" />
            </property>
    -->
        </bean>

  2. #2
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    Simple case typo. "wledao" should be "wleDao". Try:
    Code:
    setWleDao&#40;WleDao wleDao&#41; &#123;
            this.wleDao = wleDao;
    &#125;

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

    Default

    Duh. I should have caught that!

    Many thanks.

  4. #4
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    No probs. A good IDE like Eclipse can pick this up - can even configure it to be an error.

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

    Default

    I have a non-standard coding style that Eclipse doesn't support; I like to put the method's types and modifiers on the line above it;
    Code:
    public final static String
    xyzzy&#40;&#41; &#123;
        return&#40;"a string"&#41;;
    &#125;
    If it wasn't for that I'd use it.

  6. #6
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    I have a non-standard coding style that Eclipse doesn't support...If it wasn't for that I'd use it.
    It may not auto-format that way, but it shouldn't automatically reformat it on you. Having moved from UltraEdit well over a year ago myself, I'd now never go back. I'd recommend Eclipse (or similar - I've heard great things about IntelliJ IDEA) as an essential tool.

Similar Threads

  1. Replies: 2
    Last Post: Oct 17th, 2005, 08:41 PM
  2. Replies: 4
    Last Post: Sep 27th, 2005, 11:31 PM
  3. could not satisfy dependencies
    By springuser in forum Container
    Replies: 4
    Last Post: Apr 26th, 2005, 01:15 PM
  4. Replies: 1
    Last Post: Apr 25th, 2005, 07:37 PM
  5. Strange Data Access Error
    By webifyit in forum Data
    Replies: 2
    Last Post: Dec 28th, 2004, 11:06 AM

Posting Permissions

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