0

以下の環境で簡単なアプリケーションを開発したいと考えています。

  1. JBoss 7.1.1
  2. JBoss シーム 2.3
  3. JSF2.0
  4. Rifaces 4.0
  5. スプリング 3.0
  6. JPA2.0
  7. JBoss Tool 3.2 を使用した Eclipse IDE

ほとんどの構成は適切に機能します。しかし、Seam Action Bean から Spring Bean を注入できません。ページが読み込まれるときにエラーと例外はありません。私のデータテーブルは

web.xml では、

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>jsf-seam</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.seam</url-pattern>
  </servlet-mapping>
  <context-param>
    <param-name>org.richfaces.skin</param-name>
    <param-value>blueSky</param-value>
  </context-param>
  <listener>
    <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
  </listener>
  <filter>
    <filter-name>Seam Filter</filter-name>
    <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>Seam Filter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <servlet>
    <servlet-name>Seam Resource Servlet</servlet-name>
    <servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>Seam Resource Servlet</servlet-name>
    <url-pattern>/seam/resource/*</url-pattern>
  </servlet-mapping>
  <context-param>
    <param-name>facelets.DEVELOPMENT</param-name>
    <param-value>true</param-value>
  </context-param>
  <context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>.xhtml</param-value>
  </context-param>
  <security-constraint>
    <display-name>Restrict raw XHTML Documents</display-name>
    <web-resource-collection>
      <web-resource-name>XHTML</web-resource-name>
      <url-pattern>*.xhtml</url-pattern>
    </web-resource-collection>
    <auth-constraint/>
  </security-constraint>
</web-app>  

faces-config.xml 内

<?xml version="1.0" encoding="UTF-8"?>
<faces-config
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
    version="2.0">
    <application>
        <locale-config>
            <default-locale>en</default-locale>
        </locale-config>
    </application>
</faces-config>

component.xml;

<?xml version="1.0" encoding="UTF-8"?>
<components xmlns="http://jboss.org/schema/seam/components"
            xmlns:core="http://jboss.org/schema/seam/core"
            xmlns:persistence="http://jboss.org/schema/seam/persistence"
            xmlns:drools="http://jboss.org/schema/seam/drools"
            xmlns:bpm="http://jboss.org/schema/seam/bpm"
            xmlns:security="http://jboss.org/schema/seam/security"
            xmlns:mail="http://jboss.org/schema/seam/mail"
            xmlns:web="http://jboss.org/schema/seam/web"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns:spring="http://jboss.com/products/seam/spring"
            xsi:schemaLocation=
                "http://jboss.org/schema/seam/core http://jboss.org/schema/seam/core-2.3.xsd
                 http://jboss.org/schema/seam/persistence http://jboss.org/schema/seam/persistence-2.3.xsd
                 http://jboss.org/schema/seam/drools http://jboss.org/schema/seam/drools-2.3.xsd
                 http://jboss.org/schema/seam/bpm http://jboss.org/schema/seam/bpm-2.3.xsd
                 http://jboss.org/schema/seam/security http://jboss.org/schema/seam/security-2.3.xsd
                 http://jboss.org/schema/seam/mail http://jboss.org/schema/seam/mail-2.3.xsd
                 http://jboss.org/schema/seam/web http://jboss.org/schema/seam/web-2.3.xsd
                 http://jboss.org/schema/seam/components http://jboss.org/schema/seam/components-2.3.xsd">

   <core:init debug="true" jndi-pattern="@jndiPattern@"/>
   <spring:context-loader config-locations="classpath:spring-bean.xml"/>
   <core:manager concurrent-request-timeout="500"
                 conversation-timeout="120000"
                 conversation-id-parameter="cid"
                 parent-conversation-id-parameter="pid"/>

   <!-- Make sure this URL pattern is the same as that used by the Faces Servlet -->
   <web:hot-deploy-filter url-pattern="*.seam"/>

   <!-- If you are still using JBoss 4, uncomment this to have your PU started -->
<!--   <persistence:entity-manager-factory name="entityManagerFactory"-->
<!--                      persistence-unit-name="jsf-seam"/>-->
   <!-- If you are still using JBoss 4, uncomment this to have the entityManagerFactory ysed -->
<!--   <persistence:managed-persistence-context name="entityManager" auto-create="true"-->
<!--                          entity-manager-factory="#{entityManagerFactory}"/>-->

   <persistence:managed-persistence-context name="entityManager" auto-create="true"
                           persistence-unit-jndi-name="java:/jsf-seamEntityManagerFactory"/>

   <drools:rule-base name="securityRules">
      <drools:rule-files><value>/security.drl</value></drools:rule-files>
   </drools:rule-base>

   <security:rule-based-permission-resolver security-rules="#{securityRules}"/>

   <security:identity authenticate-method="#{authenticator.authenticate}" remember-me="true"/>

   <event type="org.jboss.seam.security.notLoggedIn">
      <action execute="#{redirect.captureCurrentView}"/>
   </event>
   <event type="org.jboss.seam.security.loginSuccessful">
      <action execute="#{redirect.returnToCapturedView}"/>
   </event>

   <mail:mail-session host="localhost" port="25"/>

   <!-- For use with jBPM pageflow or process management -->
   <!--
   <bpm:jbpm>
      <bpm:process-definitions></bpm:process-definitions>
      <bpm:pageflow-definitions></bpm:pageflow-definitions>
   </bpm:jbpm>
   -->

</components>

私の Seam アクション Bean では;

@Scope(CONVERSATION)
@Name("ManageDepartmentBean")
public class ManageDepartmentBean implements Serializable {
    private static final long serialVersionUID = -4373053763864526454L;

    @Out(value = "departmentList")
    public List<Department> departmentList;

        public List<Department> getDepartmentList() {
            return departmentList;
        }   

    @In("#{DepartmentService}")
    private IDepartmentService departmentService;

    @Begin
    public String begin() {
        departmentList = departmentService.findAllDepartments();
        return "success";
    }


    public String increment() {
        return "success";
    }


    @End
    public String end() {
        return "home";
    }
}

私の春の豆で。

@Service(value = "DepartmentService")
public class DepartmentService implements IDepartmentService{
    @Resource(name = "DepartmentDAO")
    private IDepartmentDAO departmentDAO;

    @Transactional(propagation = Propagation.REQUIRED)
    public List<Department> findAllDepartments() {
        return departmentDAO.findAll();
    }
}

また、web.xml で以下のように使用しようとしましたが、機能しません。

  <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath:spring-beans.xml</param-value>
  </context-param>
  <listener>
      <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>

私のページで;

    <rich:dataTable value="#{ManageDepartmentBean.departmentList}" var="dep" id="departmentTable">
        <rich:column sortBy="#{dep.id}">
            <f:facet name="header">
                <h:outputText value="Department ID"/>
            </f:facet>
            <h:outputText value="#{dep.id}" />
        </rich:column>
        <rich:column sortBy="#{dep.name}">
            <f:facet name="header">
                <h:outputText value="Name"/>
            </f:facet>
            <h:outputText value="#{dep.name}" />
        </rich:column>
        <rich:column sortBy="#{dep.description}">
            <f:facet name="header">
                <h:outputText value="Description"/>
            </f:facet>
            <h:outputText value="#{dep.description}}" />
        </rich:column>
    </rich:dataTable>
4

1 に答える 1

0

@In アノテーションを使用して、Seam アクション Bean から Spring Bean を注入できます。spring-bean.xml または applicationContext.xml に seam コンポーネントの設定を行う必要はありません。

web.xml 内

 <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath:spring-beans.xml</param-value>
  </context-param>
  <listener>
      <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>

faces-config.xml 内

<application>
    <variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver>   
</application>
于 2012-09-18T04:45:50.897 に答える