0

我正在开发一个 JSF 2.0 应用程序,我正在尝试以编程方式将 ajax 操作添加到以编程方式创建的 UIComponent(相当于 commandLink 中静态声明的 f:ajax 侦听器),如本博客所示。

当我尝试获取 ExpressionFactory 以创建 MethodExpression 时,这样:

FacesContext fc = FacesContext.getCurrentInstance();
Application application = fc.getApplication();
ExpressionFactory ef = fc.getApplication().getExpressionFactory();

所以,就在我写这些行时,我收到一个错误消息:

The method getExpressionFactory() from the type Application refers to the missing type ExpressionFactory.

唯一可用的快速修复是配置构建路径。

我不知道我到底应该做什么,我是否缺少任何 JAR 来解决这个问题?

这是我的pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>esprit.pfe2013</groupId>
  <artifactId>GCFTest4addUIC</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>GestionCongesFeki Maven Webapp</name>
  <url>http://maven.apache.org</url>

<repositories>
        <repository>
            <id>central</id>
            <name>Maven Repository Switchboard</name>
            <layout>default</layout>
            <url>http://repo1.maven.org/maven2</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>       
        <repository>
            <id>prime-repo</id>
            <name>Prime Repo</name>
            <url>http://repository.primefaces.org</url>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>central</id>
            <name>Maven Plugin Repository</name>
            <url>http://repo1.maven.org/maven2</url>
            <layout>default</layout>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <releases>
                <updatePolicy>never</updatePolicy>
            </releases>
        </pluginRepository>
    </pluginRepositories>

<!--   <repositories> -->
<!-- <repository> -->
<!--            <id>central</id> -->
<!--            <name>Central Repository</name> -->
<!--            <url>http://repo.maven.apache.org/maven2</url> -->
<!--            <layout>default</layout> -->
<!--            <snapshots> -->
<!--                <enabled>false</enabled> -->
<!--            </snapshots> -->
<!--        </repository> -->


<!--    </repositories> -->

    <dependencies>
<dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.0.1</version>        
</dependency>


        <!-- PrimeFaces -->
        <dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>3.4.1</version>
        </dependency>


        <!-- JSF 2 -->
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-api</artifactId>
            <version>2.1.11</version>
        </dependency>
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-impl</artifactId>
            <version>2.1.11</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>taglibs</groupId>
            <artifactId>standard</artifactId>
            <version>1.1.2</version>
        </dependency>




        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.13</version>
        </dependency>


        <dependency>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <version>2.4.3</version>
</dependency>






    </dependencies>
    <build>
    <finalName>GCFTest4addUIC</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
        </plugins>
    </build>





</project>
4

0 回答 0