/*
 * Copyright (C) 2012 Expression organization is undefined on line 4, column 61 in Templates/Licenses/license-gpl30.txt.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package nl.b3p.viewer.admin.stripes;

import net.sourceforge.stripes.action.ActionBean;
import net.sourceforge.stripes.action.ActionBeanContext;
import net.sourceforge.stripes.validation.Validate;
import nl.b3p.viewer.config.app.Application;
import org.stripesstuff.plugin.session.Session;

/**
 *
 * @author Meine Toonen
 */
public class ApplicationActionBean implements ActionBean{
    
    protected ActionBeanContext context;
    
    @Session(key="application")
    @Validate
    protected Application application;

    public void setContext(ActionBeanContext abc) {
        this.context= abc;
    }

    public ActionBeanContext getContext() {
        return context;
    }

    public Application getApplication() {
        return application;
    }

    public void setApplication(Application application) {
        this.application = application;
    }
}

@@ -826,16 +826,57 @@
 pes;%0D%0A%0D%0A
+import javax.persistence.EntityManager;%0D%0A
 import n
@@ -976,16 +976,121 @@
 ntext;%0D%0A
+import net.sourceforge.stripes.action.After;%0D%0Aimport net.sourceforge.stripes.controller.LifecycleStage;%0D%0A
 import n
@@ -1228,16 +1228,66 @@
 ession;%0D
+%0Aimport org.stripesstuff.stripersist.Stripersist;%0D
 %0A%0D%0A/**%0D%0A
@@ -1376,23 +1376,20 @@
 tionBean
+ 
 %7B%0D%0A
-    
 %0D%0A    pr
@@ -1428,47 +1428,8 @@
 t;%0D%0A
-    %0D%0A    @Session(key=%22application%22)%0D%0A
     
@@ -1478,16 +1478,88 @@
 cation;%0D
+%0A    @Session(key = %22applicationId%22)%0D%0A    protected Long applicationId;%0D
 %0A%0D%0A    p
@@ -1626,16 +1626,17 @@
 .context
+ 
 = abc;%0D%0A
@@ -1900,22 +1900,345 @@
 plication;%0D%0A
+        this.applicationId = application.getId();%0D%0A    %7D%0D%0A%0D%0A    @After(stages = %7BLifecycleStage.BindingAndValidation%7D)%0D%0A    private void initApplication() %7B%0D%0A        EntityManager em = Stripersist.getEntityManager();%0D%0A        application = em.find(Application.class, applicationId);%0D%0A        em.getTransaction().commit();%0D%0A
     %7D%0D%0A%7D%0D%0A

Put the applicationId on the session, not the application. After binding and validation retrieve the application