English 中文(简体)
@FacesConverter 防止用法打字: OneMenu and p:ajax
原标题:@FacesConverter prevents method call of p:selectOneMenu and p:ajax

I have a weird problem with a custom @FacesConverter with JBoss-7.1.0.CR1b during an AJAX call in p:selectOneMenu (Primefaces 3.0).

简化的Converter认为,本类没有国民教育体系或其他例外。

@FacesConverter("MyConverter")
public class MyConverter implements Converter
{      
  public Object getAsObject(FacesContext fc, UIComponent uic, String value)
  {
    logger.debug("getAsObject value: "+value);
    if (submittedValue.trim().equals("")) {return null;}
    else
    {           
      MyEjb ejb = new MyEjb();
      ejb.setId(Long.parseLong(value()));
      return ejb;  //**** alternative with return null; ****
    }
  }  
  public String getAsString(FacesContext fc, UIComponent uic, Object value)
  { 
    if (value == null || value.equals("")) {return "";}
    else
    {
        MyEjb ejb = (MyEjb)value;
        return ""+ejb.getId(); 
    }  
  }  
}

转换器在<代码>p:电子计算器中使用 1Menu:

<h:form>  
  <p:selectOneMenu value="#{clientBean.selected}" converter="MyConverter">
    <f:selectItems value="#{clientBean.all}" var="my"
                   itemLabel="#{my.name}" itemValue="#{my}"/>
      <p:ajax listener="#{clientBean.changed}" />  
  </p:selectOneMenu>
</h:form>

这种方法不是火箭工程,而是经过改变的,只是造成 de:

public void changed()
{
  logger.info("changed() "+selected);
}

但现在宣布: <changed(>>从来不使用上述代码,但我得到转手的援引 3<>>。

12:37:51,500 DEBUG getAsObject value: 35
12:37:51,502 DEBUG getAsObject value:
12:37:51,503 DEBUG getAsObject value:

如果我改动<代码>p:select OneMenu Value=”#{clientBean.s selectedId}"至 长期选定 Id,不使用“电离器”方法。 即便在<条码>上“Ireturn no>,>changed(>>也称为(收到)。 我并不认为它涉及几个方面,因为如果我使用<代码>h:select OneMenu和f:ajax,我有同样的行为。

最佳回答

You should have a <p:messages />, <p:growl /> or <h:messages /> which is been ajax-updated in your view. You should also pay attention to warnings in server logs about possible missing faces messages. The chance is big that you re seeing the infamous Validation error: Value not valid validation error.

在转换后,如果所提交的物体是可得到的物品之一,作为防范被篡改/被打的要求的一部分,联合基金将予以确认。 共同未来论坛将通过<代码>提交标的(一OfAvailableObjects)对您在<、f:selectItems>、上拥有的每一物体进行。 如果没有任何对应之处,那么,联合调查基金会将显示这一验证错误。

在你的具体情况下,<代码>MyEjb 类别显然没有equis()或其实施被打破。 另见 平等合同执行权途径

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...