I checked again and in fact the messages of the FIRST action in the chain
which implements

        public void setActionMessages(Collection messages)
        {
                m_actionMessages = messages;
        }

        public Collection getActionMessages()
        {
                return m_actionMessages;
        }

will get displayed via

           <ww:iterator value="actionMessages">
               <ww:property/>
         </ww:iterator>

only if the SECOND action does likewise implement the above actionMessages
property, i.e. setActionMessages(...) and getActionMessages(). I had a
rather quick and casual look into the source of ChainingInterceptor and then
OgnlUtil. While being a total newbie to OGNL it seems as if the action
itself is not pushed onto te stack but rather its properties are copied to
corresponding properties of the second action:

In ChainingInterceptor:

protected void before(ActionInvocation invocation) throws Exception {
        OgnlValueStack stack = invocation.getStack();
        CompoundRoot root = stack.getRoot();
                Iterator iterator = root.iterator();
                iterator.next();
        while(iterator.hasNext()) {
            Object o = iterator.next();
            OgnlUtil.copy(o, invocation.getAction(),
ActionContext.getContext().getContextMap());
        }
}

In OgnlUtil:

public static void copy(Object from, Object to, Map context) {
        Map contextFrom = Ognl.createDefaultContext(from);
        Ognl.setTypeConverter(contextFrom, XWorkConverter.getInstance());

        Map contextTo = Ognl.createDefaultContext(to);
        Ognl.setTypeConverter(contextTo, XWorkConverter.getInstance());

        BeanInfo beanInfoFrom = null;

        try {
            beanInfoFrom = Introspector.getBeanInfo(from.getClass(),
Object.class);
        } catch (IntrospectionException e) {
            log.error("An error occured", e);

            return;
        }

        PropertyDescriptor[] pds = beanInfoFrom.getPropertyDescriptors();

        for (int i = 0; i < pds.length; i++) {
            PropertyDescriptor pd = pds[i];

            try {
                Object expr = compile(pd.getName());
                Object value = Ognl.getValue(expr, contextFrom, from);
                Ognl.setValue(expr, contextTo, to, value);
            } catch (OgnlException e) {
                // ignore, this is OK
            }
        }
    }

If this qualifies as a bug I will register one with Jira.

> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of
> Jason Carreira
> Sent: Thursday, November 13, 2003 2:13 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [OS-webwork] [WW2] How to pass action properties in chained
> actions
>
>
> The first action SHOULD be on the stack and be available for the view
> page... If it's not, please log a bug in Jira.
>
> > -----Original Message-----
> > From: Olaf Bergner [mailto:[EMAIL PROTECTED]
> > Sent: Thursday, November 13, 2003 7:40 AM
> > To: [EMAIL PROTECTED]
> > Subject: RE: [OS-webwork] [WW2] How to pass action properties
> > in chained actions
> >
> >
> > No, I think it's really a case of chained actions. I have one
> > action that get's called every time the "user form" is
> > displayed in order to populate it with the pertinent
> > information, i.e. the list of all users. I have got some
> > other actions that handle deleting, creating and editing
> > users. So if a user is deleted my app will call
> > "DeleteUserAction" which deletes the user, puts a message
> > stating "User Bond, James was successfully removed from our
> > database." onto the property stack (is that correct ww2
> > lingo?) and transfers control to the "GotoUserMainFormAction"
> > which reads the updated user list from the db and dispatches
> > to "userMainForm.jsp". Obviously I will want the message
> > issued by "DeleteUserAction" preserved along the action chain.
> >
> > Anyhow, the ChainingInterceptor does the trick quite nicely.
> > One minor issue that is left is that in
> > "GotoUserMainFormAction" I have to implement a corresponding
> > property "actionMessages" if I want these messages displayed
> > on the result page. Is this how the ChainingInterceptor
> > works, i.e. it transfers those properties that are also
> > present in the second action from the first action to said
> > second action? From the paragraph in the docs I would have
> > guessed that the first action is preserved on the stack and
> > any of its properties will be accessible as long as they
> > won't be hidden by properties of the second action.



-------------------------------------------------------
This SF.Net email sponsored by: ApacheCon 2003,
16-19 November in Las Vegas. Learn firsthand the latest
developments in Apache, PHP, Perl, XML, Java, MySQL,
WebDAV, and more! http://www.apachecon.com/
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork

Reply via email to