Announcement Announcement Module
Collapse
No announcement yet.
Validation Error: {0}Value is not valid Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Validation Error: {0}Value is not valid

    the following is a part of .jspx file
    Code:
    <tr>
    <td align="left" width="400">
    <h:selectManyListbox value="#{productBean.selectedCategoryIds}" id="selectedCategoryIds">
    				
    <f:selectItems value="#{applicationBean.categorySelectItems}" id="categories"/>
    </h:selectManyListbox>
    <h:message for="selectedCategoryIds" styleClass="errorMessage"/>
    </td>
    </tr>                    		
    <tr>
    <td align="center" colspan="2">
    <h:commandButton value="Create" action="#{productBean.createAction}"/>
    <h:commandButton value="Cancel" action="cancel" immediate="true"/>
    </td>
    </tr>
    after click create button,
    i have an error message on the .jspx page,"Validation Error: {0}Value is not valid"
    in multi selection box. would you tell me what it is wrong?

    reference backing bean(omit import libraries)
    Code:
    public class ProductBean extends BaseBean {
    	//the product id
    	private String id ;
    	
    	//the product name
    	private String name;
    	
    	//the product description
    	private String description;
    	
    	//the product price
    	private double price;
    	
    	//the product width
    	private double width;
    	
    	//the product height
    	private double height;
    	
    	//the category ids associated with the product
    	private Set categoryIds;
    	
    	//the category id selected by the user on the page
    	private List selectedCategoryIds;
    	
    	/**
    	 * Default constructor.
    	 */
    	public ProductBean() {
    		this.categoryIds = new HashSet();
    		this.logger.debug("ProductBean is created");
    	}
    	
    	
    	protected void init() {
    		this.logger.debug("id = " + this.id);
    		
    		try {
    			if (this.id != null) {
    				Product p = this.serviceLocator.getCatalogService().getProduct(this.id);
    				ProductBuilder.populateProductBean(this, p);
    				
    				this.logger.debug("Product with id of " + this.id + "is retrieved successfully");
    				
    			}
    		} catch (CatalogException ce) {
    			String msg = "Could not retrieve Product with id of " + this.id;
    			this.logger.debug(msg, ce);
    			
    			throw new FacesException(msg, ce);
    		}
    	}
    	
    	
    	public String updateAction() {
    		this.logger.debug("updateAction is invoked");
    		
    		try {
    			Product product = ProductBuilder.createProduct(this);
    			this.logger.debug("productId = " + product.getId());
    			
    			this.serviceLocator.getCatalogService().updateProduct(product);
    			
    			//remove the productList inside the cache
    			FacesUtils.resetManagedBean(BeanNames.PRODUCT_LIST_BEAN);
    		} catch (Exception e) {
    			String msg = "Could not update product";
    			this.logger.error(msg, e);
    			FacesUtils.addErrorMessage(msg + ": Internal Error.");
    			
    			return NavigationResults.FAILURE;
    		}
    	
    		String msg = "Product with id of " + this.id + " was updated successfully.";
    		this.logger.debug(msg);
    		FacesUtils.addInfoMessage(msg);
    		
    		return NavigationResults.SUCCESS;
    	}
    	
    	/**
    	 * 
    	 * 
    	 * 
    	 */
    	public String createAction() {
    		log.info("createAction is invoked");
    		
    		try {
    			Product product = ProductBuilder.createProduct(this);
    			
    			this.serviceLocator.getCatalogService().saveProduct(product);
    
    			//store the current product id inside the session bean.
    			//for the use of image uploader.
    			FacesUtils.getSessionBean().setCurrentProductId(this.id);
    			
    			//remove the productList inside the cache
    			log.info("remove ProductListBean from cache");
    			FacesUtils.resetManagedBean(BeanNames.PRODUCT_LIST_BEAN);
    		} catch (DuplicateProductIdException de) {
    			String msg = "Product id already exists";
    			this.logger.info(msg);
    			FacesUtils.addErrorMessage(msg);
    			
    			return NavigationResults.RETRY;
    		} catch (Exception e) {
    			String msg = "Could not save product";
    			this.logger.error(msg, e);
    			FacesUtils.addErrorMessage(msg + ": Internal Error");
    			
    			return NavigationResults.FAILURE;
    		}
    		String msg = "Product with id of " + this.id + " was created successfully.";
    		
    		this.logger.debug(msg);
    		FacesUtils.addInfoMessage(msg);
    		
    		return NavigationResults.SUCCESS;
    	}
    	
    	
    	public String deleteAction() {
    		this.logger.debug("deleteAction is invoked");
    		
    		try {
    			Product product = ProductBuilder.createProduct(this);
    			
    			this.serviceLocator.getCatalogService().deleteProduct(product);
    		
    			//remove the productList inside the cache
    			FacesUtils.resetManagedBean(BeanNames.PRODUCT_LIST_BEAN);
    		} catch (Exception e) {
    			String msg = "Could not delete product. ";
    			this.logger.error(msg, e);
    			FacesUtils.addErrorMessage(null, msg + "Internal Error.");
    			
    			return NavigationResults.FAILURE;
    		}
    		
    		String msg = "Product with id of " + this.id + " was deleted successfully.";
    		this.logger.debug(msg);
    		FacesUtils.addInfoMessage(msg);
    		
    		return NavigationResults.SUCCESS;
    	}
    	
    	public String getId() {
    		return this.id;
    	}
    	
    	public void setId(String newId) {
    		this.id = newId;
    	}
    	
    	public String getName() {
    		return this.name;
    	}
    	
    	public void setName(String newName) {
    		this.name = newName;
    	}
    	
    	public String getDescription() {
    		return this.description;
    	}
    	
    	public void setDescription(String newDescription) {
    		this.description = newDescription;
    	}
    	
    	public double getPrice() {
    		return this.price;
    	}
    	
    	public void setPrice(double newPrice) {
    		this.price = newPrice;
    	}
    	
    	public double getWidth() {
    		return this.width;
    	}
    	
    	public void setWidth(double newWidth) {
    		this.width = newWidth;
    	}
    	
    	public double getHeight() {
    		return this.height;
    	}
    	
    	public void setHeight(double newHeight) {
    		this.height = newHeight;
    	}
    	
    	public Set getCategoryIds() {
    		return this.categoryIds;
    	}
    	
    	public void setCategoryIds(Set newCategoryIds) {
    		this.categoryIds = newCategoryIds;
    		
    		if (this.categoryIds != null) {
    			this.selectedCategoryIds = ViewUtils.convertToList(this.categoryIds);
    		}
    	}
    	
    	public List getSelectedCategoryIds() {
    		return this.selectedCategoryIds;
    	}
    	
    	public void setSelectedCategoryIds(List newSelectedCategoryIds) {
    		this.selectedCategoryIds = newSelectedCategoryIds;
    		this.categoryIds = ViewUtils.convertToSet(selectedCategoryIds);
    	}
    	
    	
    	public String getShortDescription() {
    		int shortDescriptionLength = 40;
    		
    		StringBuffer sb = new StringBuffer("");
    		
    		if (this.description != null) {
    			String[] words = this.description.split(" ");
    			
    			int length = (shortDescriptionLength>words.length)?words.length:shortDescriptionLength;
    			
    			for (int i=0; i<length; i++) {
    				sb.append(words[i]);
    				sb.append(" ");
    			}
    		}
    		
    		return sb.toString().trim();
    	}
    	
    	public String toString() {
    		return "id=" + this.id + " name=" + this.name;
    	}
    }

  • #2
    my environment:spring 2.5,hibernate3,icefaces 1.7

    Comment


    • #3
      after correcting typos in backing bean file(productCategories instead of categoryIds), i have the following a log file;
      Code:
      Jun 18, 2009 4:51:08 PM org.apache.catalina.core.StandardWrapperValve invoke
      SEVERE: Servlet.service() for servlet Blocking Servlet threw exception
      java.lang.IllegalArgumentException
      	at javax.faces.component.SelectItemsIterator.next(SelectItemsIterator.java:127)
      	at javax.faces.component.UISelectMany.matchValue(UISelectMany.java:401)
      	at javax.faces.component.UISelectMany.validateValue(UISelectMany.java:370)
      	at javax.faces.component.UIInput.validate(UIInput.java:634)
      	at javax.faces.component.UIInput.executeValidate(UIInput.java:838)
      	at javax.faces.component.UIInput.processValidators(UIInput.java:412)
      	at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:904)
      	at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:904)
      	at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:904)
      	at javax.faces.component.UIForm.processValidators(UIForm.java:170)
      	at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:904)
      	at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:904)
      	at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:904)
      	at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:342)
      	at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:78)
      	at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
      	at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
      	at com.icesoft.faces.webapp.http.core.JsfLifecycleExecutor.apply(JsfLifecycleExecutor.java:17)
      	at com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.renderCycle(ReceiveSendUpdates.java:94)
      	at com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.service(ReceiveSendUpdates.java:54)
      	at com.icesoft.faces.webapp.http.core.RequestVerifier.service(RequestVerifier.java:26)
      	at com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer.service(PathDispatcherServer.java:24)
      	at com.icesoft.faces.webapp.http.servlet.MainSessionBoundServlet.service(MainSessionBoundServlet.java:160)
      	at com.icesoft.faces.webapp.http.servlet.SessionDispatcher$1.service(SessionDispatcher.java:38)
      	at com.icesoft.faces.webapp.http.servlet.ThreadBlockingAdaptingServlet.service(ThreadBlockingAdaptingServlet.java:19)
      	at com.icesoft.faces.webapp.http.servlet.EnvironmentAdaptingServlet.service(EnvironmentAdaptingServlet.java:63)
      	at com.icesoft.faces.webapp.http.servlet.SessionDispatcher.service(SessionDispatcher.java:55)
      	at com.icesoft.faces.webapp.http.servlet.SessionVerifier.service(SessionVerifier.java:19)
      	at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:23)
      	at com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:91)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
      	at com.icesoft.faces.webapp.xmlhttp.BlockingServlet.service(BlockingServlet.java:56)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
      	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
      	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
      	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
      	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
      	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
      	at java.lang.Thread.run(Unknown Source)

      Comment

      Working...
      X