myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shaun Campbell <campbell.sh...@gmail.com>
Subject Re: Accessing multi level data from within my backing bean.
Date Mon, 13 Jul 2009 15:03:05 GMT
Hi Anton

I've got to the bottom of it.

In my existing working data access code I am using beans defined in Springs
applicationContext.xml and using the Spring simpleJdbcTemplate.

    <bean id="jdbcTemplate"
    class="org.springframework.jdbc.core.simple.SimpleJdbcTemplate">
        <constructor-arg>
            <ref bean="dataSource"/>
        </constructor-arg>
    </bean>
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName"
value="ants.jdbc.odbc.JdbcOdbcDriver" />
        <property name="url" value="jdbc:odbc:jtj_dsn"/>
        <property name="initialSize" value="5"/>
        <property name="maxActive" value="10" />
    </bean>
<!-- more bean definitions go here -->
    <bean id="jobsBean" class="uk.co.apps2net.mfm.repository.JdbcJobsDao">
        <property name="dataSource" ref="dataSource" />
    </bean>
        <bean id="jobBean" class="uk.co.apps2net.mfm.repository.JdbcJobDao">
        <property name="dataSource" ref="dataSource" />
    </bean>

When I reference jobsBean or jobBean from my web page it knows it's a Spring
bean and injects the jdbcTemplate into it.  In my web page when I access
#{job.ops} job is not recognised as a bean, the template is not injected
into it and the query fails with the null pointer.

What I need is something like this link I have that creates a jobBean, sets
parameters and retrieves the data.

<t:commandLink action="#{jobBean.getJob}" title="#{job.description}" >

                                    <h:outputText
value="#{job.orderNum}/#{job.itemNum}/#{job.jobNum}"/>
                                    <f:setPropertyActionListener
target="#{jobBean.orderNum}"

value="#{job.orderNum}"/>
                                    <f:setPropertyActionListener
target="#{jobBean.itemNum}"

value="#{job.itemNum}"/>
                                    <f:setPropertyActionListener
target="#{jobBean.jobNum}"

value="#{job.jobNum}"/>

</t:commandLink>

Any thoughts as to how I can get around this?  Actually thinking about it
this may be a Spring issue as what I probably need to do is create a jobBean
in my data access code prior to trying to retrieve the data.

Thanks
Shaun

Mime
View raw message