Кто-нибудь может помочь мне понять, что здесь не так?
This is fragment from Spring web flow project. I create new object заказывать and get a list of столы object from DB in тег состояния просмотра.
<?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.xsd">
<input name = "order" required = "true" />
<view-state id = "chooseTable" model = "flowScope.order">
<on-entry>
<set name = "flowScope.order" value = "new pizza.Order()"></set>
<evaluate expression = "pizzaFlowActions.getFreeTables()"
result = "viewScope.tables" />
</on-entry>
<transition on = "chosenCreateOrder" to = "bookedToOrder">
<evaluate expression = "order.setTable(flowScope.order)" />
</transition>
<transition on = "chosenNoOrder" to = "booked">
<evaluate expression = "order.setTable(flowScope.order)" />
</transition>
<transition on = "cancel" to = "cancel" />
</view-state>
<end-state id = "cancel" />
<end-state id = "bookedToOrder">
</end-state>
<end-state id = "booked">
</end-state>
<global-transitions>
<transition on = "cancel" to = "cancel" />
</global-transitions>
</flow>
Jsp file with form with which object заказывать is binded, and radiobuttons' values extracted from tables list.
<html xmlns:jsp = "http://java.sun.com/JSP/Page"
xmlns:spring = "http://www.springframework.org/tags"
xmlns:c = "http://java.sun.com/jsp/jstl/core"
xmlns:form = "http://www.springframework.org/tags/form">
<jsp:output omit-xml-declaration = "yes" />
<jsp:directive.page contentType = "text/html;charset=UTF-8" />
<head>
<title>Book a table</title>
</head>
<body background = "${pageContext.request.contextPath}/resources/plan.gif">
<form:form commandName = "order" class = "box login">
<input type = "hidden" name = "_flowExecutionKey" value = "${flowExecutionKey}" />
<b>Choose table: </b>
<c:forEach items = "${tables}" var = "place">
<form:radiobutton path = "table" label = "${place}" value = "${place}"/>
<br></br>
<br></br>
</c:forEach>
<input type = "submit" class = "btnLogin" name = "_eventId_chosenCreateOrder" value = "Now choose Pizza" />
<input type = "submit" class = "btnLogin" name = "_eventId_chosenNoOrder" value = "Just book a table" />
<input type = "submit" class = "btnLogin" name = "_eventId_cancel" value = "Cancel" />
</form:form>
</body>
</html>
Класс заказа
public class Order implements Serializable {
private static final Logger LOGGER = getLogger(Order.class);
private int id;
private Customer customer;
private Set<Pizza> pizzas;
private Payment payment;
private Place table;
Проблема здесь в том, что после выбора любого варианта в любой момент форма просто перезагружается и больше ничего не происходит.
Буду признателен за любую помощь и подсказки.
На самом деле, это все, что мне нужно было сделать.
так я предполагаю, что это сработало?
Мне пришлось использовать простой радиоэлемент html с идентификатором в качестве идентификатора таблицы
Я предлагаю вам отправить идентификатор места, которое вы пытаетесь отправить, затем найти его и установить в своем заказе. Или отправьте индекс места, чтобы вы могли найти его в своем списке таблиц и установить его в своем порядке в потоке