Martin Gainty wrote:
yes the Struts 1.x if tag has been deprecated

you can check for specific attributes as wes suggested OR
change your struts-spring autowire type to "constructor" in your interceptor 
stack e.g.
\WEB-INF\src\java\struts.xml

<interceptors>
  <interceptor name="autowire" 
class="com.opensymphony.xwork.spring.interceptor.ActionAutowiringInterceptor">
    <param name="autowireStrategy">2</param>
  </interceptor>
  <interceptor-stack name="autowireDefault">
    <interceptor-ref name="autowire"/>
    <interceptor-ref name="defaultStack"/>
  </interceptor-stack>
</interceptors>
and configure the springframework ContextLoaderListener in web.xml

<listener>
  
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

where the individual bean has been configured as

<bean name="some-action" class="fully.qualified.class.name" singleton="false">
</bean>
take a brief look at the characteristics of your Bean class from Bean.java

    public boolean start(Writer writer) {
        boolean result = super.start(writer);
        ValueStack stack = getStack();
        try {
            String beanName = findString(name, "name", "Bean name is required. 
Example: com.acme.FooBean");
            bean = objectFactory.buildBean(ClassLoaderUtil.loadClass(beanName, 
getClass()), stack.getContext());
        } catch (Exception e) {
            LOG.error("Could not instantiate bean", e);
            return false;
        }

        // push bean on stack
        stack.push(bean);
...
}
that last statement stack.push(bean) means the bean is now on the stack to test 
with!

from jsp
<s:property value="#beanname" />

we now know the bean as a constructed Bean object
(via the decorated name of the bean)
feel free to use the stack.push to push the necessary value to be accessed
later by <s:property ... /> in your jsp..

Seems like it'd be way easier just to expose it as an action property.

Dave


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

Reply via email to