小编Al2*_*l2x的帖子

Hibernate异常:枚举类的未知名称值

尝试从DB中检索记录时,我收到枚举类的未知名称值.使用JSF 2.0,JPA.

我的数据库中的可能值是'F'或'J'

枚举:

public enum TipoPessoa {

    FISICA ("F", "Física"),
    JURIDICA ("J", "Jurídica");

    private final String id;
    private final String descricao;

    private TipoPessoa(String id, String descricao){
        this.id = id;
        this.descricao = descricao;
    }

    public String getId() {
        return id;
    }

    public String getDescricao(){
        return descricao;
    }
}
Run Code Online (Sandbox Code Playgroud)

实体:

@Column(nullable=false, length=1)
private TipoPessoa tipoPessoa;

public TipoPessoa getTipoPessoa() {
    return tipoPessoa;
}

public void setTipoPessoa(TipoPessoa tipoPessoa) {
    this.tipoPessoa = tipoPessoa;
}
Run Code Online (Sandbox Code Playgroud)

当我尝试从DB读取记录时,我收到了错误

你能帮我解决这个问题吗?谢谢

堆栈跟踪:

javax.servlet.ServletException:枚举类的未知名称值br.com.aaa.xxx.entidade.TipoPessoa:F javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)br.com.aaa.filtro.FiltroEncode .doFilter(FiltroEncode.java:26)根本原因

javax.ejb.EJBTransactionRolledbackException:枚举类的未知名称值br.com.aaa.xxx.entidade.TipoPessoa:F .... ......

java enums hibernate jpa

18
推荐指数
1
解决办法
3万
查看次数

JSF中的RES_NOT_FOUND

我读了很多帖子但没有成功解决这个问题.请帮忙....

Eclipse Juno/JSF

项目结构: 在此输入图像描述

teste.xhtml:

<!DOCTYPE html[
    <!ENTITY nbsp "&#160;"> 
    <!ENTITY copy "&#169;">
] >
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
  <h:outputScript library="js" name="slides.min.jquery.js"/>
  <h:graphicImage value="images/blog.png" />
  <h:outputStylesheet name="css/estilo.css"/>
  </h:head>
  <h:body>
  #{javax.faces.resource}
  </h:body>
  </html>
Run Code Online (Sandbox Code Playgroud)

输出是:

<link type="text/css" rel="stylesheet" href="RES_NOT_FOUND">
Run Code Online (Sandbox Code Playgroud)

与js和图像相同的res_not_found

pom.xml:

<dependencies>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>6.0</version>
        <scope>provided</scope>
    </dependency>

<dependency>
    <groupId>org.primefaces</groupId>
    <artifactId>primefaces</artifactId>
    <version>4.0</version>
</dependency>

<dependency>
    <groupId>org.primefaces.extensions</groupId>
    <artifactId>all-themes</artifactId>
    <version>1.0.8</version>
</dependency>

<dependency>
    <groupId>com.sun.facelets</groupId>
    <artifactId>jsf-facelets</artifactId>
    <version>1.1.14</version>
</dependency>


<dependency>
    <groupId>com.sun.faces</groupId>
    <artifactId>jsf-impl</artifactId>
    <version>2.1.23</version>
    <scope>provided</scope>
</dependency>

<dependency>
    <groupId>com.sun.faces</groupId>
    <artifactId>jsf-api</artifactId>
    <version>2.1.23</version>
    <scope>provided</scope>
</dependency>       

<dependency>
    <groupId>javax.faces</groupId>
    <artifactId>javax.faces-api</artifactId>
    <version>2.2</version>
</dependency> …
Run Code Online (Sandbox Code Playgroud)

css eclipse jsf jboss facelets

6
推荐指数
1
解决办法
2万
查看次数

javax.faces.DEFAULT_SUFFIX无效

我一直在阅读一些关于javax.faces.default_suffix的帖子,但在尝试实现它时没有成功.

使用:jsf 2.0,jboss 7.1,Mojarra 2.1.5

  • 我需要在URL中显示以下内容:localhost:8080/myproject/index.jsf
  • 导航时还需要显示xxx.jsf

