所以我创建了一个自定义搜索页面,允许我按任何字段搜索客户,所有字段都是可选的。为此,我必须创建一个自定义<form:find>
标记并注释掉这一行:
<!-- <script type="text/javascript">Spring.addDecoration(new Spring.ValidateAllDecoration({elementId:'proceed', event:'onclick'}));</script> -->
这允许我提交表格。但问题是:如果我在一个字段内单击并在其外部单击而不输入任何文本,则会弹出“此字段是必需的”验证错误。
我仍然可以提交表单,并且搜索页面可以正常工作,但我想解决这个烦人的错误错误。
这是.jspx
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<div xmlns:field="urn:jsptagdir:/WEB-INF/tags/form/fields" xmlns:form="urn:jsptagdir:/WEB-INF/tags/form" xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0">
<jsp:directive.page contentType="text/html;charset=UTF-8"/>
<jsp:output omit-xml-declaration="yes"/>
<form:find_without_validation finderName="ByOutputFormatAndStorageDeviceAndWorkOrderAndServiceOffering" id="ff_com_eg_egmedia_bizapp_model_ServiceItem" path="/serviceitems" z="b0NZUow+hQ11Ruy9n/4oyBOWOBs=">
<field:select_optional disableFormBinding="true" field="outputFormat" id="f_com_eg_egmedia_bizapp_model_ServiceItem_outputFormat" items="${outputformatenums}" path="/outputformatenums" required="false" z="user-managed"/>
<field:select_optional disableFormBinding="true" field="storageDevice" id="f_com_eg_egmedia_bizapp_model_ServiceItem_storageDevice" items="${storagedeviceenums}" path="/storagedeviceenums" required="false" z="user-managed"/>
<field:select_optional disableFormBinding="true" field="workOrder" id="f_com_eg_egmedia_bizapp_model_ServiceItem_workOrder" itemValue="id" items="${workorders}" path="/workorders" required="false" z="user-managed"/>
<field:select_optional disableFormBinding="true" field="serviceOffering" id="f_com_eg_egmedia_bizapp_model_ServiceItem_serviceOffering" itemValue="id" items="${serviceofferings}" path="/serviceofferings" required="false" z="user-managed"/>
</form:find_without_validation>
</div>
我的<field:select_optional>
代码只是默认<field:select>
代码,附加<option value="" />
答案 0 :(得分:1)
在项目中查找select.tagx
,在此文件中找到以下行:
<script type="text/javascript">Spring.addDecoration(new Spring.ElementDecoration({elementId : '_${sec_field}_id', widgetType: 'dijit.form.FilteringSelect', widgetAttrs : {hasDownArrow : true}})); </script>
内部装饰器widgetAttrs
添加一个新选项:
required: ${required}
以便编辑的行看起来像:
<script type="text/javascript">Spring.addDecoration(new Spring.ElementDecoration({elementId : '_${sec_field}_id', widgetType: 'dijit.form.FilteringSelect', widgetAttrs : {hasDownArrow : true, required: ${required}}})); </script>
完成此修改后,required
标记中的field:select
属性将正常运作。