You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Robson Rodrigues <ro...@gmail.com> on 2009/07/08 00:37:40 UTC

Struts 2 Validation

Hello People,

 

i´m using the struts 2 in a project and i´m with a problem on the
validation. When i try validate a form, the struts say the validation
failed, even when the field is with correct value, in addition, it is not
going back to the field with the old value

 

here is my struts.xml. The action is the Cliente_insert:

 

<package name="cliente" namespace="/" extends="struts-default">

<default-interceptor-ref name="defaultStack"/>

 

<action name="Cliente_input" >

<result >/cliente/inputCliente.jsp</result>

</action>

<action name="Cliente_edit" class="br.com.robson.modelo.ClienteAction"
method="editar">

<interceptor-ref name="paramsPrepareParamsStack" />

<result >/cliente/editCliente.jsp</result>

</action>

<action name="Cliente_list" class="br.com.robson.modelo.ClienteAction"
method="listar">

<result name="success">/cliente/listaClientes.jsp</result>

</action>

<action name="Cliente_insert" class="br.com.robson.modelo.ClienteAction"
method="inserir">

<interceptor-ref name="validationWorkflowStack"/>

 

<result name="input">/cliente/inputCliente.jsp</result>

<result name="success" type="redirect">Cliente_list.action</result>

</action>

<action name="Cliente_delete" class="br.com.robson.modelo.ClienteAction"
method="deletar">

<result name="success" type="redirect">Cliente_list.action</result>

</action>

<action name="Cliente_update" class="br.com.robson.modelo.ClienteAction"
method="atualizar">

<result name="success" type="redirect">Cliente_list.action</result>

</action>

 

</package>

 

Here is my validation archive:

 

<!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="required">

true

<message> O campo nome é obrigatório </message>

</field-validator>

</field> -->

<field name="telefone">

<field-validator type="required">

true

<message> O campo telefone é obrigatório </message>

</field-validator>

<field-validator type="stringlength">

true

6

14

<message> O campo telefone deve ter entre 6 e 14 caracteres </message>

</field-validator>

</field>

</validators>

 

here is my jsp:

 

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"

pageEncoding="ISO-8859-1"%>

<%@page import="br.com.robson.modelo.Cliente" %>

<%@page import ="java.util.*" %>

<%@ taglib prefix="s" uri="/struts-tags" %>

 

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html:html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>Insert title here</title>

<script language="javascript">

</script>

</head>

<body>

Novo Cliente

<s:debug/>

 

<s:form action="Cliente_insert.action" method="POST" >

 

<s:textfield name="idCli" label="Id" />

 

<s:textfield name="nome" label="Nome"/>

 

<s:textfield name="telefone" label="Ielefone"/>

 

<s:submit></s:submit>

</s:form>

 

 

 

 

</body>

</html:html>

 

I hope you can help me

 

Hugs!

 
-- 
View this message in context: http://www.nabble.com/Struts-2-Validation-tp24382602p24382602.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: not displaying errors!

Posted by Martin Gainty <mg...@hotmail.com>.
if you could display the jsp we could see 
			the actual component for the HTML id="err" 

