尝试从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 .... ......
我读了很多帖子但没有成功解决这个问题.请帮忙....
Eclipse Juno/JSF
项目结构:

teste.xhtml:
<!DOCTYPE html[
<!ENTITY nbsp " ">
<!ENTITY copy "©">
] >
<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) 我一直在阅读一些关于javax.faces.default_suffix的帖子,但在尝试实现它时没有成功.
使用:jsf 2.0,jboss 7.1,Mojarra 2.1.5
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)
你能帮我解决这个问题吗?谢谢
我一直在寻找与p:selectCheckBoxMenu相关的所有p:ajax事件
我需要单击selectCheckBoxMenu下拉箭头,然后再次从bean中加载我的对象。
谷歌,但没有成功。
在此先感谢堆栈成员。
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:

我有一个包含很多组件的整个表单,包括ap:tab
当我点击p:commandButton id = c1来提交整个表单内容时:
什么是最好的解决方案?提前致谢.
我在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)