[jboss-user] [JBoss Seam] - UISelectOne: Value is not a valid option.

blady do-not-reply at jboss.com
Wed Sep 6 14:18:53 EDT 2006


Hi!

I have a big problem with JSF validation. I don't know why but when i submit a form i get "Value is not a valid option" error for h:selectOneMenu control. I'm using @SelectItems binder with my converter:

xhtml:

  | <h:selectOneMenu class="configInput" 
  |         id="tAccountStatus"
  |         value="#{bankAccountControl.instance.idBankAccountStatus}"
  |         converter="#{bankAccountStatusFinder.converter}">
  |     <f:selectItems value="#{bankAccountStatusList}"/>
  | </h:selectOneMenu>
  | 

#{bankAccountStatusList}:

  | @SelectItems(valueStrategy=SelectItems.Strategy.OBJECT, labelMethod="getStatusName")
  |     private List<BankAccountStatus> bankAccountStatusList;
  | 
  | @Factory("bankAccountStatusList")
  | public void findBankAccountStatuses() {
  |     bankAccountStatusList = entityManager
  |         .createQuery("FROM BankAccountStatus bas ORDER BY bas.statusName")
  |         .getResultList();	
  | }
  | 

#{bankAccountControl.instance}:

  | @Valid
  | private BankAccount bankAccount;
  | 
  | public BankAccount getInstance() {
  |     return bankAccount;
  | }
  | 

#{bankAccountStatusFinder.converter}:

  | static public class BankAccountStatusConverter 
  |         implements Converter, Serializable {
  | 
  |     private static final long serialVersionUID = 3820066884549543875L;
  | 	
  |     List<BankAccountStatus> bankAccountStatusList;
  |     
  |     public BankAccountStatusConverter(
  |         List<BankAccountStatus> bankAccountStatusList){
  |             this.bankAccountStatusList = bankAccountStatusList;
  |         }
  | 	    
  |     public String getAsString(FacesContext facesContext,
  | 	                              UIComponent  component, 
  | 	                              Object       obj) {
  | 	        if (obj == null) return null;
  | 	
  |         BankAccountStatus bankAccountStatus = (BankAccountStatus) obj;
  |         String val = String.valueOf(bankAccountStatus.getIdBankAccountStatus());
  |         return val;
  |     }
  | 	    
  |     public Object getAsObject(FacesContext facesContext,
  | 	                              UIComponent  component, 
  | 	                              String       str) throws ConverterException {
  | 	    	
  |         if (str == null || str.length()==0) {
  |             return null;
  |         }
  | 	
  |         long id = Long.valueOf(str).longValue();
  |         for (BankAccountStatus bankAccountStatus : bankAccountStatusList){
  |             if (bankAccountStatus.getIdBankAccountStatus() == id) {
  |                 return bankAccountStatus;
  |             }
  |         }	
  |     return null;
  |     }
  | }
  | 

There is no any exception on console, anything. Only message from JSF that "Value is not a valid option", i don't know how to make it works.

Please help.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3969828#3969828

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3969828



More information about the jboss-user mailing list