You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by nandyiyer <na...@gmail.com> on 2010/04/16 12:35:58 UTC

Struts2 XML based validation doesnt work !

Hello all ,

I'm trying to include XML based validation in my application ?

This is part of my struts.xml -
                <action name="addAuctionItem" class="auctionItemAction"
method="addAuctionItem">
                        <result name="success">
                                /body_displayAddAuctionItem.jsp
                        </result>
                        <result name="input">
                                /body_displayAddAuctionItem.jsp
                        </result>
                </action>

and this is my AuctionItemAction-addAuctionItem-validation.xml -

<!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="auctionItem.shortDescription">
                <field-validator type="requiredstring">
                        <message>Item name is required.</message>
                </field-validator>
        </field>
        <field name="auctionItem.longDescription">
                <field-validator type="requiredstring">
                        <message>Description is required.</message>
                </field-validator>
        </field>
</validators>

When I try to run the application the validation doesnt happen at all .
The class and xml file are in the same package structure .

Do anyone have an idea about this ?
Any help on this will be greatly appreciated .

Thanks
Nanditha 

-- 
View this message in context: http://old.nabble.com/Struts2-XML-based-validation-doesnt-work-%21-tp28265349p28265349.html
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: Struts2 XML based validation doesnt work !

Posted by Alex Rodriguez Lopez <al...@flordeutopia.pt>.
I'm sure your problem is related to themes/templates.

If you are using simple theme you have to provide your own labels for 
fields, so the field validation works and S2 knows where to place the 
messages (because you know validation happens, it's just the messages 
not displaying, right?).

check http://struts.apache.org/2.1.8.1/docs/themes-and-templates.html

although... btw, it's been more than a week since I can't see code 
examples in S2 2.1.8.1 guides, anyone knows why?


Em 27-04-2010 06:40, nandyiyer escreveu:
>
> When I dont provide any values to the input fields , I cannot perform the
> operation and when I provide , it happens .
> So I'm sure that validation is working .
>
> Thanks
> Nanditha
>
>
> nandyiyer wrote:
>>
>> Hello all ,
>>
>> I'm trying to include XML based validation in my application ?
>>
>> This is part of my struts.xml -
>>                  <action name="addAuctionItem" class="auctionItemAction"
>> method="addAuctionItem">
>>                          <result name="success">
>>                                  /body_displayAddAuctionItem.jsp
>>                          </result>
>>                          <result name="input">
>>                                  /body_displayAddAuctionItem.jsp
>>                          </result>
>>                  </action>
>>
>> and this is my AuctionItemAction-addAuctionItem-validation.xml -
>>
>> <!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="auctionItem.shortDescription">
>>                  <field-validator type="requiredstring">
>>                          <message>Item name is required.</message>
>>                  </field-validator>
>>          </field>
>>          <field name="auctionItem.longDescription">
>>                  <field-validator type="requiredstring">
>>                          <message>Description is required.</message>
>>                  </field-validator>
>>          </field>
>> </validators>
>>
>> When I try to run the application the validation doesnt happen at all .
>> The class and xml file are in the same package structure .
>>
>> Do anyone have an idea about this ?
>> Any help on this will be greatly appreciated .
>>
>> Thanks
>> Nanditha
>>
>>
>


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


Re: Struts2 XML based validation doesnt work !

Posted by nandyiyer <na...@gmail.com>.
When I dont provide any values to the input fields , I cannot perform the
operation and when I provide , it happens . 
So I'm sure that validation is working . 

Thanks 
Nanditha 


nandyiyer wrote:
> 
> Hello all ,
> 
> I'm trying to include XML based validation in my application ?
> 
> This is part of my struts.xml -
>                 <action name="addAuctionItem" class="auctionItemAction"
> method="addAuctionItem">
>                         <result name="success">
>                                 /body_displayAddAuctionItem.jsp
>                         </result>
>                         <result name="input">
>                                 /body_displayAddAuctionItem.jsp
>                         </result>
>                 </action>
> 
> and this is my AuctionItemAction-addAuctionItem-validation.xml -
> 
> <!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="auctionItem.shortDescription">
>                 <field-validator type="requiredstring">
>                         <message>Item name is required.</message>
>                 </field-validator>
>         </field>
>         <field name="auctionItem.longDescription">
>                 <field-validator type="requiredstring">
>                         <message>Description is required.</message>
>                 </field-validator>
>         </field>
> </validators>
> 
> When I try to run the application the validation doesnt happen at all .
> The class and xml file are in the same package structure .
> 
> Do anyone have an idea about this ?
> Any help on this will be greatly appreciated .
> 
> Thanks
> Nanditha 
> 
> 

-- 
View this message in context: http://old.nabble.com/Struts2-XML-based-validation-doesnt-work-%21-tp28265349p28373110.html
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: Struts2 XML based validation doesnt work !

Posted by Lukasz Lenart <lu...@googlemail.com>.
2010/4/16 nandyiyer <na...@gmail.com>:
> I'm trying to include XML based validation in my application ?
>
> This is part of my struts.xml -
>                <action name="addAuctionItem" class="auctionItemAction"

Are you using Spring? Try default packge and
auctionItemAction-addAuctionItem-validation.xml


