You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Eric MacAdie <em...@gmail.com> on 2013/09/16 04:20:52 UTC

Issues with docs

I don't know if this is the place to point this out, but it looks like the
docs on the Apache website need a bit of work.

When I go to http://struts.apache.org/release/2.3.x/docs/unit-testing.html,
I got a warning pop-up window saying: "Syntax Highlighter: Can't find brush
for: xml"

That happens on quite a few of the 2.3 pages, but none of the 2.2 pages.

- Eric MacAdie

Re: validator type="regex" : param name is regex , not expression

Posted by Lukasz Lenart <lu...@apache.org>.
Done, thanks for reporting!

https://cwiki.apache.org/confluence/display/WW/Form+Validation+Using+XML

2013/9/16 Chris <ch...@yahoo.fr>:
> Hi Lukasz,
>
> Good example of regex in http://struts.apache.org/development/2.x/docs/form-validation-using-xml.html ,
> and choose  between JavaScript validator or Java validator will be another story .;-)
>
>
> but the file EditAction-validation.xml seems contain a wrong value.
> .
>
> I found it in testing PhoneNumber with many wrong values and it always worked !
> I thought maybe a jar is missing ?
>
> But it was the param name in the file EditAction-validation.xml
> -> <param name="expression"> should be <param name="regex">
>
> before
> <validator type="regex">
>     <param name="fieldname">personBean.phoneNumber</param>
>     <param name="expression"><![CDATA[\d{3}-\d{3}-\d{4}]]></param>
>     <message>Phone number must be entered as 999-999-9999.</message>
> </validator>
>
> after
> <validator type="regex">
>     <param name="fieldname">personBean.phoneNumber</param>
>     <param name="regex"><![CDATA[\d{3}-\d{3}-\d{4}]]></param>
>     <message>Phone number must be entered as 999-999-9999.</message>
> </validator>
>
>
>
>
> Regards,
>
> Chris ( christalkto )
>
>
> ________________________________

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


validator type="regex" : param name is regex , not expression

Posted by Chris <ch...@yahoo.fr>.
Hi Lukasz,

Good example of regex in http://struts.apache.org/development/2.x/docs/form-validation-using-xml.html ,  
and choose  between JavaScript validator or Java validator will be another story .;-)


but the file EditAction-validation.xml seems contain a wrong value.
. 

I found it in testing PhoneNumber with many wrong values and it always worked !
I thought maybe a jar is missing ? 

But it was the param name in the file EditAction-validation.xml
-> <param name="expression"> should be <param name="regex">

before
<validator type="regex">
    <param name="fieldname">personBean.phoneNumber</param>
    <param name="expression"><![CDATA[\d{3}-\d{3}-\d{4}]]></param>
    <message>Phone number must be entered as 999-999-9999.</message>
</validator>

after 
<validator type="regex">
    <param name="fieldname">personBean.phoneNumber</param>
    <param name="regex"><![CDATA[\d{3}-\d{3}-\d{4}]]></param>
    <message>Phone number must be entered as 999-999-9999.</message>
</validator>




Regards,

Chris ( christalkto ) 


________________________________

Re: How configure struts2 to get validation rules from Spring via @value

