Roberto-

in 
%TOMCAT_HOME%\webapps\struts2-showcase-2.1.6\WEB-INF\classes\com\opensymphony\xwork2\validator\validators\default.xml
 you should have at minimum these 2 Validation Classes declared:
<validators>
    <validator name="requiredstring" 
class="com.opensymphony.xwork.validator.validators.RequiredStringValidator"/>
    <validator name="expression" 
class="com.opensymphony.xwork.validator.validators.ExpressionValidator"/>
    <!-- Other validators go here -->
</validators>

//an example of Action Class with an ID attribute
package com.opensymphony.webwork.example;
import com.opensymphony.xwork.ActionSupport;
/**
 * ValidatedAction
 * @author Jason Carreira
 * Created Sep 12, 2003 9:23:38 PM
 */
public class WhateverNameOfYourAction extends ActionSupport {
    private String validationAction = "basicValidation.action";

//here is your ID field
    private String ID;
    public String getID() { return ID; }
    public void setID(String ID) { this.ID = ID; }

    public String getValidationAction() {
        return validationAction;
    }
    public void setValidationAction(String validationAction) {
        this.validationAction = validationAction;
    }
}
WhateverNameOfYourAction-validation.xml
<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0//EN" 
"http://www.opensymphony.com/xwork/xwork-validator-1.0.dtd";>
<validators>
    <validator type="expression">
        <param name="expression"><![CDATA[(ID!=null)]]></param>
        <message>ID Must Not Be Null </message>
    </validator>
    <field name="ID">
        <field-validator type="requiredstring">
            <message>You must enter a ID.</message>
        </field-validator>
    </field>
</validators>
?
Martin 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung / Note de déni et de confidentialité 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger 
sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung 
oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem 
Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. 
Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung 
fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le 
destinataire prévu, nous te demandons avec bonté que pour satisfaire informez 
l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est 
interdite. Ce message sert à l'information seulement et n'aura pas n'importe 
quel effet légalement obligatoire. Étant donné que les email peuvent facilement 
être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité 
pour le contenu fourni.






> Date: Wed, 8 Apr 2009 15:15:11 +0200
> From: roberto.nunn...@supsi.ch
> To: user@struts.apache.org
> Subject: Re: validation
> 
> Humm.. I don't know.. I tried with
> 
> view:
> <s:form method="post" action="Item_update" namespace="/admin">
> 
> struts.xml:
> <action name="Item_update" method="update" 
> class="ch.nunnisoft.myecommerce.actions.admin.ItemAction">
>    <result type="redirect-action">
>      <param name="actionName">Item-view?id=${id}</param>
>    </result>
>    <result name="input" type="tiles">adminItemEdit</result>
> </action>
> 
> and renamed validator xml file to:
> Item_update-update-validation.xml
> 
> but still.. it doesn't check anything..
> 
> Any more hints?
> 
> Robi
> 
> 
> Lukasz Lenart ha scritto:
> > 2009/4/8 Roberto Nunnari <roberto.nunn...@supsi.ch>:
> >>        <action name="Item-update" method="update"
> > 
> > Action name is:
> > Item-update
> > 
> > method name is:
> > update
> > 
> > so then, validation file should be?
> > Item-update-update-validation.xml
> > 
> >> and here's my Item-update-validation.xml file that I put in the same folder
> > 
> > In theory this should work for whole action Item-update, but I think
> > the problem is that double dash ;-)
> > 
> > Change naming convention for your actions, use namespace instead names
> > like Item-update or use underscore
> > 
> > 
> > Regards
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
> 

Rediscover Hotmail®: Get quick friend updates right in your inbox.  Check it 
out.

_________________________________________________________________
Quick access to your favorite MSN content and Windows Live with Internet 
Explorer 8. 
http://ie8.msn.com/microsoft/internet-explorer-8/en-us/ie8.aspx?ocid=B037MSN55C0701A

Reply via email to