2013-10-08 118 views
1

Primefaces 3.5.16,JBoss 7.2.0,PE 0.7.1,Mojara 2.1.26,WELD-000900 1.1.10(最終) Web.xml有一些配置的東西,faces- config定義了語言包。OmniFaces必填字段1.6.1

我有以下對話與一些輸入字段和p:TabView的:

<p:dialog> 

    <h:form> 
    <p:tabView binding="#{tabViewEL}"> 
    <p:messages autoUpdate="true"/> 
    <p:tab title="tab1"> 

    <p:inputText value="#{bean.value1}" required="true" /> 
    <p:inputText value="#{bean.value2}" /> 
    <p:selectOneMenu value="#{bean.value3}"> 
     <f:selectItems value="#{bean.items1}"></f:selectItems> 
    </p:selectOneMenu> 
    </p:tab> 
    <p:tab> ... </p:tab> 
    </p:tabView> 

    <p:commandButton value="ok" oncomplete="checkAndHide(xhr, status, args);" action="#{bean.action()}"/> 
    </h:form> 

</p:dialog> 

如果我點擊 「OK」,我使用OmniFaces v 1.5或1.6它的功能的權利。如果我使用的是1.6.1,則所有必填字段(和p:selectOneMenu沒有null-selected-Item)都會標記爲紅色,並顯示錯誤「需要值」。我如何在沒有驗證錯誤的情況下使用1.6.1?

編輯:我試圖創建一個例子,但我發現應用程序的另一個奇怪的行爲。使用OmniFaces 1.6,它的功能正確,但在1.6.1中,輸入字段沒有填充值。

OmnitestBean.java 
import java.io.Serializable; 

import javax.annotation.PostConstruct; 
import javax.enterprise.context.SessionScoped; 
import javax.inject.Named; 

@Named 
@SessionScoped 
public class OmnitestBean implements Serializable{ 
private Integer value1 = 12; 
private Integer value2 = 3; 

public OmnitestBean(){ 
    System.out.println("Constru"); 
} 

@PostConstruct 
public void a(){ 
    value1 = 14; 
    value2 = 30; 
    System.out.println("in postconstruct"); 
} 

public Integer getValue1() { 
    return value1; 
} 

public void setValue1(Integer value1) { 
    this.value1 = value1; 
} 

public Integer getValue2() { 
    return value2; 
} 

public void setValue2(Integer value2) { 
    this.value2 = value2; 
} 

public void action(){ 
    System.out.println("In action"); 
} 

} 

omnifaces.xhtml:

<!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" 
xmlns:fn="http://java.sun.com/jsp/jstl/functions" 
xmlns:pe="http://primefaces.org/ui/extensions"> 
<h:head /> 
<body> 
<h:form id="editPopForm"> 
    <p:messages id="messages2" autoUpdate="true"></p:messages> 
    <p:inputText value="#{omnitestBean.value1}" required="true" /> 
    <p:inputText value="#{omnitestBean.value2}" /> 

    <p:commandButton process="@form" action="#{omnitestBean.action()}" value="OK" 
     update="@form" id="editFormOkButt" /> 
</h:form> 

+0

這很奇怪。將看看它。順便說一句,這不應該是''嗎?請以這樣的方式發佈代碼,以便我可以將它未經修改地複製到''中。有或沒有'checkAndHide'。 – BalusC

+0

對不起,無法複製。請發佈一個真正的SSCCE(即我(和你!)只需在空白的操場WAR環境中複製'n'paste'n'run而不作非顯而易見的修改/存根)的代碼。 – BalusC

+0

謝謝!我會盡力的。很遺憾,我無法以原始形式發送我的代碼。 – Tony

回答

1

由於BalusC在他的評論中指出它是與整數轉換器。 我有以下的虛擬整數轉換器,它隱藏在項目中的某個地方。

@FacesConverter(value = "someDummyConverter") 
public class SomeDummyConverter extends IntegerConverter { 
public Object getAsObject(FacesContext context, UIComponent component, 
     String value) { 
    Integer intValue = (Integer) super.getAsObject(context, component, value); 
    return intValue; 
} 

@Override 
public String getAsString(FacesContext context, UIComponent component, Object o) { 
    return null; 
} 
如果我用OmniFaces 1.5或1.6這個轉換器

}

不叫。使用OmniFaces 1.6.1,1.6.2,1.6.3轉換器被調用。如果我刪除了轉換器,問題就消失了。