struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Giovanni Azua <g...@imc.nl>
Subject S2.1.1 question on validation ...
Date Wed, 28 Nov 2007 14:49:21 GMT
hi,

I am trying to introduce a validation rule that checks that at least one 
element has been
added to an optiontransferselect UI component. I use the expression type 
validation but
does not seem to work ... see the details below.

<field name="outSamplePeriods">
   <field-validator type="fieldexpression">
      <param name="expression"><![CDATA[ (outSamplePeriods.length > 0) 
]]></param>
      <message><![CDATA[ At least one Out of Sample Period must be 
provided ]]></message>
    </field-validator>
</field>  

TIA,
regards,
Giovanni

************************ page.jsp **************************

<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>

<s:form action="TradingIdea@create" method="get" theme="%{currentTheme}">
   ...
    <s:optiontransferselect
        tooltip="Select all Out-of-Sample Period Ranges corresponding to 
this Trading Idea"
        label="Out-of-Sample Periods"
        leftTitle="All Periods"
        rightTitle="Selected Periods"
        name="allPeriodRanges"
        list="defaultAllPeriodRanges"
        doubleName="outSamplePeriods"
        doubleList="defaultOutSamplePeriods"
        size="1" multiple="false"
        doubleSize="5" doubleMultiple="true"
        allowAddAllToLeft="false"
        allowAddAllToRight="false"
        allowSelectAll="false"
        allowUpDownOnLeft="false"
        allowUpDownOnRight="false"
    />
    ...
    <s:submit value="Create" align="center"/>
</s:form>

************************ TradingIdea-validation.xml 
***************************

<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 
1.0.2//EN" "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">

<!--  START VALIDATOR: TradingIdea -->

<validators>
    <field name="name">
        <field-validator type="requiredstring">
            <message>Name must be provided</message>
        </field-validator>
    </field>
    <field name="template">
        <field-validator type="requiredstring">
            <message>Template value must be provided</message>
        </field-validator>
    </field>
    <field name="grouping">
        <field-validator type="requiredstring">
            <message>Grouping criteria must be provided e.g. DAILY</message>
        </field-validator>
    </field>
    <field name="inSamplePeriod">
        <field-validator type="requiredstring">
            <message>In Sample Period must be provided</message>
        </field-validator>
    </field>
    <field name="outSamplePeriods">
        <field-validator type="fieldexpression">
            <param name="expression"><![CDATA[ (outSamplePeriods.length 
 > 0) ]]></param>
            <message><![CDATA[ At least one Out of Sample Period must be 
provided ]]></message>
        </field-validator>
    </field>    
    <field name="utilityFormulas">
        <field-validator type="fieldexpression">
            <param name="expression"><![CDATA[ (utilityFormulas.length > 
0) ]]></param>
            <message><![CDATA[ At least one Utility Formula must be 
provided ]]></message>
        </field-validator>
    </field>    
</validators>

<!--  END VALIDATOR: TradingIdea  -->

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message