Posted by Alireza Fattahi <af...@yahoo.com>.
Let me ask this way.
In below validation
@IntRangeFieldValidator(type =ValidatorType.FIELD,min ="10"

is there any way we can read '10' from external resource files !


 
~Regards,
~~Alireza Fattahi


________________________________
 From: Lukasz Lenart <lu...@apache.org>
To: Struts Users Mailing List <us...@struts.apache.org> 
Sent: Tuesday, 17 September 2013, 12:48
Subject: Re: How configure struts2 to get validation rules from Spring via @value
 

Code formatting? Maybe use some web service to present your code.

Does system.properties is defined as a Struts 2 properties file?

2013/9/17 Alireza Fattahi <af...@yahoo.com>:
> We are using spring 3 and struts 2. We use spring @value annotation to get values from property files.
> We want to get validation rules from property files instead of hard-coding them in action.
> Here is sample property system.properties transfer.account.min.amount=10
> Here is the action:
> publicclassTransferToAccountimplementsPreparable{@Value("${transfer.account.min.amount}")publicStringminAmount;//...........execute and other methods omitted@IntRangeFieldValidator(type =ValidatorType.FIELD,min ="${minAmount}",key ="validate.int.min")publicvoidsetAmount(Integeramount){this.amount =amount;}
> The minAmount is populated correctly by value 10, but the validation is not working.
> ________________________________
>
> To see if parameters are passed correctly, I make a test as below.
> Assume we want to get a key from spring managed property file ( This is just a test ;) )
> system.properties
> transfer.account.min.amount.key=validate.int.min
> The resource bundel is: validate.int.min = This field must be more than ${min}
> ...and make this change
> @IntRangeFieldValidator(type =ValidatorType.FIELD,min ="${minAmount}",key ="${transfer.account.min.amount.key}")
> Now when an error happens the validation message shows validate.int.min, instead of fetching this value from resource bundle!
> Of course, when you run below code:
> @IntRangeFieldValidator(type =ValidatorType.FIELD,min ="${minAmount}",key ="validate.int.min")
> The error message is fetched resource bundle correctly!
> ________________________________
>
> If I can use annotation in this way, please let me know what is my mistake!
> If I can not use annotations like this, please let me know what is
> the best way to avoid hard coding the validaiton rolls in actions.
>
>
> ~Regards,
> ~~Alireza Fattahi

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

Re: How configure struts2 to get validation rules from Spring via @value

Posted by Lukasz Lenart <lu...@apache.org>.
2013/9/20 Alireza Fattahi <af...@yahoo.com>:
> Let me ask this way.
> In below validation
> @IntRangeFieldValidator(type =ValidatorType.FIELD,min ="10"
>
> is there any way we can read '10' from external resource files !

Directly not, but there is built-in support for expression, so you can
use minExpression="${minFieldValue}" which will be evaluated against
your action. Or you can use xml based validation and then '10' will be
in a file ;-)


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

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


Re: How configure struts2 to get validation rules from Spring via @value

Posted by Alireza Fattahi <af...@yahoo.com>.
Let me ask this way.
In below validation
@IntRangeFieldValidator(type =ValidatorType.FIELD,min ="10"

is there any way we can read '10' from external resource files !


 
~Regards,
~~Alireza Fattahi


________________________________
 From: Lukasz Lenart <lu...@apache.org>
To: Struts Users Mailing List <us...@struts.apache.org> 
Sent: Tuesday, 17 September 2013, 12:48
Subject: Re: How configure struts2 to get validation rules from Spring via @value
 

Code formatting? Maybe use some web service to present your code.

Does system.properties is defined as a Struts 2 properties file?

2013/9/17 Alireza Fattahi <af...@yahoo.com>:
> We are using spring 3 and struts 2. We use spring @value annotation to get values from property files.
> We want to get validation rules from property files instead of hard-coding them in action.
> Here is sample property system.properties transfer.account.min.amount=10
> Here is the action:
> publicclassTransferToAccountimplementsPreparable{@Value("${transfer.account.min.amount}")publicStringminAmount;//...........execute and other methods omitted@IntRangeFieldValidator(type =ValidatorType.FIELD,min ="${minAmount}",key ="validate.int.min")publicvoidsetAmount(Integeramount){this.amount =amount;}
> The minAmount is populated correctly by value 10, but the validation is not working.
> ________________________________
>
> To see if parameters are passed correctly, I make a test as below.
> Assume we want to get a key from spring managed property file ( This is just a test ;) )
> system.properties
> transfer.account.min.amount.key=validate.int.min
> The resource bundel is: validate.int.min = This field must be more than ${min}
> ...and make this change
> @IntRangeFieldValidator(type =ValidatorType.FIELD,min ="${minAmount}",key ="${transfer.account.min.amount.key}")
> Now when an error happens the validation message shows validate.int.min, instead of fetching this value from resource bundle!
> Of course, when you run below code:
> @IntRangeFieldValidator(type =ValidatorType.FIELD,min ="${minAmount}",key ="validate.int.min")
> The error message is fetched resource bundle correctly!
> ________________________________
>
> If I can use annotation in this way, please let me know what is my mistake!
> If I can not use annotations like this, please let me know what is
> the best way to avoid hard coding the validaiton rolls in actions.
>
>
> ~Regards,
> ~~Alireza Fattahi

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

Re: How configure struts2 to get validation rules from Spring via @value

Posted by Lukasz Lenart <lu...@apache.org>.
Code formatting? Maybe use some web service to present your code.

Does system.properties is defined as a Struts 2 properties file?

2013/9/17 Alireza Fattahi <af...@yahoo.com>:
> We are using spring 3 and struts 2. We use spring @value annotation to get values from property files.
> We want to get validation rules from property files instead of hard-coding them in action.
> Here is sample property system.properties transfer.account.min.amount=10
> Here is the action:
> publicclassTransferToAccountimplementsPreparable{@Value("${transfer.account.min.amount}")publicStringminAmount;//...........execute and other methods omitted@IntRangeFieldValidator(type =ValidatorType.FIELD,min ="${minAmount}",key ="validate.int.min")publicvoidsetAmount(Integeramount){this.amount =amount;}
> The minAmount is populated correctly by value 10, but the validation is not working.
> ________________________________
>
> To see if parameters are passed correctly, I make a test as below.
> Assume we want to get a key from spring managed property file ( This is just a test ;) )
> system.properties
> transfer.account.min.amount.key=validate.int.min
> The resource bundel is: validate.int.min = This field must be more than ${min}
> ...and make this change
> @IntRangeFieldValidator(type =ValidatorType.FIELD,min ="${minAmount}",key ="${transfer.account.min.amount.key}")
> Now when an error happens the validation message shows validate.int.min, instead of fetching this value from resource bundle!
> Of course, when you run below code:
> @IntRangeFieldValidator(type =ValidatorType.FIELD,min ="${minAmount}",key ="validate.int.min")
> The error message is fetched resource bundle correctly!
> ________________________________
>
> If I can use annotation in this way, please let me know what is my mistake!
> If I can not use annotations like this, please let me know what is
> the best way to avoid hard coding the validaiton rolls in actions.
>
>
> ~Regards,
> ~~Alireza Fattahi

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


How configure struts2 to get validation rules from Spring via @value

Posted by Alireza Fattahi <af...@yahoo.com>.
We are using spring 3 and struts 2. We use spring @value annotation to get values from property files. 
We want to get validation rules from property files instead of hard-coding them in action. 
Here is sample property system.properties transfer.account.min.amount=10 
Here is the action: 
publicclassTransferToAccountimplementsPreparable{@Value("${transfer.account.min.amount}")publicStringminAmount;//...........execute and other methods omitted@IntRangeFieldValidator(type =ValidatorType.FIELD,min ="${minAmount}",key ="validate.int.min")publicvoidsetAmount(Integeramount){this.amount =amount;} 
The minAmount is populated correctly by value 10, but the validation is not working. 
________________________________
 
To see if parameters are passed correctly, I make a test as below. 
Assume we want to get a key from spring managed property file ( This is just a test ;) ) 
system.properties
transfer.account.min.amount.key=validate.int.min 
The resource bundel is: validate.int.min = This field must be more than ${min} 
...and make this change 
@IntRangeFieldValidator(type =ValidatorType.FIELD,min ="${minAmount}",key ="${transfer.account.min.amount.key}") 
Now when an error happens the validation message shows validate.int.min, instead of fetching this value from resource bundle!  
Of course, when you run below code: 
@IntRangeFieldValidator(type =ValidatorType.FIELD,min ="${minAmount}",key ="validate.int.min") 
The error message is fetched resource bundle correctly! 
________________________________
 
If I can use annotation in this way, please let me know what is my mistake! 
If I can not use annotations like this, please let me know what is 
the best way to avoid hard coding the validaiton rolls in actions. 


~Regards,
~~Alireza Fattahi

Re: Issues with docs

Posted by Lukasz Lenart <lu...@apache.org>.
It will be updated with next release - soon


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

2013/9/16 Ken McWilliams <ke...@gmail.com>:
> Still you can't have users going to improper content, how would they know
> it works elsewhere?
> The content missing on the page (code) is a significant issue.
>
>
> On Sun, Sep 15, 2013 at 11:16 PM, Lukasz Lenart <lu...@apache.org>wrote:
>
>> Thanks, but it is already solved with Draft docs
>>
>> http://struts.apache.org/development/2.x/docs/unit-testing.html
>>
>>
>> Regards
>> --
>> Łukasz
>> + 48 606 323 122 http://www.lenart.org.pl/
>>
>> 2013/9/16 Eric MacAdie <em...@gmail.com>:
>> > I don't know if this is the place to point this out, but it looks like
>> the
>> > docs on the Apache website need a bit of work.
>> >
>> > When I go to
>> http://struts.apache.org/release/2.3.x/docs/unit-testing.html,
>> > I got a warning pop-up window saying: "Syntax Highlighter: Can't find
>> brush
>> > for: xml"
>> >
>> > That happens on quite a few of the 2.3 pages, but none of the 2.2 pages.
>> >
>> > - Eric MacAdie
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>

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


Re: Issues with docs

Posted by Ken McWilliams <ke...@gmail.com>.
Still you can't have users going to improper content, how would they know
it works elsewhere?
The content missing on the page (code) is a significant issue.


On Sun, Sep 15, 2013 at 11:16 PM, Lukasz Lenart <lu...@apache.org>wrote:

> Thanks, but it is already solved with Draft docs
>
> http://struts.apache.org/development/2.x/docs/unit-testing.html
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> 2013/9/16 Eric MacAdie <em...@gmail.com>:
> > I don't know if this is the place to point this out, but it looks like
> the
> > docs on the Apache website need a bit of work.
> >
> > When I go to
> http://struts.apache.org/release/2.3.x/docs/unit-testing.html,
> > I got a warning pop-up window saying: "Syntax Highlighter: Can't find
> brush
> > for: xml"
> >
> > That happens on quite a few of the 2.3 pages, but none of the 2.2 pages.
> >
> > - Eric MacAdie
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: Issues with docs

Posted by Lukasz Lenart <lu...@apache.org>.
Thanks, but it is already solved with Draft docs

http://struts.apache.org/development/2.x/docs/unit-testing.html


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

2013/9/16 Eric MacAdie <em...@gmail.com>:
> I don't know if this is the place to point this out, but it looks like the
> docs on the Apache website need a bit of work.
>
> When I go to http://struts.apache.org/release/2.3.x/docs/unit-testing.html,
> I got a warning pop-up window saying: "Syntax Highlighter: Can't find brush
> for: xml"
>
> That happens on quite a few of the 2.3 pages, but none of the 2.2 pages.
>
> - Eric MacAdie

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