Announcement Announcement Module
Collapse
No announcement yet.
prepopulate checkboxes in a success view Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • prepopulate checkboxes in a success view

    Hi,

    I have a page with a drop-down list which allows a user to choose the type of music he likes. After choosing and submitting, I want to display the available cd's of this type of music from the data base, in checkboxes form in another page. But I am not able to find out how to do it, and when choosing and submitting, I'm getting: java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'command' available as request attribute

    My controller

    BuyController.java
    Code:
    public class BuyController extends SimpleFormController {
    
    	private ProductManager productManager;
    
    	public ModelAndView onSubmit(Object command) throws ServletException {
    
    		String type = ((ProductType) command).getType();
    
    		Map<String, Object> myModel = new HashMap<String, Object>();
    		myModel.put("products", this.productManager.readType(type));
    
    		return new ModelAndView("buySearch", "model", myModel);
    	}
    
    
    	public ProductManager getProductManager() {
    		return productManager;
    	}
    
    	public void setProductManager(ProductManager productManager) {
    		this.productManager = productManager;
    	}

    The relevant part of my form view:

    buy.jsp
    Code:
    <form:form method="POST" commandName="productType">
    <form:select path="type">
    <form:option value="NONE" label="--Select please"/> 
    <form:option value="Classic"/>
    <form:option value="Rock"/>
    <form:option value="Pop"/>
    <form:option value="Jazz"/>
    </form:select>
    
    <input type="submit" value="OK">
    <form:errors path="tipus" cssClass="error" />
    </form:form>

    My success view:

    buySearch.jsp
    Code:
    <form:form>
    <c:forEach items="${model.products}" var="prod"> 
    <form:checkbox path="model.products" value="${prod.title}"/>
    <c:out value="${prod.title}"/> 
    <c:out value="${prod.price}"/> 
    </c:forEach>
    </form:form>

    I'm getting the exception at the line "<form:checkbox path...."


    my bean configuration:
    Code:
    <bean name="/buy.htm" class="eMusicalWorld.web.BuyController">
    		<property name="sessionForm" value="true" />
    		<property name="commandName" value="productType" />
    		<property name="commandClass" value="eMusicalWorld.service.ProductType" />
    		<property name="validator">
    			<bean class="eMusicalWorld.service.ProductTypeValidator" />
    		</property>
    		<property name="formView" value="buy" />
    		<property name="successView" value="buySearch" />
    		<property name="productManager" ref="productManager" />
    	</bean>

    Any idea why am I getting this exception and how to solve it?

    Thanks in advance!

  • #2
    I solved it finally without using form tag as explained here:
    http://stackoverflow.com/questions/2...and-checkboxes

    Comment

    Working...
    X