he makes the accusation that Struts ParametersInterceptor specifically flushes 
session data to (DB) repository  but this is not the case

com.opensymphony.xwork2.interceptor.ParametersInterceptor (contents):
    @Override
    public String doIntercept(ActionInvocation invocation) throws Exception 
    {
        Object action = invocation.getAction();
        if (!(action instanceof NoParameters)) 
        {
            ActionContext ac = invocation.getInvocationContext();
            final Map<String, Object> parameters = retrieveParameters(ac);
            if (LOG.isDebugEnabled()) 
            {
                LOG.debug("Setting params " + getParameterLogMap(parameters));
            }
            if (parameters != null) 
            {
                Map<String, Object> contextMap = ac.getContextMap();
                try 
                {
                    ReflectionContextState.setCreatingNullObjects(contextMap, 
true);
                    ReflectionContextState.setDenyMethodExecution(contextMap, 
true);
                    
ReflectionContextState.setReportingConversionErrors(contextMap, true);
                    ValueStack stack = ac.getValueStack();
                    setParameters(action, stack, parameters);
                } 
                finally 
                {
                    ReflectionContextState.setCreatingNullObjects(contextMap, 
false);
                    ReflectionContextState.setDenyMethodExecution(contextMap, 
false);
                    
ReflectionContextState.setReportingConversionErrors(contextMap, false);
                }
            }
        }
        return invocation.invoke();
    }
    protected void setParameters(Object action, ValueStack stack, final 
Map<String, Object> parameters) 
    {
        ParameterNameAware parameterNameAware = (action instanceof 
ParameterNameAware) ? (ParameterNameAware) action : null;
        Map<String, Object> params;
        Map<String, Object> acceptableParameters;
        if (ordered) 
        {
            params = new TreeMap<String, Object>(getOrderedComparator());
            acceptableParameters = new TreeMap<String, 
Object>(getOrderedComparator());
            params.putAll(parameters);
        } 
        else 
       {
            params = new TreeMap<String, Object>(parameters);
            acceptableParameters = new TreeMap<String, Object>();
        }
        for (Map.Entry<String, Object> entry : params.entrySet()) 
        {
            String name = entry.getKey();
boolean acceptableName = acceptableName(name) && (parameterNameAware == null  
|| parameterNameAware.acceptableParameterName(name));
            if (acceptableName) 
            {
                acceptableParameters.put(name, entry.getValue());
            }
        }
        ValueStack newStack = valueStackFactory.createValueStack(stack);
        boolean clearableStack = newStack instanceof ClearableValueStack;
        if (clearableStack) 
        {
            //if the stack's context can be cleared, do that to prevent OGNL
            //from having access to objects in the stack, see XW-641
            ((ClearableValueStack)newStack).clearContextValues();
            Map<String, Object> context = newStack.getContext();
            ReflectionContextState.setCreatingNullObjects(context, true);
            ReflectionContextState.setDenyMethodExecution(context, true);
            ReflectionContextState.setReportingConversionErrors(context, true);
            //keep locale from original context
            context.put(ActionContext.LOCALE, 
stack.getContext().get(ActionContext.LOCALE));
        }
        boolean memberAccessStack = newStack instanceof MemberAccessValueStack;
        if (memberAccessStack) {
            //block or allow access to properties
            //see WW-2761 for more details
            MemberAccessValueStack accessValueStack = (MemberAccessValueStack) 
newStack;
            accessValueStack.setAcceptProperties(acceptParams);
            accessValueStack.setExcludeProperties(excludeParams);
        }
        for (Map.Entry<String, Object> entry : acceptableParameters.entrySet()) 
{
            String name = entry.getKey();
            Object value = entry.getValue();
            try {
                newStack.setValue(name, value);
            } catch (RuntimeException e) {
                if (devMode) {
                    String developerNotification = 
LocalizedTextUtil.findText(ParametersInterceptor.class, "devmode.notification", 
ActionContext.getContext().getLocale(), "Developer Notification:\n{0}", new 
Object[]{
                             "Unexpected Exception caught setting '" + name + 
"' on '" + action.getClass() + ": " + e.getMessage()
                    });
                    LOG.error(developerNotification);
                    if (action instanceof ValidationAware) {
                        ((ValidationAware) 
action).addActionMessage(developerNotification);
                    }
                }
            }
        }

        if (clearableStack && (stack.getContext() != null) && 
(newStack.getContext() != null))
            stack.getContext().put(ActionContext.CONVERSION_ERRORS, 
newStack.getContext().get(ActionContext.CONVERSION_ERRORS));

        addParametersToContext(ActionContext.getContext(), 
acceptableParameters);
    }

    protected void addParametersToContext(ActionContext ac, Map<String, Object> 
newParams) 
   {
    }


