Primefaces中的selectOneMenu看起来很奇怪

时间:2013-06-14 12:52:51

标签: jsf primefaces

我有一个让selectOneMenu看起来正常的问题(就像普通的下拉列表一样)。我的代码如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui">

<h:head>
</h:head>
<h:body>
  <h:form >
    <p:selectOneMenu >  
      <f:selectItem itemLabel="Select One" itemValue="" />  
      <f:selectItem itemLabel="Option 1" itemValue="1" />  
      <f:selectItem itemLabel="Option 2" itemValue="2" />  
      <f:selectItem itemLabel="Option 3" itemValue="3" />  
    </p:selectOneMenu>  
  </h:form>       
</h:body>
</html>

我得到的是这样的:

enter image description here

所以,我的问题是:我做错了什么?

我已经在Firefox,Chrome和IE上查看了它,并且在每个浏览器上看起来都一样。

我认为这个问题可能与maven依赖关系有关 - 也许我错过了一些或者有一些我看不到的冲突......

我使用primefaces 3.5。我可以提供maven依赖项的完整列表,但该项目有很多,我不想发布不可读的问题。

修改

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>lcsb.mapviewer</groupId>
<artifactId>MapViewer</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>MapViewer</name>
<url>http://maven.apache.org</url>

<repositories>
    <repository>
        <id>prime-repo</id>
        <name>Prime Repo</name>
        <url>http://repository.primefaces.org</url>
    </repository>
    <repository>
        <id>ebi-repo</id>
        <name>The EBI internal repository</name>
        <url>http://www.ebi.ac.uk/~maven/m2repo</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>       
    <repository>
        <id>org.springframework.security.taglibs.facelets</id>
        <url>http://spring-security-facelets-taglib.googlecode.com/svn/repo/</url>
    </repository>
</repositories>

<properties>
    <springframework.version>3.2.1.RELEASE</springframework.version>
    <springframework.security.version>3.1.3.RELEASE</springframework.security.version>
    <primafaces.version>3.5</primafaces.version>
    <primafaces.themes.version>1.0.8</primafaces.themes.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
    <finalName>MapViewer</finalName>
    <plugins>
        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.1.1</version>
            <configuration>
                <packagingExcludes>WEB-INF/web.xml</packagingExcludes>
            </configuration>
        </plugin>
    </plugins>
</build>

<dependencies>

    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-api</artifactId>
        <version>2.1.7</version>
    </dependency>
    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-impl</artifactId>
        <version>2.1.7</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.primefaces</groupId>
        <artifactId>primefaces</artifactId>
        <version>${primafaces.version}</version>
    </dependency>
    <dependency>
        <groupId>org.primefaces.themes</groupId>
        <artifactId>home</artifactId>
        <version>${primafaces.themes.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.webflow</groupId>
        <artifactId>spring-faces</artifactId>
        <version>2.3.2.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${springframework.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${springframework.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${springframework.version}</version>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>4.1.0.Final</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.8.2</version>
    </dependency>

    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>${springframework.version}</version>
    </dependency> 

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
        <version>${springframework.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>${springframework.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${springframework.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-taglibs</artifactId>
        <version>${springframework.security.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-config</artifactId>
        <version>${springframework.security.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-web</artifactId>
        <version>${springframework.security.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-core</artifactId>
        <version>${springframework.security.version}</version>
    </dependency>
    <dependency>
         <groupId>org.springframework.security</groupId>
         <artifactId>facelets-taglib-jsf20-spring-3</artifactId>
         <version>0.5</version>
    </dependency>

    <dependency>
        <groupId>c3p0</groupId>
        <artifactId>c3p0</artifactId>
        <version>0.9.1.2</version>
    </dependency>

    <dependency>
        <groupId>cglib</groupId>
        <artifactId>cglib</artifactId>
        <version>2.2.2</version>
    </dependency>           

    <dependency>
        <groupId>postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>9.1-901.jdbc4</version>
    </dependency>
    <dependency>
        <groupId>javax.mail</groupId>
        <artifactId>mail</artifactId>
        <version>1.4.1</version>
    </dependency>

    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.2.4</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>commons-fileupload</groupId>
        <artifactId>commons-fileupload</artifactId>
        <version>1.2.2</version>
    </dependency>

    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.4</version>
    </dependency>

    <dependency>
        <groupId>commons-cli</groupId>
        <artifactId>commons-cli</artifactId>
        <version>1.2</version>
    </dependency>

    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>2.2</version>
    </dependency>

    <dependency>
        <groupId>uk.ac.ebi.miriam</groupId>
        <artifactId>miriam-lib</artifactId>
        <version>1.1.5</version>
    </dependency>
    <dependency>
        <groupId>xerces</groupId>
        <artifactId>xerces</artifactId>
        <version>2.4.0</version>
    </dependency>
    <dependency>
        <groupId>batik</groupId>
        <artifactId>batik-rasterizer</artifactId>
        <version>1.6</version>
    </dependency>

    <dependency>
        <groupId>batik</groupId>
        <artifactId>batik-svggen</artifactId>
        <version>1.6</version>
    </dependency>

    <dependency>
        <groupId>javassist</groupId>
        <artifactId>javassist</artifactId>
        <version>3.12.1.GA</version>
    </dependency>

    <dependency>
        <groupId>org.primefaces.extensions</groupId>
        <artifactId>primefaces-extensions</artifactId>
        <version>0.7.1</version>
    </dependency>

</dependencies>
</project>

1 个答案:

答案 0 :(得分:1)

好的,我发现了问题。

我的应用程序实现了spring安全模块(之前我没有提及它,因为我认为它是无关紧要的)。在验证之前访问该页面(它是登录页面)。因此,安全性会禁用对主题资源的访问。为了解决这个问题,我补充道:

<security:http pattern="/javax.faces.resource/**" security="none"/>

到我的配置xml。