Thanks for the help. Indeed in order to access your Spring Beans from a
custom tag handler you need to extend the abstract class
org.springframework.web.servlet.tags.RequestContextAwareTag (which extends
TagSupport) and get a reference to the WebApplicationContext through
getRequestContext()  method.



mraible wrote:
> 
> Dependency Injection for tag libraries is not supported by Spring
> AFAIK. If you can get a pageContext, you should be able to get a
> ServletContext and look up the WebApplicationContext (and all your
> beans) from that.
> 
> Matt
> 
> On Wed, Aug 6, 2008 at 2:28 AM, ensoreus <[EMAIL PROTECTED]> wrote:
>>
>> Hy,
>>
>>        I am using AppFuse version 2 - Struts 2 Basic. I am trying to use
>> a
>> StateTag similar to the CountryTag in appfuse.tld, for displaying a list
>> of
>> available states for the selected country. The states are stored in an
>> Oracle DB 10g table. The manager and dao for the State table are declared
>> as
>> follows in applicationContext.xml :
>>
>>    <!-- Add new DAOs here -->
>>    <bean id="stateDao" class="myPackage.dao.hibernate.StateDaoHibernate">
>>        <property name="sessionFactory" ref="sessionFactory"/>
>>    </bean>
>>
>>    <!-- Add new Managers here -->
>>    <bean id="stateManager"
>> class="myPackage.service.impl.StateManagerImpl">
>>        <property name="stateDao" ref="stateDao"/>
>>    </bean>
>>
>>    <!-- Add new Spring managed beans here -->
>>    <bean id="stateTag" class="myPackage.webapp.taglib.StateTag">
>>        <property name="stateManager" ref="stateManager"/>
>>    </bean>
>>
>> StateTag.java
>>
>>    public class StateTag extends TagSupport {
>>
>>                private stateManager stateManager;
>>
>>                public void setStateManager(StateManager statetManager) {
>>                         this.stateManager = stateManager;
>>                }
>>    }
>>
>>    The problem is that the stateManager Spring bean is null in
>> StateTag.java, so I can't load the states from the database table.
>> Dependency injection doesn't seem to work! What am I doing wrong? Why
>> doesn't Spring inject an instance of stateManager?
>>
>>    Any help at all would be highly appreciated. Thanks.
>>
>> Andrei
>> --
>> View this message in context:
>> http://www.nabble.com/Null-Spring-beans-tp18846526s2369p18846526.html
>> Sent from the AppFuse - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Null-Spring-beans-tp18846526s2369p18865171.html
Sent from the AppFuse - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to