web.xml中

<welcome-file-list>
    <welcome-file>/comum/inicio/index.xhtml</welcome-file>
</welcome-file-list>

<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>  **have tried *.jsf but with no success**
</servlet-mapping>

<context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>.jsf</param-value>
</context-param>
Run Code Online (Sandbox Code Playgroud)

你能帮我解决这个问题吗?谢谢

navigation jsf web.xml servlets facelets

5
推荐指数
1
解决办法
5816
查看次数

p:selectCheckboxMenu和可用的p:ajax事件

我一直在寻找与p:selectCheckBoxMenu相关的所有p:ajax事件

我需要单击selectCheckBoxMenu下拉箭头,然后再次从bean中加载我的对象。

谷歌,但没有成功。

在此先感谢堆栈成员。

events primefaces

4
推荐指数
1
解决办法
1万
查看次数

在inputText中按Enter键后执行命令

Mojarra 2.1.5/PrimeFaces 3.5

我不知道如何解释.我有一个inputText和commandButton当我在inputText中键入内容并按Enter键时,我需要自动执行commandButton.

<p:inputText id="txtProducao" required="false"
    value="#{ManagedBean.xxxPreco.producaoDia}"
    requiredMessage="#{bundle.xxPreco_xProdx}>
</p:inputText>
<p:commandButton id="buttonProducaoDia" 
    icon="ui-icon-check"
    actionListener="#{ManagedBean.calculaProdxxx}"
    update="txtValorSoma">
</p:commandButton>
Run Code Online (Sandbox Code Playgroud)

我需要为每个inputText键入一些值,然后在Enter后我需要执行相应的commandButton:

在此输入图像描述

jsf primefaces

4
推荐指数
1
解决办法
2735
查看次数

仅验证表单的特定部分而不是整个表单

我有一个包含很多组件的整个表单,包括ap:tab

当我点击p:commandButton id = c1来提交整个表单内容时:

  • 我需要验证整个表单所需的消息,但我确实需要忽略p:tab必需的消息字段.
  • 如果我在p:选项卡中单击p:commandButton id = c2,我只需要验证p:选项卡中所需的消息字段.

什么是最好的解决方案?提前致谢.

forms validation jsf primefaces

3
推荐指数
1
解决办法
2192
查看次数

java.lang.NoClassDefFoundError:javax/faces/context/FacesContext

我在Eclipse中有两个Web项目:Framework和webxxx

在我的框架中,我有一些utils功能,如复制,下载,上传等...

当我从webxxx我得到的电话下载方法*java.lang.NoClassDefFoundError: javax/faces/context/FacesContext*.

如果我将GerenciarArquivo类移动到webxxx项目,则downloadFile方法可以正常工作.

框架:

public abstract class GerenciarArquivo{
...
public static void downloadFile(String filePath) throws IOException{
    FacesContext context = FacesContext.getCurrentInstance();  
    HttpServletResponse response = (HttpServletResponse) context  
                         .getExternalContext().getResponse(); 
Run Code Online (Sandbox Code Playgroud)

WEBXXX项目:

GerenciarArquivo.downloadFile(abb.getPath());
Run Code Online (Sandbox Code Playgroud)

这两个项目都有:

在此输入图像描述 在此输入图像描述

Web xxx项目依赖项:

<dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>6.0</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.primefaces</groupId>
        <artifactId>primefaces</artifactId>
        <version>3.5</version>
    </dependency>

    <dependency>
        <groupId>org.primefaces.themes</groupId>
        <artifactId>all-themes</artifactId>
        <version>1.0.9</version>
    </dependency>


    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-impl</artifactId>
        <version>2.2.4</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-api</artifactId>
        <version>2.2.4</version>
        <scope>provided</scope>
    </dependency>       

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>3.0-alpha-1</version>
        <scope>provided</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)

框架依赖:

<dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>6.0</version>
    </dependency> …
Run Code Online (Sandbox Code Playgroud)

java jsf maven

0
推荐指数
1
解决办法
1万
查看次数