Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

SelectOneMenu strange behavior: "Validation Error: Value is not valid"

843844Jun 15 2008 — edited Jun 23 2008
Hello,

I have 2 select-one. When I select any item from the first select-one, and I leave the second select-one with the default item value (1) it is all ok.
But when I try to select an item from the second select-one I receive this message:
16-giu-2008 1.06.51 com.sun.faces.lifecycle.RenderResponsePhase execute
INFO: WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
sourceId=formInsertShip:newShip:fkcontractorcontact[severity=(ERROR 2), summary=(formInsertShip:newShip:fkcontractorcontact: Validation Error: Value is not valid), detail=(formInsertShip:newShip:fkcontractorcontact: Validation Error: Value is not valid)]
First I tried with raw int type but I receveid the same error in both cases above, then I tried with String.valueOf() that solved the
case of the 1st select-one, but not the 2nd... I am really going slightly mad, please can you help me to find a clear solution to solve this problem?
Thank in advance.

JSF Code:
			<h:selectOneMenu id="fkcontractorsite" value="#{contractorshipMBean.fkcontractorsite}">
			  <f:selectItems value="#{contractorshipMBean.listWrappedSites}" />
			  <f:selectItem itemValue="1" itemLabel="this is always ok" />
			</h:selectOneMenu>
			<h:outputText value="Contractor ship contact"></h:outputText>
			<h:selectOneMenu id="fkcontractorcontact" value="#{contractorshipMBean.fkcontractorcontact}">
			  <f:selectItems value="#{contractorshipMBean.listWrappedContacts}" />
			  <f:selectItem itemValue="1" itemLabel="this is always ok" />
			</h:selectOneMenu>
BackingBean:
	public List<SelectItem> getListWrappedSites() {
		List<SelectItem> listWrappedSites = new ArrayList<SelectItem>();
		try {
			FacesContext facesContext = FacesContext.getCurrentInstance();
			String crid = facesContext.getExternalContext().getRequestParameterMap().get("crid");
			int cridInt = 0;
			if (crid==null)
				cridInt = AStaticDao.readContractorByShip(this);
			else
				cridInt = Integer.parseInt(crid);
			List<Contractorsite> list = AStaticDao.listSitesByContractor(cridInt);
			Iterator<Contractorsite> it = list.iterator();
			while(it.hasNext()) {
				Contractorsite site = it.next();
				javax.faces.model.SelectItem si = new javax.faces.model.SelectItem(String.valueOf(site.getCstid()),site.getCstcity());
				listWrappedSites.add(si);
			}
		} catch (Exception e) {
			listWrappedSites = null;
			e.printStackTrace();
		}
        return listWrappedSites;
    }
	
	public List<SelectItem> getListWrappedContacts() {
		List<SelectItem> listWrappedContacts = new ArrayList<SelectItem>();
		try {
			FacesContext facesContext = FacesContext.getCurrentInstance();
			String crid = facesContext.getExternalContext().getRequestParameterMap().get("crid");
			int cridInt = 0;
			if (crid==null)
				cridInt = AStaticDao.readContractorByShip(this);
			else
				cridInt = Integer.parseInt(crid);
			List<Contractorcontact> list = AStaticDao.listContactsByContractor(cridInt);
			Iterator<Contractorcontact> it = list.iterator();
			while(it.hasNext()) {
				Contractorcontact contact = it.next();
				//ContractorcontactMBean beanCopy = new ContractorcontactMBean();
				//BeanUtils.copyProperties(beanCopy, contact);
				javax.faces.model.SelectItem si = new javax.faces.model.SelectItem(String.valueOf(contact.getCnid()),String.valueOf(contact.getCnname()));
				//javax.faces.model.SelectItem si = new javax.faces.model.SelectItem(beanCopy,beanCopy.getCnname());
				listWrappedContacts.add(si);
			}
		} catch (Exception e) {
			listWrappedContacts = null;
			e.printStackTrace();
		}
        return listWrappedContacts;
    }
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 21 2008
Added on Jun 15 2008
2 comments
345 views