Reputation: 4317
Here is JSP file that is generated to user who is composing his pizza, it's subflow of another flow. I can't understand why I need to check at least one checkbox to make submit button work. I mean that, when there are 0 checkboxes checked, then submit button sends me back to same site. I hope I brought enough information, if there is something more I should add, write it.
Where is this coded ? In JSP or somewhere in flow file ?
Updated with required class.
I made github repo of my project.
createPizza.jspx
<div xmlns:form="http://www.springframework.org/tags/form"
xmlns:jsp="http://java.sun.com/JSP/Page">
<jsp:output omit-xml-declaration="yes"/>
<jsp:directive.page contentType="text/html;charset=UTF-8" />
<h2>Create Pizza</h2>
<form:form commandName="pizza">
<input type="hidden" name="_flowExecutionKey"
value="${flowExecutionKey}"/>
<b>Size: </b><br/>
<form:radiobutton path="size"
label="Small (12-inch)" value="SMALL"/><br/>
<form:radiobutton path="size"
label="Medium (14-inch)" value="MEDIUM"/><br/>
<form:radiobutton path="size"
label="Large (16-inch)" value="LARGE"/><br/>
<form:radiobutton path="size"
label="Ginormous (20-inch)" value="GINORMOUS"/>
<br/>
<br/>
<b>Toppings: </b><br/>
<form:checkboxes path="toppings" items="${toppingsList}"
delimiter="<br/>"/><br/><br/>
<input type="submit" class="button" name="_eventId_addPizza" value="Continue"/>
<input type="submit" class="button" name="_eventId_cancel" value="Cancel"/>
</form:form>
</div>
order-flow.xml
<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow
http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
<input name="order" required="true" />
<view-state id="showOrder">
<transition on="createPizza" to="createPizza" />
<transition on="checkout" to="orderCreated" />
<transition on="cancel" to="cancel" />
</view-state>
<!-- Corresponding state -->
<view-state id="createPizza" model="flowScope.pizza">
<on-entry>
<set name="flowScope.pizza"
value="new com.springinaction.pizza.domain.Pizza()" />
<evaluate result="viewScope.toppingsList" expression=
"T(com.springinaction.pizza.domain.Topping).asList()" />
</on-entry>
<transition on="addPizza" to="showOrder">
<evaluate expression="order.addPizza(flowScope.pizza)" />
</transition>
<transition on="cancel" to="showOrder" />
</view-state>
<end-state id="cancel" />
<end-state id="orderCreated" />
</flow>
Pizza.java
package com.springinaction.pizza.domain;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@SuppressWarnings("serial")
public class Pizza implements Serializable {
private PizzaSize size;
private List<Topping> toppings;
public Pizza() {
toppings = new ArrayList<Topping>();
size = PizzaSize.LARGE;
}
public PizzaSize getSize() {
return size;
}
public void setSize(PizzaSize size) {
this.size = size;
}
public void setSize(String sizeString) {
this.size = PizzaSize.valueOf(sizeString);
}
public List<Topping> getToppings() {
return toppings;
}
public void setToppings(List<Topping> toppings) {
this.toppings = toppings;
}
public void setToppings(String[] toppingStrings) {
for (int i = 0; i < toppingStrings.length; i++) {
toppings.add(Topping.valueOf(toppingStrings[i]));
}
}
}
Upvotes: 1
Views: 964
Reputation: 4317
Apparently as shazin emphasized the problem lies in overloaded setToppings
method in Pizza class which makes trouble. After commenting the one with array of Strings as argument, application works properly. Possibly it's related with EL which handles it in that way and may change on another Container ( I used tomcat, and I think that dedicated server is Jetty ).
Upvotes: 0