You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Yellek <ye...@gmail.com> on 2009/04/25 04:54:59 UTC

ModelDrivenInterceptor not refreshing model for Struts2

I have a ModelDrivenInterceptor set up as follows in struts.xml:

                <interceptor-ref name="modelDriven">
                    <!-- allow actions to change the model during execution
so that the view gets a new model. --> 
                    true
                </interceptor-ref>

My save method in my action is as follows:

    /**
     * Create or update the entity.
     * 
     * @return <code>Show</code>
     */
    public String save() {
        LOG.debug("save() Called");
        setEntity(getDao().save(entity));
        return SHOW;
    }

The DAO is using Hibernate via JPA.

However the entity is never replaced on the value stack.

Digging a little further in the debugger I get to the following code on
lines 114-116 of ModelDrivenInterceptor:

                if (item == newModel) {
                    needsRefresh = false;
                }

Now the debugger tells me that those two variables have different object
identities. newModel has the ID of the entity set from the database save and
item does not. However for some reason Java is saying that the two variables
are == to each other which is clearly not the case. Definitely weird.

Can anyone suggest what might be going on? My only thought is that there is
some weirdness going on with the Hibernate CGLIB enhanced model objects.

Peter Kelley


-- 
View this message in context: http://www.nabble.com/ModelDrivenInterceptor-not-refreshing-model-for-Struts2-tp23227918p23227918.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org