Martin Gainty 
______________________________________________ 
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: Thu, 9 Jul 2009 15:21:04 +0200
> From: rgw@lsoft.com
> To: user@struts.apache.org
> Subject: Re: <s:actionerrors> not displaying errors!
> 
> My first guess would be that you are not properly dispatching back to 
> your input page. A closer look at your struts.xml would clarify this, 
> though.
> 
> Robert
> 
> Kavita Mehta schrieb:
> > Hi,
> > I am using Struts 2.0  and I am not able to display the action errors in 
> > my JSP.
> >
> > Action class code :
> >
> > if( ( getSelectedlocation() == null ) || getSelectedlocation().compareTo( 
> > "" ) == 0 
> >                                         && ( (getLocation() == null ) ||( 
> > getLocation().compareTo( "" ) == 0 )))
> >                                 {
> >                                         mLog.warn( "Location not 
> > specified. Added Error message" );
> >                                         addActionError( "Please specify a 
> > Location for the message . " );
> >                                 }
> >
> >
> > JSP code :
> >
> > <tr>
> >     <td align="left" valign="top"><p><s:actionerror id="err" /></p></td>
> >   </tr>
> >
> >
> > The error is added successfully as i can see from the logs but it is not 
> > getting displayed  on the JSP ..any pointers ?
> >
> >
> > Thanks,
> > Kavita
> >
> >
> >
> >
> >
> > *****************************************************DISCLAIMER*****************************************************
> >
> > This message and/or attachment(s) contained here are confidential, proprietary to HUGHES SYSTIQUE and its customers. 
> > Contents may be privileged or otherwise protected by law. The information is solely intended for the entity it is 
> > addressed to. If you are not the intended recipient of this message, it is strictly prohibited to read, forward, 
> > print, retain, copy or disseminate this message or any part of it. If you have received this e-mail in error, 
> > please notify the sender immediately and delete the message.
> >
> > ********************************************************************************************************************
> >
> >
> >   
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 

_________________________________________________________________
Insert movie times and more without leaving Hotmail®. 
http://windowslive.com/Tutorial/Hotmail/QuickAdd?ocid=TXT_TAGLM_WL_HM_Tutorial_QuickAdd_062009

Re: not displaying errors!

Posted by Kavita Mehta <Ka...@hsc.com>.
Thanks Robert  .. Lemme check the same.



Robert Graf-Waczenski <rg...@lsoft.com> 
07/09/2009 06:51 PM
Please respond to
"Struts Users Mailing List" <us...@struts.apache.org>


To
Struts Users Mailing List <us...@struts.apache.org>
cc

Subject
Re: <s:actionerrors> not displaying errors!






My first guess would be that you are not properly dispatching back to 
your input page. A closer look at your struts.xml would clarify this, 
though.

Robert

Kavita Mehta schrieb:
> Hi,
> I am using Struts 2.0  and I am not able to display the action errors in 

> my JSP.
>
> Action class code :
>
> if( ( getSelectedlocation() == null ) || 
getSelectedlocation().compareTo( 
> "" ) == 0 
>                                         && ( (getLocation() == null ) 
||( 
> getLocation().compareTo( "" ) == 0 )))
>                                 {
>                                         mLog.warn( "Location not 
> specified. Added Error message" );
>                                         addActionError( "Please specify 
a 
> Location for the message . " );
>                                 }
>
>
> JSP code :
>
> <tr>
>     <td align="left" valign="top"><p><s:actionerror id="err" /></p></td>
>   </tr>
>
>
> The error is added successfully as i can see from the logs but it is not 

> getting displayed  on the JSP ..any pointers ?
>
>
> Thanks,
> Kavita
>
>
>
>
>
> 
*****************************************************DISCLAIMER*****************************************************
>
> This message and/or attachment(s) contained here are confidential, 
proprietary to HUGHES SYSTIQUE and its customers. 
> Contents may be privileged or otherwise protected by law. The 
information is solely intended for the entity it is 
> addressed to. If you are not the intended recipient of this message, it 
is strictly prohibited to read, forward, 
> print, retain, copy or disseminate this message or any part of it. If 
you have received this e-mail in error, 
> please notify the sender immediately and delete the message.
>
> 
********************************************************************************************************************
>
>
> 



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






*****************************************************DISCLAIMER*****************************************************

This message and/or attachment(s) contained here are confidential, proprietary to HUGHES SYSTIQUE and its customers. 
Contents may be privileged or otherwise protected by law. The information is solely intended for the entity it is 
addressed to. If you are not the intended recipient of this message, it is strictly prohibited to read, forward, 
print, retain, copy or disseminate this message or any part of it. If you have received this e-mail in error, 
please notify the sender immediately and delete the message.

********************************************************************************************************************


Re: not displaying errors!

Posted by Robert Graf-Waczenski <rg...@lsoft.com>.
My first guess would be that you are not properly dispatching back to 
your input page. A closer look at your struts.xml would clarify this, 
though.

Robert

Kavita Mehta schrieb:
> Hi,
> I am using Struts 2.0  and I am not able to display the action errors in 
> my JSP.
>
> Action class code :
>
> if( ( getSelectedlocation() == null ) || getSelectedlocation().compareTo( 
> "" ) == 0 
>                                         && ( (getLocation() == null ) ||( 
> getLocation().compareTo( "" ) == 0 )))
>                                 {
>                                         mLog.warn( "Location not 
> specified. Added Error message" );
>                                         addActionError( "Please specify a 
> Location for the message . " );
>                                 }
>
>
> JSP code :
>
> <tr>
>     <td align="left" valign="top"><p><s:actionerror id="err" /></p></td>
>   </tr>
>
>
> The error is added successfully as i can see from the logs but it is not 
> getting displayed  on the JSP ..any pointers ?
>
>
> Thanks,
> Kavita
>
>
>
>
>
> *****************************************************DISCLAIMER*****************************************************
>
> This message and/or attachment(s) contained here are confidential, proprietary to HUGHES SYSTIQUE and its customers. 
> Contents may be privileged or otherwise protected by law. The information is solely intended for the entity it is 
> addressed to. If you are not the intended recipient of this message, it is strictly prohibited to read, forward, 
> print, retain, copy or disseminate this message or any part of it. If you have received this e-mail in error, 
> please notify the sender immediately and delete the message.
>
> ********************************************************************************************************************
>
>
>   



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


not displaying errors!

Posted by Kavita Mehta <Ka...@hsc.com>.
Hi,
I am using Struts 2.0  and I am not able to display the action errors in 
my JSP.

Action class code :

if( ( getSelectedlocation() == null ) || getSelectedlocation().compareTo( 
"" ) == 0 
                                        && ( (getLocation() == null ) ||( 
getLocation().compareTo( "" ) == 0 )))
                                {
                                        mLog.warn( "Location not 
specified. Added Error message" );
                                        addActionError( "Please specify a 
Location for the message . " );
                                }


JSP code :

<tr>
    <td align="left" valign="top"><p><s:actionerror id="err" /></p></td>
  </tr>


The error is added successfully as i can see from the logs but it is not 
getting displayed  on the JSP ..any pointers ?


Thanks,
Kavita





*****************************************************DISCLAIMER*****************************************************

This message and/or attachment(s) contained here are confidential, proprietary to HUGHES SYSTIQUE and its customers. 
Contents may be privileged or otherwise protected by law. The information is solely intended for the entity it is 
addressed to. If you are not the intended recipient of this message, it is strictly prohibited to read, forward, 
print, retain, copy or disseminate this message or any part of it. If you have received this e-mail in error, 
please notify the sender immediately and delete the message.

********************************************************************************************************************


Re: dynamic return when validation failed

Posted by Oscar Alvarez <oi...@gmail.com>.
                   Use Pattern Matching Wildcards in  Configurations

Action configuration files are somehow able to grow to
extremely large at incredible speeds. On way to combat this
phenomenon is to use pattern matching. Pattern matching works
by defining one or more patterns that URLs will conform to.
An example will be an easy way to see how things work. Let’s
say that the URLs in your web application always follows the
pattern “/{module}/{entity}/{action}.action”. This is a common
pattern;       examples         would        be       the    URL’s
“/admin/User/edit.action”,         “/admin/User/list.action”     and
“/admin/User/add.action”.

The class configuration is such that there is a Struts2 action class
with the name “{entity}Action”, and each {action} is method on
the action class. All the results from invoking the action’s
methods will result in either the update page for the entity being
displayed, or a list of all the entities being displayed.

For our example, the “struts.xml” configuration will look like
this:

*<action name=”*/*/*” method=”{3}”
           class=”com.infoq.actions.{1}.{2}Action”>
      <result name=”view”>/{1}/update{2}.jsp</result>
      <result name=”list”>/{1}/list.jsp</result>
</action>*

Each asterisk in the actions name is a wildcard. In the example,
only asterisks are used – but this need not be the case. For
example, say you wish to map all entity view actions together.
Something like ‘name=”/*/View*”’ would do the trick. Token
identifiers, {1}, {2}, etc., are then used to obtain the text values
harvested from the wildcards (where the numeric value
correlating to the position of the asterisk, ascending from left to
right).

In the “struts.properties” configuration file (or using the constant
tag in the “struts.xml” configuration file) you need to ensure the
following property is correctly set:

struts.enable.SlashesInActionNames = true

This property allows slashes in the name of the action. Struts2’s
default configuration is to not have slashes in the action name,
instead using packages for namespace separation.

Finally, there is no shortcut if you are providing validation and
conversion property files rather than using annotations. We’ll
talk about this more in following sections. Each needs to
contain the full name of the action, along with the necessary
extension: i.e. “edit-validation.xml” and “edit-conversion.xml”
for the original example, in the “com.infoq.actions.admin”
package.


2009/7/9 <ma...@yahoo.com>

> Thanks for let me know another struts2 book, have a quick look in it,
> didn't found any good tip to solve my problem.
>
> Regards
> Louis
>
>
>
> ________________________________
> From: Oscar Alvarez <oi...@gmail.com>
> To: Struts Users Mailing List <us...@struts.apache.org>
> Sent: Wednesday, July 8, 2009 7:09:35 PM
> Subject: Re: dynamic return when validation failed
>
> 2009/7/8 Oscar Alvarez <oi...@gmail.com>
>
> > Hi...
> >
> > Try to get the Ian Roughley's "Starting Struts2 online" ebook for free,
> and
> > study "PRODUCTIVITY TIPS" -> "Re-Using Action Configurations"... and see
> if
> > there are some other tips for you.
> >
>
>
> And of course "PRODUCTIVITY TIPS" -> "Use Pattern Matching Wildcards in
> Configurations" too.
>
>
>
> >
> > HTH
> >
> > 2009/7/8 Greg Lindholm <gr...@gmail.com>
> >
> > > Greg Lindholm wrote:
> >> >
> >> >> The referer header will contain the URL of the last request, which
> will
> >> be
> >> >> the action URL not the jsp page that rendered the result. So this
> >> wouldn't
> >> >> help the OP if I understood his problem.
> >> >>
> >> >
> >> > I think you misunderstand what the referer field contains.  It'll be
> the
> >> > url that was displaying in the address field on the page from which
> the
> >> form
> >> > was submitted.  http://en.wikipedia.org/wiki/HTTP_referrer Note that
> it
> >> > can be forged, etc.
> >> >
> >> >
> >> Not sure why you think I don't understand referer. In a struts app what
> >> you
> >> see in the address field is the "action URL" (e.g.
> >> http://host/MyAction.action) you don't ever see the JSP page name that
> >> rendered the page. The OP seemed to be looking for the name of the jsp
> >> page
> >> so don't see how this would help.
> >>
> >
> >
> >
> > --
> > Atentamente
> > Óscar Álvarez Vielma
> > (09) 8416 4052
> >
>
>
>
> --
> Atentamente
> Óscar Álvarez Vielma
> (09) 8416 4052
>



-- 
Atentamente
Óscar Álvarez Vielma
(09) 8416 4052

Re: dynamic return when validation failed

Posted by ma...@yahoo.com.
Thanks for let me know another struts2 book, have a quick look in it, didn't found any good tip to solve my problem.

Regards
Louis



________________________________
From: Oscar Alvarez <oi...@gmail.com>
To: Struts Users Mailing List <us...@struts.apache.org>
Sent: Wednesday, July 8, 2009 7:09:35 PM
Subject: Re: dynamic return when validation failed

2009/7/8 Oscar Alvarez <oi...@gmail.com>

> Hi...
>
> Try to get the Ian Roughley's "Starting Struts2 online" ebook for free, and
> study "PRODUCTIVITY TIPS" -> "Re-Using Action Configurations"... and see if
> there are some other tips for you.
>


And of course "PRODUCTIVITY TIPS" -> "Use Pattern Matching Wildcards in
Configurations" too.



>
> HTH
>
> 2009/7/8 Greg Lindholm <gr...@gmail.com>
>
> > Greg Lindholm wrote:
>> >
>> >> The referer header will contain the URL of the last request, which will
>> be
>> >> the action URL not the jsp page that rendered the result. So this
>> wouldn't
>> >> help the OP if I understood his problem.
>> >>
>> >
>> > I think you misunderstand what the referer field contains.  It'll be the
>> > url that was displaying in the address field on the page from which the
>> form
>> > was submitted.  http://en.wikipedia.org/wiki/HTTP_referrer Note that it
>> > can be forged, etc.
>> >
>> >
>> Not sure why you think I don't understand referer. In a struts app what
>> you
>> see in the address field is the "action URL" (e.g.
>> http://host/MyAction.action) you don't ever see the JSP page name that
>> rendered the page. The OP seemed to be looking for the name of the jsp
>> page
>> so don't see how this would help.
>>
>
>
>
> --
> Atentamente
> Óscar Álvarez Vielma
> (09) 8416 4052
>



-- 
Atentamente
Óscar Álvarez Vielma
(09) 8416 4052

Re: dynamic return when validation failed

Posted by Oscar Alvarez <oi...@gmail.com>.
2009/7/8 Oscar Alvarez <oi...@gmail.com>

> Hi...
>
> Try to get the Ian Roughley's "Starting Struts2 online" ebook for free, and
> study "PRODUCTIVITY TIPS" -> "Re-Using Action Configurations"... and see if
> there are some other tips for you.
>


And of course "PRODUCTIVITY TIPS" -> "Use Pattern Matching Wildcards in
Configurations" too.



>
> HTH
>
> 2009/7/8 Greg Lindholm <gr...@gmail.com>
>
> > Greg Lindholm wrote:
>> >
>> >> The referer header will contain the URL of the last request, which will
>> be
>> >> the action URL not the jsp page that rendered the result. So this
>> wouldn't
>> >> help the OP if I understood his problem.
>> >>
>> >
>> > I think you misunderstand what the referer field contains.  It'll be the
>> > url that was displaying in the address field on the page from which the
>> form
>> > was submitted.  http://en.wikipedia.org/wiki/HTTP_referrer Note that it
>> > can be forged, etc.
>> >
>> >
>> Not sure why you think I don't understand referer. In a struts app what
>> you
>> see in the address field is the "action URL" (e.g.
>> http://host/MyAction.action) you don't ever see the JSP page name that
>> rendered the page. The OP seemed to be looking for the name of the jsp
>> page
>> so don't see how this would help.
>>
>
>
>
> --
> Atentamente
> Óscar Álvarez Vielma
> (09) 8416 4052
>



-- 
Atentamente
Óscar Álvarez Vielma
(09) 8416 4052

Re: dynamic return when validation failed

Posted by Oscar Alvarez <oi...@gmail.com>.
Hi...

Try to get the Ian Roughley's "Starting Struts2 online" ebook for free, and
study "PRODUCTIVITY TIPS" -> "Re-Using Action Configurations"... and see if
there are some other tips for you.

HTH

2009/7/8 Greg Lindholm <gr...@gmail.com>

> > Greg Lindholm wrote:
> >
> >> The referer header will contain the URL of the last request, which will
> be
> >> the action URL not the jsp page that rendered the result. So this
> wouldn't
> >> help the OP if I understood his problem.
> >>
> >
> > I think you misunderstand what the referer field contains.  It'll be the
> > url that was displaying in the address field on the page from which the
> form
> > was submitted.  http://en.wikipedia.org/wiki/HTTP_referrer Note that it
> > can be forged, etc.
> >
> >
> Not sure why you think I don't understand referer. In a struts app what you
> see in the address field is the "action URL" (e.g.
> http://host/MyAction.action) you don't ever see the JSP page name that
> rendered the page. The OP seemed to be looking for the name of the jsp page
> so don't see how this would help.
>



-- 
Atentamente
Óscar Álvarez Vielma
(09) 8416 4052

RE: dynamic return when validation failed

Posted by Martin Gainty <mg...@hotmail.com>.
check your web.xml to see if your filtering thru SiteMesh e.g.
    <filter>
        <filter-name>sitemesh</filter-name>
        <filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>sitemesh</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

where com.opensymphony.module.sitemesh.filter.PageFilter contains parsePage method
protected com.opensymphony.module.sitemesh.Page 
parsePage(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException 
{
        try 
        {
            PageResponseWrapper pageResponse = new PageResponseWrapper(response, factory);
            chain.doFilter(request, pageResponse);
            // check if another servlet or filter put a page object to the request
            Page result = (Page)request.getAttribute(PAGE);
//MG: THIS IS the page you want

            if (result == null) {
                // parse the page
                result = pageResponse.getPage();
            }
            request.setAttribute(USING_STREAM, new Boolean(pageResponse.isUsingStream()));
            return result;
        }

//once you have the Page you can do page.getTitle() and then 
//map Title to Page Number
//the other way is to modify protected com.opensymphony.module.sitemesh.Page 
//for accessor and mutator for pageNumber

did you ask wes?
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: Thu, 9 Jul 2009 07:36:58 -0700
> From: mailtolouis2020-struts@yahoo.com
> Subject: Re: dynamic return when validation failed
> To: user@struts.apache.org
> 
> > <result name="input">/xxx/MyWizardPage${page}.jsp</result>
> 
> oh yes, this does the trick! Thanks! 
> 
> I just found another problem when using xml based validation. In struts1, there is a page attribute, which can tell the validator to validate certain fields which belong to that page, but this useful feature is not in struts2, is there any replacement for that?
> 
> 
> 
> 
> 
> ________________________________
> From: Greg Lindholm <gr...@gmail.com>
> To: Struts Users Mailing List <us...@struts.apache.org>
> Sent: Thursday, July 9, 2009 2:32:17 PM
> Subject: Re: dynamic return when validation failed
> 
> >
> >
> > >
> > > Well, if I remove my validation code in the validate() method and put it
> > > into execute() method, then I can easily control which logical name to be
> > > return, but I thought that is not a good way to do that right?
> > >
> >
> > While this might not be a "good way to do that," it's what I would do and
> > in
> > fact have done.
> > --
> > Jim Kiley
> > Senior Technical Consultant | Summa
> > [p] 412.258.3346
> > http://www.summa-tech.com
> >
> 
> I occasionally have to do validation in the execute() method but always
> prefer to do declarative validation with annotations wherever possible since
> it is so much simpler and cleaner. This means all my actions have to be able
> to handle an 'input' result. Since 'input' result is the standard for
> validation errors you should be prepared for it as the next programmer who
> works on your code may add a validation() method or add validation
> annotations.
> 
> @OP: If you know which page# in a wizard sequence to return to and use that
> page# in the jsp name then you can make that page# available with a
> getPage() method and do this:
> 
>     <result name="input">/xxx/MyWizardPage${page}.jsp</result>
> 
> It does mean you would need to have a jsp page naming convention that
> includes the page#.

_________________________________________________________________
Windows Live™ SkyDrive™: Get 25 GB of free online storage.
http://windowslive.com/online/skydrive?ocid=TXT_TAGLM_WL_SD_25GB_062009

Re: dynamic return when validation failed

Posted by ma...@yahoo.com.
> <result name="input">/xxx/MyWizardPage${page}.jsp</result>

oh yes, this does the trick! Thanks! 

I just found another problem when using xml based validation. In struts1, there is a page attribute, which can tell the validator to validate certain fields which belong to that page, but this useful feature is not in struts2, is there any replacement for that?





________________________________
From: Greg Lindholm <gr...@gmail.com>
To: Struts Users Mailing List <us...@struts.apache.org>
Sent: Thursday, July 9, 2009 2:32:17 PM
Subject: Re: dynamic return when validation failed

>
>
> >
> > Well, if I remove my validation code in the validate() method and put it
> > into execute() method, then I can easily control which logical name to be
> > return, but I thought that is not a good way to do that right?
> >
>
> While this might not be a "good way to do that," it's what I would do and
> in
> fact have done.
> --
> Jim Kiley
> Senior Technical Consultant | Summa
> [p] 412.258.3346
> http://www.summa-tech.com
>

I occasionally have to do validation in the execute() method but always
prefer to do declarative validation with annotations wherever possible since
it is so much simpler and cleaner. This means all my actions have to be able
to handle an 'input' result. Since 'input' result is the standard for
validation errors you should be prepared for it as the next programmer who
works on your code may add a validation() method or add validation
annotations.

@OP: If you know which page# in a wizard sequence to return to and use that
page# in the jsp name then you can make that page# available with a
getPage() method and do this:

    <result name="input">/xxx/MyWizardPage${page}.jsp</result>

It does mean you would need to have a jsp page naming convention that
includes the page#.

Re: dynamic return when validation failed

Posted by Greg Lindholm <gr...@gmail.com>.
>
>
> >
> > Well, if I remove my validation code in the validate() method and put it
> > into execute() method, then I can easily control which logical name to be
> > return, but I thought that is not a good way to do that right?
> >
>
> While this might not be a "good way to do that," it's what I would do and
> in
> fact have done.
> --
> Jim Kiley
> Senior Technical Consultant | Summa
> [p] 412.258.3346
> http://www.summa-tech.com
>

I occasionally have to do validation in the execute() method but always
prefer to do declarative validation with annotations wherever possible since
it is so much simpler and cleaner. This means all my actions have to be able
to handle an 'input' result. Since 'input' result is the standard for
validation errors you should be prepared for it as the next programmer who
works on your code may add a validation() method or add validation
annotations.

@OP: If you know which page# in a wizard sequence to return to and use that
page# in the jsp name then you can make that page# available with a
getPage() method and do this:

    <result name="input">/xxx/MyWizardPage${page}.jsp</result>

It does mean you would need to have a jsp page naming convention that
includes the page#.

Re: dynamic return when validation failed

Posted by Jim Kiley <jh...@summa-tech.com>.
On Thu, Jul 9, 2009 at 5:26 AM, <ma...@yahoo.com> wrote:

>
> Well, if I remove my validation code in the validate() method and put it
> into execute() method, then I can easily control which logical name to be
> return, but I thought that is not a good way to do that right?
>

While this might not be a "good way to do that," it's what I would do and in
fact have done.
-- 
Jim Kiley
Senior Technical Consultant | Summa
[p] 412.258.3346
http://www.summa-tech.com

Re: dynamic return when validation failed

Posted by ma...@yahoo.com.
Hi Dale & Greg,

Thanks for all your discussion.


>>>
> The problem is that the OP doesn't understand his problem.  If the
> validation step knows what the result page should be, he shouldn't be
> returning "input", but rather the name of the logical step to be rendered.
>  He's right that the code shouldn't need to know what jsp page renders that
> step, just the logical name of the page, fleshed out in the .xml file.
>



Yes, my validation step know what the result page should be (I mean the logical name of the result page), why I said it returning to the "input" that is because the workflow interceptor always return to the logical name "input" when there is error, that is why come to this idea to replace the value of "input"

Well, if I remove my validation code in the validate() method and put it into execute() method, then I can easily control which logical name to be return, but I thought that is not a good way to do that right?

There must be other way to solve this kind of validation problem, what I call this wizard validation, I think it is quite common in many web project. 
Like in my case, create employee wizard, it break into 5 pages and handle by CreateEmpAction, I can use Greg solution 2, but then I need to create CreateEmpAction1, CreateEmpAction2, etc, thats not look so tidy to me. 

Hopefully someone done this before can give me some light.

Regards
Louis

Re: dynamic return when validation failed

Posted by Greg Lindholm <gr...@gmail.com>.
 Dale Newfield <da...@newfield.org> wrote:

> Greg Lindholm wrote:
> > Not sure why you think I don't understand referer.
>
> I already quoted the bits that illustrate this perceived misunderstanding,
> but since you apparently want me to be more specific:
>

Actually I just wanted to move off the whole referer topic since It was not
likely going to be of any help to the OP.


>
>
>  Greg Lindholm wrote:
>>>
>>>> The referer header will contain the URL of the last request
>>>>
>>>
> It won't contain the url of the last request.  The last request
> (chronologically, since you don't specify any other binding for 'last') was
> likely an image or style sheet or something to fill in something on the
> previously rendered page, or even something in another tab.
>

Yes I gave an imprecise usage of "last request". Was it really confusing to
you? Did you really think I meant the last chronological request received by
the server?


>
>
>  which will be the action URL not the jsp page that rendered the
>>>> result.
>>>>
>>>
By "action URL" I simply meant the URL contains the name of the "action" and
not the name of the jsp that rendered the page. Sorry if this was confusing.


>
> This is completely dependent upon how you handle posts.  If you use the
> post-redirect style, it won't be the "action url" (I'm not sure what you
> mean by that phrase, but I assume you're differentiating those urls from
> ones that are not side-effecting), but the GET url that resulted in the
> display of the form.  Assuming post-redirect-only-if-successful, then it'll
> be the url of the step before this one: "submit-multi-page-form-step-2" when
> the step that's failing validation is "submit-multi-page-form-step-3" (or
> "submit-multi-page-form-3" if this step failed validation again, which
> illustrates where this path will break down).
>

Yes, very nice description, so what you are saying is the referer header
isn't going to be of any use in solving the OP problem?


>
>
>  So this  wouldn't help the OP if I understood his problem.
>>>>
>>>
> The problem is that the OP doesn't understand his problem.  If the
> validation step knows what the result page should be, he shouldn't be
> returning "input", but rather the name of the logical step to be rendered.
>  He's right that the code shouldn't need to know what jsp page renders that
> step, just the logical name of the page, fleshed out in the .xml file.
>
> -Dale
>

Yes your right but I was trying to be helpful.

Can we just stop this OT discussion now?

Re: dynamic return when validation failed

Posted by Dale Newfield <da...@newfield.org>.
Greg Lindholm wrote:
 > Not sure why you think I don't understand referer.

I already quoted the bits that illustrate this perceived 
misunderstanding, but since you apparently want me to be more specific:

>> Greg Lindholm wrote:
>>> The referer header will contain the URL of the last request

It won't contain the url of the last request.  The last request 
(chronologically, since you don't specify any other binding for 'last') 
was likely an image or style sheet or something to fill in something on 
the previously rendered page, or even something in another tab.

>>> which will be the action URL not the jsp page that rendered the
>>> result.

This is completely dependent upon how you handle posts.  If you use the 
post-redirect style, it won't be the "action url" (I'm not sure what you 
mean by that phrase, but I assume you're differentiating those urls from 
ones that are not side-effecting), but the GET url that resulted in the 
display of the form.  Assuming post-redirect-only-if-successful, then 
it'll be the url of the step before this one: 
"submit-multi-page-form-step-2" when the step that's failing validation 
is "submit-multi-page-form-step-3" (or "submit-multi-page-form-3" if 
this step failed validation again, which illustrates where this path 
will break down).

>>> So this  wouldn't help the OP if I understood his problem.

The problem is that the OP doesn't understand his problem.  If the 
validation step knows what the result page should be, he shouldn't be 
returning "input", but rather the name of the logical step to be 
rendered.  He's right that the code shouldn't need to know what jsp page 
renders that step, just the logical name of the page, fleshed out in the 
.xml file.

-Dale

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


Re: dynamic return when validation failed

Posted by Greg Lindholm <gr...@gmail.com>.
> Greg Lindholm wrote:
>
>> The referer header will contain the URL of the last request, which will be
>> the action URL not the jsp page that rendered the result. So this wouldn't
>> help the OP if I understood his problem.
>>
>
> I think you misunderstand what the referer field contains.  It'll be the
> url that was displaying in the address field on the page from which the form
> was submitted.  http://en.wikipedia.org/wiki/HTTP_referrer Note that it
> can be forged, etc.
>
>
Not sure why you think I don't understand referer. In a struts app what you
see in the address field is the "action URL" (e.g.
http://host/MyAction.action) you don't ever see the JSP page name that
rendered the page. The OP seemed to be looking for the name of the jsp page
so don't see how this would help.

Re: dynamic return when validation failed

Posted by Dale Newfield <da...@newfield.org>.
Greg Lindholm wrote:
> The referer header will contain the URL of the last request, which will be
> the action URL not the jsp page that rendered the result. So this wouldn't
> help the OP if I understood his problem.

I think you misunderstand what the referer field contains.  It'll be the 
url that was displaying in the address field on the page from which the 
form was submitted.  http://en.wikipedia.org/wiki/HTTP_referrer Note 
that it can be forged, etc.

-Dale

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


Re: dynamic return when validation failed

Posted by ma...@yahoo.com.
what I mean is since in the action I already define the result, which has the jsp name, if struts2 provide a way that I can get this info, then I can set it to ${input} easily.

E.g if there is something like xxxx.getResult("page1") and it give me the value "/WEB-INF/pages/page1.jsp" then this solve my problem, so I don't need to store another hidden value in the jsp.

<action name="MyAction" class="MyAction">
<result name="page1">/WEB-INF/pages/page1.jsp</result>
<result name="page2">/WEB-INF/pages/page2.jsp</result>
<result name="input">${input}</result>
</action>


regards
Louis

________________________________
From: Greg Lindholm <gr...@gmail.com>
To: Struts Users Mailing List <us...@struts.apache.org>
Sent: Wednesday, July 8, 2009 5:52:25 PM
Subject: Re: dynamic return when validation failed

The referer header will contain the URL of the last request, which will be
the action URL not the jsp page that rendered the result. So this wouldn't
help the OP if I understood his problem.

On Wed, Jul 8, 2009 at 11:50 AM, Dale Newfield <da...@newfield.org> wrote:

> Greg Lindholm wrote:
>
>> There is nothing in a request that will tell you which page you came from
>> unless you put it there (as with the hidden parameter).
>>
>
> While this is mostly true, it's not 100% true.  HTTP has a "referer" (yes,
> misspelled in the spec) field so most of the time you can know from where a
> link came or a post was posted (assuming this value is provided by the
> browser).  Note, all it provides is the URL of that previous page, so if
> that's not specific enough you're still SOL.
>
> -Dale
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: dynamic return when validation failed

Posted by Greg Lindholm <gr...@gmail.com>.
The referer header will contain the URL of the last request, which will be
the action URL not the jsp page that rendered the result. So this wouldn't
help the OP if I understood his problem.

On Wed, Jul 8, 2009 at 11:50 AM, Dale Newfield <da...@newfield.org> wrote:

> Greg Lindholm wrote:
>
>> There is nothing in a request that will tell you which page you came from
>> unless you put it there (as with the hidden parameter).
>>
>
> While this is mostly true, it's not 100% true.  HTTP has a "referer" (yes,
> misspelled in the spec) field so most of the time you can know from where a
> link came or a post was posted (assuming this value is provided by the
> browser).  Note, all it provides is the URL of that previous page, so if
> that's not specific enough you're still SOL.
>
> -Dale
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: dynamic return when validation failed

Posted by Dale Newfield <da...@newfield.org>.
Greg Lindholm wrote:
> There is nothing in a request that will tell you which page you came from
> unless you put it there (as with the hidden parameter).

While this is mostly true, it's not 100% true.  HTTP has a "referer" 
(yes, misspelled in the spec) field so most of the time you can know 
from where a link came or a post was posted (assuming this value is 
provided by the browser).  Note, all it provides is the URL of that 
previous page, so if that's not specific enough you're still SOL.

-Dale

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


Re: dynamic return when validation failed

Posted by Greg Lindholm <gr...@gmail.com>.
There is nothing in a request that will tell you which page you came from
unless you put it there (as with the hidden parameter).

If you don't like that then use the multiple actions so the action name
tells you where the request came from (and where to go back).



On Wed, Jul 8, 2009 at 11:05 AM, <ma...@yahoo.com> wrote:

> Hi,
>
> Thanks for the reply, I try not to hardcode any file name in the jsp,
> prefer to put it in the struts config file, but don't know how to get the
> value out of it.
>
>
>
> Regards
> Louis
>
>
>
> ________________________________
> From: Greg Lindholm <gr...@gmail.com>
> To: Struts Users Mailing List <us...@struts.apache.org>
> Sent: Wednesday, July 8, 2009 2:46:00 PM
> Subject: Re: dynamic return when validation failed
>
> One way would be to pass a hidden parameter that tells you which page you
> came from.
> In page1.jsp form you could add:
>   <s:hidden name="page" value="page1" />
> You would need to add a setter and getter in you action for page variable.
> Then your result could be:
>   <result name="input">/WEB-INF/pages/${page}.jsp</result>
>
> Another way would to have different actions defined for each page so they
> know where to return to:
>
> <action name="MyActionPage1" class="MyAction">
>   <result name="page1">/WEB-INF/pages/page1.jsp</result>
>  <result name="page2">/WEB-INF/pages/page2.jsp</result>
>  <result name="input">/WEB-INF/pages/page1.jsp</result>
> </action>
> <action name="MyActionPage2" class="MyAction">
>   <result name="page1">/WEB-INF/pages/page1.jsp</result>
>  <result name="page2">/WEB-INF/pages/page2.jsp</result>
>  <result name="input">/WEB-INF/pages/page2.jsp</result>
> </action>
>
> On Wed, Jul 8, 2009 at 4:05 AM, <ma...@yahoo.com> wrote:
>
> > Hello,
> >
> > I'm new to struts2, and learning the validation in struts 2 at the
> moment.
> >
> > I'm not able to get the validation work in the way I want in the webflow
> > (or wizard kind of page) design. Everytime when validation failed, it
> always
> > return to INPUT page, I wondering is there a way I can tell struts return
> to
> > different result page depand on what validation failed.
> >
> > For e.g, I got page1.jsp, page2.jsp both are calling the same action,
> when
> > page1 submit and the validation failed, I want it to go back to page1, if
> > page2 submit I want to control it to go back to page2  if the validation
> > fail.
> >
> > What I can possible think of the solutions right now is write my own
> custom
> > validation interceptor which allow to dynamic set where to return.
> >
> > Another solution I'm not sure whether I can achive or not, for e.g below
> is
> > the configuration of my action
> >
> >
> > <action name="MyAction" class="MyAction">
> > <result name="page1">/WEB-INF/pages/page1.jsp</result>
> > <result name="page2">/WEB-INF/pages/page2.jsp</result>
> > <result name="input">${input}</result>
> > </action>
> >
> > In the action I want to get the value of result name="page1" or "page2",
> is
> > it possible? If so then I can pass it to ${input}
> >
> > Or is there any other better way to solve this?
> >
> >
> > Regards
> > Louis
>

Re: dynamic return when validation failed

Posted by ma...@yahoo.com.
Hi,

Thanks for the reply, I try not to hardcode any file name in the jsp, prefer to put it in the struts config file, but don't know how to get the value out of it.



Regards
Louis



________________________________
From: Greg Lindholm <gr...@gmail.com>
To: Struts Users Mailing List <us...@struts.apache.org>
Sent: Wednesday, July 8, 2009 2:46:00 PM
Subject: Re: dynamic return when validation failed

One way would be to pass a hidden parameter that tells you which page you
came from.
In page1.jsp form you could add:
   <s:hidden name="page" value="page1" />
You would need to add a setter and getter in you action for page variable.
Then your result could be:
   <result name="input">/WEB-INF/pages/${page}.jsp</result>

Another way would to have different actions defined for each page so they
know where to return to:

<action name="MyActionPage1" class="MyAction">
   <result name="page1">/WEB-INF/pages/page1.jsp</result>
  <result name="page2">/WEB-INF/pages/page2.jsp</result>
  <result name="input">/WEB-INF/pages/page1.jsp</result>
</action>
<action name="MyActionPage2" class="MyAction">
   <result name="page1">/WEB-INF/pages/page1.jsp</result>
  <result name="page2">/WEB-INF/pages/page2.jsp</result>
  <result name="input">/WEB-INF/pages/page2.jsp</result>
</action>

On Wed, Jul 8, 2009 at 4:05 AM, <ma...@yahoo.com> wrote:

> Hello,
>
> I'm new to struts2, and learning the validation in struts 2 at the moment.
>
> I'm not able to get the validation work in the way I want in the webflow
> (or wizard kind of page) design. Everytime when validation failed, it always
> return to INPUT page, I wondering is there a way I can tell struts return to
> different result page depand on what validation failed.
>
> For e.g, I got page1.jsp, page2.jsp both are calling the same action, when
> page1 submit and the validation failed, I want it to go back to page1, if
> page2 submit I want to control it to go back to page2  if the validation
> fail.
>
> What I can possible think of the solutions right now is write my own custom
> validation interceptor which allow to dynamic set where to return.
>
> Another solution I'm not sure whether I can achive or not, for e.g below is
> the configuration of my action
>
>
> <action name="MyAction" class="MyAction">
> <result name="page1">/WEB-INF/pages/page1.jsp</result>
> <result name="page2">/WEB-INF/pages/page2.jsp</result>
> <result name="input">${input}</result>
> </action>
>
> In the action I want to get the value of result name="page1" or "page2", is
> it possible? If so then I can pass it to ${input}
>
> Or is there any other better way to solve this?
>
>
> Regards
> Louis

Re: dynamic return when validation failed

Posted by Greg Lindholm <gr...@gmail.com>.
One way would be to pass a hidden parameter that tells you which page you
came from.
In page1.jsp form you could add:
   <s:hidden name="page" value="page1" />
You would need to add a setter and getter in you action for page variable.
Then your result could be:
   <result name="input">/WEB-INF/pages/${page}.jsp</result>

Another way would to have different actions defined for each page so they
know where to return to:

<action name="MyActionPage1" class="MyAction">
   <result name="page1">/WEB-INF/pages/page1.jsp</result>
  <result name="page2">/WEB-INF/pages/page2.jsp</result>
  <result name="input">/WEB-INF/pages/page1.jsp</result>
</action>
<action name="MyActionPage2" class="MyAction">
   <result name="page1">/WEB-INF/pages/page1.jsp</result>
  <result name="page2">/WEB-INF/pages/page2.jsp</result>
  <result name="input">/WEB-INF/pages/page2.jsp</result>
</action>

On Wed, Jul 8, 2009 at 4:05 AM, <ma...@yahoo.com> wrote:

> Hello,
>
> I'm new to struts2, and learning the validation in struts 2 at the moment.
>
> I'm not able to get the validation work in the way I want in the webflow
> (or wizard kind of page) design. Everytime when validation failed, it always
> return to INPUT page, I wondering is there a way I can tell struts return to
> different result page depand on what validation failed.
>
> For e.g, I got page1.jsp, page2.jsp both are calling the same action, when
> page1 submit and the validation failed, I want it to go back to page1, if
> page2 submit I want to control it to go back to page2  if the validation
> fail.
>
> What I can possible think of the solutions right now is write my own custom
> validation interceptor which allow to dynamic set where to return.
>
> Another solution I'm not sure whether I can achive or not, for e.g below is
> the configuration of my action
>
>
> <action name="MyAction" class="MyAction">
> <result name="page1">/WEB-INF/pages/page1.jsp</result>
> <result name="page2">/WEB-INF/pages/page2.jsp</result>
> <result name="input">${input}</result>
> </action>
>
> In the action I want to get the value of result name="page1" or "page2", is
> it possible? If so then I can pass it to ${input}
>
> Or is there any other better way to solve this?
>
>
> Regards
> Louis

dynamic return when validation failed

Posted by ma...@yahoo.com.
Hello,

I'm new to struts2, and learning the validation in struts 2 at the moment.

I'm not able to get the validation work in the way I want in the webflow (or wizard kind of page) design. Everytime when validation failed, it always return to INPUT page, I wondering is there a way I can tell struts return to different result page depand on what validation failed.

For e.g, I got page1.jsp, page2.jsp both are calling the same action, when page1 submit and the validation failed, I want it to go back to page1, if page2 submit I want to control it to go back to page2  if the validation fail.

What I can possible think of the solutions right now is write my own custom validation interceptor which allow to dynamic set where to return.

Another solution I'm not sure whether I can achive or not, for e.g below is the configuration of my action


<action name="MyAction" class="MyAction">
<result name="page1">/WEB-INF/pages/page1.jsp</result>
<result name="page2">/WEB-INF/pages/page2.jsp</result>
<result name="input">${input}</result>
</action>
        
In the action I want to get the value of result name="page1" or "page2", is it possible? If so then I can pass it to ${input}

Or is there any other better way to solve this?


Regards
Louis

Re: Struts 2 Validation

Posted by Robson Rodrigues <ro...@gmail.com>.
Someone can solve my problem? the validator always say the validation failed
:(


Robson Rodrigues wrote:
> 
> Hello People,
> 
>  
> 
> i´m using the struts 2 in a project and i´m with a problem on the
> validation. When i try validate a form, the struts say the validation
> failed, even when the field is with correct value, in addition, it is not
> going back to the field with the old value
> 
>  
> 
> here is my struts.xml. The action is the Cliente_insert:
> 
>  
> 
> <package name="cliente" namespace="/" extends="struts-default">
> 
> <default-interceptor-ref name="defaultStack"/>
> 
>  
> 
> <action name="Cliente_input" >
> 
> <result >/cliente/inputCliente.jsp</result>
> 
> </action>
> 
> <action name="Cliente_edit" class="br.com.robson.modelo.ClienteAction"
> method="editar">
> 
> <interceptor-ref name="paramsPrepareParamsStack" />
> 
> <result >/cliente/editCliente.jsp</result>
> 
> </action>
> 
> <action name="Cliente_list" class="br.com.robson.modelo.ClienteAction"
> method="listar">
> 
> <result name="success">/cliente/listaClientes.jsp</result>
> 
> </action>
> 
> <action name="Cliente_insert" class="br.com.robson.modelo.ClienteAction"
> method="inserir">
> 
> <interceptor-ref name="validationWorkflowStack"/>
> 
>  
> 
> <result name="input">/cliente/inputCliente.jsp</result>
> 
> <result name="success" type="redirect">Cliente_list.action</result>
> 
> </action>
> 
> <action name="Cliente_delete" class="br.com.robson.modelo.ClienteAction"
> method="deletar">
> 
> <result name="success" type="redirect">Cliente_list.action</result>
> 
> </action>
> 
> <action name="Cliente_update" class="br.com.robson.modelo.ClienteAction"
> method="atualizar">
> 
> <result name="success" type="redirect">Cliente_list.action</result>
> 
> </action>
> 
>  
> 
> </package>
> 
>  
> 
> Here is my validation archive:
> 
>  
> 
> <!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="required">
> 
> true
> 
> <message> O campo nome é obrigatório </message>
> 
> </field-validator>
> 
> </field> -->
> 
> <field name="telefone">
> 
> <field-validator type="required">
> 
> true
> 
> <message> O campo telefone é obrigatório </message>
> 
> </field-validator>
> 
> <field-validator type="stringlength">
> 
> true
> 
> 6
> 
> 14
> 
> <message> O campo telefone deve ter entre 6 e 14 caracteres </message>
> 
> </field-validator>
> 
> </field>
> 
> </validators>
> 
>  
> 
> here is my jsp:
> 
>  
> 
> <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
> 
> pageEncoding="ISO-8859-1"%>
> 
> <%@page import="br.com.robson.modelo.Cliente" %>
> 
> <%@page import ="java.util.*" %>
> 
> <%@ taglib prefix="s" uri="/struts-tags" %>
> 
>  
> 
> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd">
> 
> <html:html>
> 
> <head>
> 
> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
> 
> <title>Insert title here</title>
> 
> <script language="javascript">
> 
> </script>
> 
> </head>
> 
> <body>
> 
> Novo Cliente
> 
> <s:debug/>
> 
>  
> 
> <s:form action="Cliente_insert.action" method="POST" >
> 
>  
> 
> <s:textfield name="idCli" label="Id" />
> 
>  
> 
> <s:textfield name="nome" label="Nome"/>
> 
>  
> 
> <s:textfield name="telefone" label="Ielefone"/>
> 
>  
> 
> <s:submit></s:submit>
> 
> </s:form>
> 
>  
> 
>  
> 
>  
> 
>  
> 
> </body>
> 
> </html:html>
> 
>  
> 
> I hope you can help me
> 
>  
> 
> Hugs!
> 
>  
> 
:-(:-/:-(
-- 
View this message in context: http://www.nabble.com/Struts-2-Validation-tp24382602p24393052.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: Struts 2 Validation

Posted by Martin Gainty <mg...@hotmail.com>.

you are taking this course to learn about J2EE apps?

did you even read the email i sent you on setting up min and max params
    <field name="integerValidatorField">
        <field-validator type="int">
            <param name="min">1</param>
            <param name="max">10</param>
            <message><![CDATA[ must be integer min 1 max 10 if supplied ]]></message>
        </field-validator>
    </field>

better to get the fundamentals straight before you hire americans to work at min wage

Martin Gainty 
______________________________________________ 
Jogi és Bizalmassági kinyilatkoztatás/Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 Ez az
üzenet bizalmas.  Ha nem ön az akinek szánva volt, akkor kérjük, hogy
jelentse azt nekünk vissza. Semmiféle továbbítása vagy másolatának
készítése nem megengedett.  Ez az üzenet csak ismeret cserét szolgál és
semmiféle jogi alkalmazhatósága sincs.  Mivel az electronikus üzenetek
könnyen megváltoztathatóak, ezért minket semmi felelöség nem terhelhet
ezen üzenet tartalma miatt.

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 Jul 2009 15:23:53 -0700
> From: robsonsilvar@gmail.com
> To: user@struts.apache.org
> Subject: Re: Struts 2 Validation
> 
> 
> People,
> 
> If someone want help me about my university project, here is my e-mail:
> robsonsilvar@gmail.com . I can send to you the entire projcect. 
> 
> This project is about control of stock and MRP. I´m using Struts2, Hibernate
> and MYSQL. It is separate on three layers with MVC.
> 
> 
> 
> Robson Rodrigues wrote:
> > 
> > Hello People,
> > 
> >  
> > 
> > i´m using the struts 2 in a project and i´m with a problem on the
> > validation. When i try validate a form, the struts say the validation
> > failed, even when the field is with correct value, in addition, it is not
> > going back to the field with the old value
> > 
> >  
> > 
> > here is my struts.xml. The action is the Cliente_insert:
> > 
> >  
> > 
> > <package name="cliente" namespace="/" extends="struts-default">
> > 
> > <default-interceptor-ref name="defaultStack"/>
> > 
> >  
> > 
> > <action name="Cliente_input" >
> > 
> > <result >/cliente/inputCliente.jsp</result>
> > 
> > </action>
> > 
> > <action name="Cliente_edit" class="br.com.robson.modelo.ClienteAction"
> > method="editar">
> > 
> > <interceptor-ref name="paramsPrepareParamsStack" />
> > 
> > <result >/cliente/editCliente.jsp</result>
> > 
> > </action>
> > 
> > <action name="Cliente_list" class="br.com.robson.modelo.ClienteAction"
> > method="listar">
> > 
> > <result name="success">/cliente/listaClientes.jsp</result>
> > 
> > </action>
> > 
> > <action name="Cliente_insert" class="br.com.robson.modelo.ClienteAction"
> > method="inserir">
> > 
> > <interceptor-ref name="validationWorkflowStack"/>
> > 
> >  
> > 
> > <result name="input">/cliente/inputCliente.jsp</result>
> > 
> > <result name="success" type="redirect">Cliente_list.action</result>
> > 
> > </action>
> > 
> > <action name="Cliente_delete" class="br.com.robson.modelo.ClienteAction"
> > method="deletar">
> > 
> > <result name="success" type="redirect">Cliente_list.action</result>
> > 
> > </action>
> > 
> > <action name="Cliente_update" class="br.com.robson.modelo.ClienteAction"
> > method="atualizar">
> > 
> > <result name="success" type="redirect">Cliente_list.action</result>
> > 
> > </action>
> > 
> >  
> > 
> > </package>
> > 
> >  
> > 
> > Here is my validation archive:
> > 
> >  
> > 
> > <!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="required">
> > 
> > true
> > 
> > <message> O campo nome é obrigatório </message>
> > 
> > </field-validator>
> > 
> > </field> -->
> > 
> > <field name="telefone">
> > 
> > <field-validator type="required">
> > 
> > true
> > 
> > <message> O campo telefone é obrigatório </message>
> > 
> > </field-validator>
> > 
> > <field-validator type="stringlength">
> > 
> > true
> > 
> > 6
> > 
> > 14
> > 
> > <message> O campo telefone deve ter entre 6 e 14 caracteres </message>
> > 
> > </field-validator>
> > 
> > </field>
> > 
> > </validators>
> > 
> >  
> > 
> > here is my jsp:
> > 
> >  
> > 
> > <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
> > 
> > pageEncoding="ISO-8859-1"%>
> > 
> > <%@page import="br.com.robson.modelo.Cliente" %>
> > 
> > <%@page import ="java.util.*" %>
> > 
> > <%@ taglib prefix="s" uri="/struts-tags" %>
> > 
> >  
> > 
> > <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> > "http://www.w3.org/TR/html4/loose.dtd">
> > 
> > <html:html>
> > 
> > <head>
> > 
> > <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
> > 
> > <title>Insert title here</title>
> > 
> > <script language="javascript">
> > 
> > </script>
> > 
> > </head>
> > 
> > <body>
> > 
> > Novo Cliente
> > 
> > <s:debug/>
> > 
> >  
> > 
> > <s:form action="Cliente_insert.action" method="POST" >
> > 
> >  
> > 
> > <s:textfield name="idCli" label="Id" />
> > 
> >  
> > 
> > <s:textfield name="nome" label="Nome"/>
> > 
> >  
> > 
> > <s:textfield name="telefone" label="Ielefone"/>
> > 
> >  
> > 
> > <s:submit></s:submit>
> > 
> > </s:form>
> > 
> >  
> > 
> >  
> > 
> >  
> > 
> >  
> > 
> > </body>
> > 
> > </html:html>
> > 
> >  
> > 
> > I hope you can help me
> > 
> >  
> > 
> > Hugs!
> > 
> >  
> > 
> 
> -- 
> View this message in context: http://www.nabble.com/Struts-2-Validation-tp24382602p24400471.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
> 

_________________________________________________________________
Windows Live™: Keep your life in sync. 
http://windowslive.com/explore?ocid=TXT_TAGLM_WL_BR_life_in_synch_062009

Re: Struts 2 Validation

Posted by Robson Rodrigues <ro...@gmail.com>.
People,

If someone want help me about my university project, here is my e-mail:
robsonsilvar@gmail.com . I can send to you the entire projcect. 

This project is about control of stock and MRP. I´m using Struts2, Hibernate
and MYSQL. It is separate on three layers with MVC.



Robson Rodrigues wrote:
> 
> Hello People,
> 
>  
> 
> i´m using the struts 2 in a project and i´m with a problem on the
> validation. When i try validate a form, the struts say the validation
> failed, even when the field is with correct value, in addition, it is not
> going back to the field with the old value
> 
>  
> 
> here is my struts.xml. The action is the Cliente_insert:
> 
>  
> 
> <package name="cliente" namespace="/" extends="struts-default">
> 
> <default-interceptor-ref name="defaultStack"/>
> 
>  
> 
> <action name="Cliente_input" >
> 
> <result >/cliente/inputCliente.jsp</result>
> 
> </action>
> 
> <action name="Cliente_edit" class="br.com.robson.modelo.ClienteAction"
> method="editar">
> 
> <interceptor-ref name="paramsPrepareParamsStack" />
> 
> <result >/cliente/editCliente.jsp</result>
> 
> </action>
> 
> <action name="Cliente_list" class="br.com.robson.modelo.ClienteAction"
> method="listar">
> 
> <result name="success">/cliente/listaClientes.jsp</result>
> 
> </action>
> 
> <action name="Cliente_insert" class="br.com.robson.modelo.ClienteAction"
> method="inserir">
> 
> <interceptor-ref name="validationWorkflowStack"/>
> 
>  
> 
> <result name="input">/cliente/inputCliente.jsp</result>
> 
> <result name="success" type="redirect">Cliente_list.action</result>
> 
> </action>
> 
> <action name="Cliente_delete" class="br.com.robson.modelo.ClienteAction"
> method="deletar">
> 
> <result name="success" type="redirect">Cliente_list.action</result>
> 
> </action>
> 
> <action name="Cliente_update" class="br.com.robson.modelo.ClienteAction"
> method="atualizar">
> 
> <result name="success" type="redirect">Cliente_list.action</result>
> 
> </action>
> 
>  
> 
> </package>
> 
>  
> 
> Here is my validation archive:
> 
>  
> 
> <!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="required">
> 
> true
> 
> <message> O campo nome é obrigatório </message>
> 
> </field-validator>
> 
> </field> -->
> 
> <field name="telefone">
> 
> <field-validator type="required">
> 
> true
> 
> <message> O campo telefone é obrigatório </message>
> 
> </field-validator>
> 
> <field-validator type="stringlength">
> 
> true
> 
> 6
> 
> 14
> 
> <message> O campo telefone deve ter entre 6 e 14 caracteres </message>
> 
> </field-validator>
> 
> </field>
> 
> </validators>
> 
>  
> 
> here is my jsp:
> 
>  
> 
> <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
> 
> pageEncoding="ISO-8859-1"%>
> 
> <%@page import="br.com.robson.modelo.Cliente" %>
> 
> <%@page import ="java.util.*" %>
> 
> <%@ taglib prefix="s" uri="/struts-tags" %>
> 
>  
> 
> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd">
> 
> <html:html>
> 
> <head>
> 
> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
> 
> <title>Insert title here</title>
> 
> <script language="javascript">
> 
> </script>
> 
> </head>
> 
> <body>
> 
> Novo Cliente
> 
> <s:debug/>
> 
>  
> 
> <s:form action="Cliente_insert.action" method="POST" >
> 
>  
> 
> <s:textfield name="idCli" label="Id" />
> 
>  
> 
> <s:textfield name="nome" label="Nome"/>
> 
>  
> 
> <s:textfield name="telefone" label="Ielefone"/>
> 
>  
> 
> <s:submit></s:submit>
> 
> </s:form>
> 
>  
> 
>  
> 
>  
> 
>  
> 
> </body>
> 
> </html:html>
> 
>  
> 
> I hope you can help me
> 
>  
> 
> Hugs!
> 
>  
> 

-- 
View this message in context: http://www.nabble.com/Struts-2-Validation-tp24382602p24400471.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