struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gabriel Belingueres" <belingue...@gmail.com>
Subject Re: Sanity-check regarding ModelDrivenInterceptor vs. stack order
Date Thu, 17 Jul 2008 13:08:43 GMT
The map would be just an auxiliary data structure to maintain this
propertyName -> ownerObject mapping (I suppose you could just iterate
on every object in the stack using reflection to ask about its
properties, or some fancy method in commons-beanutils library) but the
general idea is the following:

Suppose you have in the stack an Employee object which has a name
property (with its getter/setter). The Employee has pushed by some
interceptor in the interceptor chain. The Map would hold the
("name"->employee) mapping.

Suppose you have a ModelDriven action that returns in the getModel()
method a Person object, which too has a name property. Now when the
interceptor tries to push into the stack, the stack first check if the
properties of this object is already in the map. Because they share a
name property, you can warn the user that you are shadowing then name
property of the employee object.

Of course this checking would belong inside the ValueStack, not in the
ModelDriverInterceptor.


2008/7/17 Dave Newton <newton.dave@yahoo.com>:
> --- On Wed, 7/16/08, Gabriel Belingueres <belingueres@gmail.com> wrote:
>> I believe that we could check on stack.push() if the object
>> to push shadows some other object in the stack with relative ease.
>>
>> The basic idea would be to use a Map<String,Object>
>> where the key is the property name, and the value is
>> the object in the stack with that property name. If
>> the yet to push object has a property that is already
>> in the Map, then it would shadow it (unless of course
>> it is actually the same object), and a warn can be
>> logged/exception thrown (in devMode only).
>
> You lost me--why would we need to keep a shadow map?
>
> The current code checks if a refresh is needed: if it is, the old object is removed via
ArrayList.remove(Object), and if appropriate, the new object is pushed (the stack order change).
>
> To replace the old object ArrayList.indexOf(Object) would retrieve the index and the
new object would be set with ArrayList.set(int, Object).
>
> There's still a potential stack depth issue, though, since if the new value is null it's
not supposed to get put on the stack.
>
> Dave
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>

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


Mime
View raw message