问题描述
我在Springs Web Flow中遇到问题。如果用户点击表单提交按钮,我将在我的bean中具有 RIGHT 值。
I am having a issue with Springs Web Flow. If the user clicks on the form submit button I will have the RIGHT values in my bean.
性别字段的示例将为MALE或FEMALE。但是,我然后添加了一个 AjaxEventDecoration 来提交更改性别下拉框,这是一个真正的形式:select ,在bean中将获得值为sex,这是elementId。以下是我的代码,你可以查看它,让我知道你的想法...我需要尽快解决这个价值...
Example the sex field will be MALE or FEMALE. But I then added a AjaxEventDecoration to do a submit on change of the sex dropdown box which is really a form:select and in the bean I will get the value "sex" which is the elementId. Below is my code can you please review it and let me know what you think... I need to fix this value ASAP...
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<style type="text/css" media="screen">
@import url("<c:url value="/resources/dojo/resources/dojo.css"/>");
@import url("<c:url value="/resources/dijit/themes/claro/claro.css"/>");
</style>
<script djconfig="parseOnLoad: true"
src="<c:url value="/resources/dojo/dojo.js"/>" type="text/javascript"></script>
<script type="text/javascript"
src="<c:url value="/resources/spring/Spring.js" />"> </script>
<script type="text/javascript"
src="<c:url value="/resources/spring/Spring-Dojo.js" />"></script>
<script type="text/javascript">dojo.require("dojo.parser");</script>
<html>
<head>
<title>Spring 3.0 MVC - Web Flow Example</title>
</head>
<body class="claro">
<h2>Dropdown Test</h2>
<form:form commandName="customer" id="customer">
<input type="hidden" name="_flowExecutionKey"
value="${flowExecutionKey}" />
<div id="container">
<table>
<tr>
<td><font color=red><form:errors path="sex" /></font><b>Sex:</b></td>
<td><form:select path="sex" id="sex">
<form:option value="MALE" label="MALE" />
<form:option value="FEMALE" label="FEMALE" />
</form:select>
<script type="text/javascript">
Spring.addDecoration(new Spring.ElementDecoration({
elementId : "sex",
widgetType : "dijit.form.Select",
widgetAttrs : {
promptMessage : "Enter Sex",
required : true }}));
</script></td></tr>
</table>
</div>
<input type="submit" name="_eventId_submit" id="submit" value="Submit" />
<input type="submit" name="_eventId_cancel" value="Cancel" />
<p>
<script type="text/javascript">
Spring.addDecoration(new Spring.ValidateAllDecoration({
elementId : 'submit',
event : 'onclick'
}));
Spring.addDecoration(new Spring.AjaxEventDecoration({
elementId: "sex",
event: "onChange",
formId:"customer",
params: {fragments:"body", _eventId: "loadSchools"}}));
</script>
</form:form>
</body>
</html>
推荐答案
您没有关闭< / b>
之后的活动,但< / n>
。导致一些奇怪的问题,如你正在使用的
you don't have any closing </b>
after "Active" but </n>
.
these things some times can lead up to weird issues like the one you are having
修复它,再试一次
我找到一个解决方案pb:基本上删除你的选择的装饰和ajax事件,这样做:
I found a solution to you pb: basically remove the decoration and ajax event on your select and do it this way:
<tr>
<td><font color=red><form:errors path="sex" /></font><b>Sex:</b></td>
<td><form:select path="sex" id="sex" required="true" data-dojo-type="dijit/form/Select" onchange="Spring.remoting.submitForm('sex', 'customer', {fragments:'body', _eventId: 'loadSchools'}); return false;">
<form:option value="MALE" label="MALE" />
<form:option value="FEMALE" label="FEMALE" />
</form:select>
</td>
</tr>
似乎有一些选择装饰的问题...我会尝试看看我是否可以找到另一种方式,但我测试了这个,它的作品
it seems like there are some issues with select decoration... I will try to see if I can find another way, but I tested this and it works
这篇关于问题与Springs Web Flow。表单提交值是正确的,AjaxEventDecoration不是的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!