Regards
-- 
Łukasz
http://www.lenart.org.pl/
Kapituła Javarsovia 2010
http://javarsovia.pl

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


Re: Struts2 XML based validation doesnt work !

Posted by Lukasz Lenart <lu...@googlemail.com>.
2010/4/26 nandyiyer <na...@gmail.com>:
> I didnt understand the previous message . Could you please elaborate on it or
> tell me as to where to add it ?

If you are using Simple theme, you must add previously mentioned tag
into your jsp.


Regards
-- 
Łukasz
http://www.lenart.org.pl/
Kapituła Javarsovia 2010
http://javarsovia.pl

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


Re: Struts2 XML based validation doesnt work !

Posted by nandyiyer <na...@gmail.com>.
I didnt understand the previous message . Could you please elaborate on it or
tell me as to where to add it ? 

Thanks 
Nanditha 


nandyiyer wrote:
> 
> Hello all ,
> 
> I'm trying to include XML based validation in my application ?
> 
> This is part of my struts.xml -
>                 <action name="addAuctionItem" class="auctionItemAction"
> method="addAuctionItem">
>                         <result name="success">
>                                 /body_displayAddAuctionItem.jsp
>                         </result>
>                         <result name="input">
>                                 /body_displayAddAuctionItem.jsp
>                         </result>
>                 </action>
> 
> and this is my AuctionItemAction-addAuctionItem-validation.xml -
> 
> <!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="auctionItem.shortDescription">
>                 <field-validator type="requiredstring">
>                         <message>Item name is required.</message>
>                 </field-validator>
>         </field>
>         <field name="auctionItem.longDescription">
>                 <field-validator type="requiredstring">
>                         <message>Description is required.</message>
>                 </field-validator>
>         </field>
> </validators>
> 
> When I try to run the application the validation doesnt happen at all .
> The class and xml file are in the same package structure .
> 
> Do anyone have an idea about this ?
> Any help on this will be greatly appreciated .
> 
> Thanks
> Nanditha 
> 
> 

-- 
View this message in context: http://old.nabble.com/Struts2-XML-based-validation-doesnt-work-%21-tp28265349p28361262.html
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: Struts2 XML based validation doesnt work !

Posted by nandyiyer <na...@gmail.com>.
I tried adding this tag - <s:actionerror /> ( and also with <s:actionmessage
/> , but no luck ... What could be the problem here ? 

And suppose if I dont use Simple theme , should we do anything ? 

Thanks
Nanditha 

-- 
View this message in context: http://old.nabble.com/Struts2-XML-based-validation-doesnt-work-%21-tp28265349p28363351.html
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: Struts2 XML based validation doesnt work !

Posted by Lukasz Lenart <lu...@googlemail.com>.
2010/4/23 nandyiyer <na...@gmail.com>:
> Changed the code and fixed the issue . The validation works but the message
> wont be displayed on the screen . Can anyone say what is the problem here ?

How do you know that it works?


Regards
-- 
Łukasz
http://www.lenart.org.pl/
Kapituła Javarsovia 2010
http://javarsovia.pl

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


Re: Struts2 XML based validation doesnt work !

Posted by Lukasz Lenart <lu...@googlemail.com>.
2010/4/23 nandyiyer <na...@gmail.com>:
>
> Changed the code and fixed the issue . The validation works but the message
> wont be displayed on the screen . Can anyone say what is the problem here ?

What theme are you using? If Simple you must add <s:actionerror> or
<s:actionmessage/> or <s:fielderror/> tag.


Regards
-- 
Łukasz
http://www.lenart.org.pl/
Kapituła Javarsovia 2010
http://javarsovia.pl

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


Re: Struts2 XML based validation doesnt work !

Posted by nandyiyer <na...@gmail.com>.
Changed the code and fixed the issue . The validation works but the message
wont be displayed on the screen . Can anyone say what is the problem here ? 

Thanks 
Nanditha 


nandyiyer wrote:
> 
> Hello all ,
> 
> I'm trying to include XML based validation in my application ?
> 
> This is part of my struts.xml -
>                 <action name="addAuctionItem" class="auctionItemAction"
> method="addAuctionItem">
>                         <result name="success">
>                                 /body_displayAddAuctionItem.jsp
>                         </result>
>                         <result name="input">
>                                 /body_displayAddAuctionItem.jsp
>                         </result>
>                 </action>
> 
> and this is my AuctionItemAction-addAuctionItem-validation.xml -
> 
> <!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="auctionItem.shortDescription">
>                 <field-validator type="requiredstring">
>                         <message>Item name is required.</message>
>                 </field-validator>
>         </field>
>         <field name="auctionItem.longDescription">
>                 <field-validator type="requiredstring">
>                         <message>Description is required.</message>
>                 </field-validator>
>         </field>
> </validators>
> 
> When I try to run the application the validation doesnt happen at all .
> The class and xml file are in the same package structure .
> 
> Do anyone have an idea about this ?
> Any help on this will be greatly appreciated .
> 
> Thanks
> Nanditha 
> 
> 

-- 
View this message in context: http://old.nabble.com/Struts2-XML-based-validation-doesnt-work-%21-tp28265349p28342031.html
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