【问题标题】:How to disable field validation on finder page in Spring Roo如何在 Spring Roo 的 finder 页面上禁用字段验证
【发布时间】:2012-06-06 18:49:25
【问题描述】:

所以我创建了一个自定义搜索页面,允许我按任何字段搜索客户,并且所有字段都是可选的。为此,我必须创建一个自定义 <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>

我的&lt;field:select_optional&gt; 标签只是默认的&lt;field:select&gt; 标签,还有一个额外的&lt;option value="" /&gt;

【问题讨论】:

    标签: spring dojo spring-roo


    【解决方案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>
    

    修改后field:select标签中的required属性可以正常工作。

    【讨论】:

    • 这可行,但我想知道为什么“必需”属性在没有我们修改的情况下不起作用。
    • 我发现了几个类似这样的错误,我认为 Spring-Roo 不是很成功的项目。 Spring 确实放弃了 Roo - 现在它是开源的
    猜你喜欢
    • 2023-03-19
    • 1970-01-01
    • 1970-01-01
    • 2015-12-18
    • 1970-01-01
    • 1970-01-01
    • 2013-03-27
    • 2018-04-19
    • 1970-01-01
    相关资源
    最近更新 更多