首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >OmniFaces 1.6.1必需字段

OmniFaces 1.6.1必需字段
EN

Stack Overflow用户
提问于 2013-10-08 12:36:19
回答 1查看 241关注 0票数 1

Primefaces 3.5.16,JBoss 7.2.0,PE 0.7.1,Mojara 2.1.26,焊缝-000900 1.1.10 (最终) Web.xml有一些配置,faces-config有语言包定义。

下面有一些输入字段和p:tabview的对话框:

代码语言:javascript
复制
<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,不带空选择项)都被标记为红色,并带有错误“值是必需的”。如何在没有验证错误的情况下使用1.6.1?

编辑:我尝试创建一个示例,但我发现了另一个奇怪的应用程序行为。使用OmniFaces 1.6,它的功能是正确的,但是对于1.6.1,输入字段没有填充值。

代码语言:javascript
复制
 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:

代码语言:javascript
复制
 <!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>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-10-29 13:49:21

正如BalusC在他的评论中所指出的,这与Integer转换器有关。我有下面的虚拟整数转换器,它隐藏在项目的某个地方。

代码语言:javascript
复制
@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调用转换器。如果我删除转换器,问题就消失了。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19247876

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档