You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by nodep <no...@libero.it> on 2007/08/07 17:15:24 UTC

[S2] validation continue even if there is an error

Hi, I wrote this xml-file for validation:
<< ...
<validators>
    <field name="nome">
        <field-validator type="requiredstring">
            <message key="requiredstring"/>
        </field-validator>
    </field>
    <field name="indirizzo">
        <field-validator type="requiredstring">
            <message key="requiredstring"/>
        </field-validator>
    </field>
    <field name="comune">
        <field-validator type="requiredstring">
            <message key="requiredstring"/>
        </field-validato>
    </field>
....
...
>>

and it's wrong because there's a  tag  "field-validator" not closed. 
Struts2 doesn't stop the flow and go to my action:  for me it's not logic,
it should stop with some error and return to the prev page ... 
What do you think?

Stefano :)
-- 
View this message in context: http://www.nabble.com/-S2--validation-continue-even-if-there-is-an-error-tf4230757.html#a12036217
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: [S2] validation continue even if there is an error

Posted by nodep <no...@libero.it>.
Hi, my validation file is:
<!DOCTYPE validators PUBLIC
        "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
        "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">

<validators>
    <field name="nome">
        <field-validator type="requiredstring">
            <message key="requiredstring"/>
        </field-validator>
    </field>
    <field name="indirizzo">
        <field-validator type="requiredstring">
            <message key="requiredstring"/>
        </field-validato>
    </field>
    <field name="comune">
        <field-validator type="requiredstring">
            <message key="requiredstring"/>
        </field-validator>
    </field>
    <field name="provincia">
        <field-validator type="requiredstring">
            <message key="requiredstring"/>
        </field-validator>
    </field>
    <field name="cap">
        <field-validator type="requiredstring">
            <message key="requiredstring"/>
        </field-validator>
    </field>
    <field name="piva">
        <field-validator type="requiredstring">
            <message key="requiredstring"/>
        </field-validator>
    </field>
    <field name="telefono">
        <field-validator type="requiredstring">
            <message key="requiredstring"/>
        </field-validator>
    </field>
</validators>

I placed the DTD but when I try to validate my form I see in the log:
...
09:47:13,501DEBUG AnnotationValidationInterceptor:134 - Validating
/app/anagrafiche/modify with method e
xecute.
09:47:13,564FATAL DomHelper:353 - The element type "field-validator" must be
terminated by the matching
end-tag "</field-validator>". at (null:14:11)
org.xml.sax.SAXParseException: The element type "field-validator" must be
terminated by the matching end
-tag "</field-validator>".
        at
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHand
lerWrapper.java:236)
        at
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.ja
va:215)
        at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:38
6)
        at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:31
6)
        at
com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1438)
        at
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanEndElement(XMLNSDocument
ScannerImpl.java:696)
        at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatc
her.dispatch(XMLDocumentFragmentScannerImpl.java:1685)
        at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocume
ntFragmentScannerImpl.java:368)
        at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:8
34)
        at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:7
64)
        at
com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
        at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:124
2)
...

and then struts2 execute my action (processing my not validated data from
the form ...).  Maybe have  I to do something
to caught the exception and not to excecute the action when the
validation-file is not wellformed?

Thanks to reply.


Stefano


----------------------------------------------------------------------------------------------

mihel wrote:
> 
> nodep wrote:
>> and it's wrong because there's a  tag  "field-validator" not closed. 
>> Struts2 doesn't stop the flow and go to my action:  for me it's not
>> logic,
>> it should stop with some error and return to the prev page ... 
>> What do you think?
> 
> We think that XML validity check is a task of DTD attached.
> Please put DTD (or Schema) to the XMLs and it will cure
> your issues.
> (In 2.0.9 DTDs became required for validator XMLs I think)
> 
> Oleg
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-S2--validation-continue-even-if-there-is-an-error-tf4230757.html#a12048767
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: [S2] validation continue even if there is an error

Posted by Oleg Mikheev <mi...@bigfoot.com>.
nodep wrote:
> and it's wrong because there's a  tag  "field-validator" not closed. 
> Struts2 doesn't stop the flow and go to my action:  for me it's not logic,
> it should stop with some error and return to the prev page ... 
> What do you think?

We think that XML validity check is a task of DTD attached.
Please put DTD (or Schema) to the XMLs and it will cure
your issues.
(In 2.0.9 DTDs became required for validator XMLs I think)

Oleg

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