I am a bit confused about how pageBeginRender works during a form
submission  Here is the code i have:

        public void pageBeginRender(PageEvent event) {
                // initialize app
                retrieveApp(getAppVerId());
        }
        
        private void retrieveApp(Long id){
                if(id != null){
                        System.out.println("Updating App: "+ id);
                        AppDAO dao = new AppDAO();
                        AppVer ver = null;
                        AppInfo info = null;
                        ver = dao.getAppVerId(id, false);
                        info = ver.getAppInfo();
                        setAppInfo(info);
                        setAppVer(ver);
                }
                if(getAppInfo() == null){
                        System.out.println("Creating a new application");
                        setAppInfo(new AppInfo());
                        setAppVer(new AppVer());
                        getAppVer().setRegdate(new Date());
                }
        }

        /**
         * Action taken when this form has been submitted
         * 
         * @param cycle
         */
        public void formSubmit(IRequestCycle cycle){
                System.out.println("Current VerId = "+ getAppVerId());
                // Check to see all validation was a success
                ValidationDelegate delegate =
(ValidationDelegate)getBeans().getBean("delegate");
                
                if(!delegate.getHasErrors()){
                        // Insert the new version
                        AppDAO dao = new AppDAO();
                        AppInfo info = getAppInfo();
                        AppVer ver = getAppVer();
                        
....

Basically I need to initialize the AppInfo and AppVer objects when the
page is rendered.  The page is an add/edit form.  If appVerId is not
null I lookup AppInfo and AppVer to populate my form for editing, if
null create new objects.   This seems to work fine.   THe problem I am
having is that when I submit the form It create a new AppVer and
AppInfo because appVerId appears to be null in pageBeginRender(Event)
but when it continues to formSubmit my print is showing the the
appVerId != null which is what I expect.  The problem is the objects
have been intialized as new so it ends up creating duplicates.  Hope I
made this clear.

-- 
~chris

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to