Martin Gainty 
______________________________________________ 
Jogi és Bizalmassági kinyilatkoztatás/Verzicht und 
Vertraulichkeitanmerkung/Note de déni et de confidentialité
 Ez az
üzenet bizalmas.  Ha nem ön az akinek szánva volt, akkor kérjük, hogy
jelentse azt nekünk vissza. Semmiféle továbbítása vagy másolatának
készítése nem megengedett.  Ez az üzenet csak ismeret cserét szolgál és
semmiféle jogi alkalmazhatósága sincs.  Mivel az electronikus üzenetek
könnyen megváltoztathatóak, ezért minket semmi felelöség nem terhelhet
ezen üzenet tartalma miatt.

Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger 
sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung 
oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem 
Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. 
Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung 
fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le 
destinataire prévu, nous te demandons avec bonté que pour satisfaire informez 
l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est 
interdite. Ce message sert à l'information seulement et n'aura pas n'importe 
quel effet légalement obligatoire. Étant donné que les email peuvent facilement 
être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité 
pour le contenu fourni.




> Date: Thu, 10 Mar 2011 19:39:56 -0600
> Subject: Re: RE: Re : Re : ModelDriven & Hibernate Entities
> From: burtonrho...@gmail.com
> To: user@struts.apache.org
> 
> Here is an old thread talking of this same issue.  It appears some
> suggestions are given, but still an issue.  Dave was *marginally*
> following this thread as well ;-)
> 
> http://www.coderanch.com/t/58423/Struts/Struts-Model-Driven-fundamentally-flawed
> 
> 
> On Thu, Mar 10, 2011 at 11:55 AM, CRANFORD, CHRIS
> <chris.cranf...@setech.com> wrote:
> > Dave et el -
> >
> > I can only conclude that either something is severely lost in my
> > understanding of a Struts2 ModelDriven action coupled with Spring3 and
> > Hibernate/JPA.  I have tried numerous configuration changes,
> > annotations, etc and nothing has appeared to avoid allowing dirty data
> > to make it to the database and I just cannot continue with this risk; it
> > just jeopardizes integrity.
> >
> > So unless someone can shed some light on my implementation, showing what
> > could be flawed; then I need to go down a different path.
> >
> > I like the notion that the ModelDriven does a lot of the grunt work for
> > me with respect of populating my entity based on form properties and
> > keeps my action class very clean and free of form bloat; however I feel
> > it puts some risks on the table which I could easily avoid by not
> > allowing the framework to modify my persistent entity and force me to
> > manage the copy/update of the entity accordingly when applicable.
> >
> >> -----Original Message-----
> >> From: Dave Newton [mailto:davelnew...@gmail.com]
> >> Sent: Thursday, March 10, 2011 10:40 AM
> >> To: CRANFORD, CHRIS
> >> Cc: Struts Users Mailing List; Maurizio Cucchiara
> >> Subject: Re: RE: Re : Re : ModelDriven & Hibernate Entities
> >>
> >> On Thu, Mar 10, 2011 at 11:38 AM, CRANFORD, CHRIS wrote:
> >> > Yes the plugin is in the app's lib directory.
> >>
> >> Just FYI, that sets the object factory to "spring", so Spring is
> >> instantiating your actions.
> >>
> >> (At least it used to.)
> >>
> >> Dave
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> > For additional commands, e-mail: user-h...@struts.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
> 
                                          

Reply via email to