You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by PutoDemonio <al...@gmail.com> on 2008/08/07 11:40:31 UTC
v:commonsValidator maxlength
I'm searching info about how to use v:commonsValidator, something more than
check a required field or an email, but I don't find anything.
Where can I find something like documentation, and not just a little
example, always the same "required field" example!!
I'm trying to validate the maxlength of a textArea, and I try something like
this:
<h:inputTextarea styleClass="text medium" id="description"
value="#{subsystemForm.subsystem.description}" required="true"
maxlength="1500">
<v:commonsValidator type="required"
arg="#{text['subsystem.description']}" />
<v:commonsValidator type="maxlength"
arg="#{text['subsystem.description']}"/>
</h:inputTextarea>
But I think that I have to set the maxlength value in some parameter in
v:commonsValidator node...
Please, help! This must be too easy to loose so much time!!!
--
View this message in context: http://www.nabble.com/v%3AcommonsValidator-maxlength-tp18867067p18867067.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.
Re: v:commonsValidator maxlength
Posted by PutoDemonio <al...@gmail.com>.
Thank you very much.
Your message has help me very much!
--
View this message in context: http://www.nabble.com/v%3AcommonsValidator-maxlength-tp18867067p18886247.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.
Re: v:commonsValidator maxlength
Posted by PutoDemonio <al...@gmail.com>.
Sorry, but I have to change that code, because it had a mistake.
If you had disabled the JavaScript, the server validation thowed an
exception, caused by adding the "maxlength" parameter, I don't know exactly
why!!
It was necesary for client validation, so Whath could I do?
I have edit the validator-rules.xml, to change the name of the parameter
that client validator looks for.
I have change it from maxlength to max, so now I use the same parameter to
server and client validation.
The part of the validator-rules.xml I have change is:
<validator name="maxlength"
classname="org.apache.commons.validator.GenericValidator"
method="maxLength"
methodParams="java.lang.String,int"
depends=""
msg="errors.maxlength">
[...]
var iMax = parseInt(oMaxLength[x][2]("max"));
[...]
</validator>
And my code now is:
Now my code is:
<h:inputTextarea styleClass="text medium" id="description"
value="#{subsystemForm.subsystem.description}" required="true"
maxlength="1500" cols="80" rows="10">
<v:commonsValidator type="required"
arg="#{text['subsystem.description']}"
server="true"
client="true"/>
<v:commonsValidator type="maxlength"
arg="#{text['subsystem.description']}"
max="1500"
server="true"
client="true"/>
</h:inputTextarea>
--
View this message in context: http://www.nabble.com/v%3AcommonsValidator-maxlength-tp18867067p18888006.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.
Re: v:commonsValidator maxlength
Posted by PutoDemonio <al...@gmail.com>.
Now my code is:
<h:inputTextarea styleClass="text medium" id="description"
value="#{subsystemForm.subsystem.description}" required="true"
maxlength="1500" cols="80" rows="10">
<v:commonsValidator type="required"
arg="#{text['subsystem.description']}"
server="true"
client="true"/>
<v:commonsValidator type="maxlength"
arg="#{text['subsystem.description']}"
max="1500"
maxlength="1500"
server="true"
client="true"/>
</h:inputTextarea>
The "max" parameter is to server side validatioin, and the "maxlength"
parameter to the client side.
Thank you one more time!!!
--
View this message in context: http://www.nabble.com/v%3AcommonsValidator-maxlength-tp18867067p18886904.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.