You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shale.apache.org by Sanjay Choudhary <ch...@gmail.com> on 2007/03/14 21:32:43 UTC

Defining mask globally

hi

I wish to define the global regex for masks in a common file. For example ,
name field mask will be like ^[a-zA-Z]+$.

<h:inputText id="nameame" styleClass="inputText"
                    value="#{BrokerRepresentative.name}" size="20">
                    <val:commonsValidator type="mask" arg="Company Name"
server="true"
                        client="false">
                        <val:validatorVar name="mask" value="^[a-zA-Z]+$" />
                    </val:commonsValidator>
                </h:inputText>

I wish to replace this with something like

<f:loadBundle basename="globalmasks" val="globalmask"/>

<h:inputText id="nameame" styleClass="inputText"
                    value="#{BrokerRepresentative.name}" size="20">
                    <val:commonsValidator type="mask" arg="Company Name"
server="true"
                        client="false">
                        <val:validatorVar name="mask" value="#{
globalmask.name}" />
                    </val:commonsValidator>
                </h:inputText>

This will enable me to validate the name field in a uniform way through out
my application. Also if any change is need in regex then it needs to applied
in one place.  When I tried this solution  I got


java.lang.NullPointerException
	org.apache.shale.validator.CommonsValidator.convert(CommonsValidator.java:954)
	org.apache.shale.validator.CommonsValidator.loadMethodParamValues(CommonsValidator.java:715)
	org.apache.shale.validator.CommonsValidator.validate(CommonsValidator.java:793)
	javax.faces.component.UIInput.validateValue(UIInput.java:781)
	javax.faces.component.UIInput.validate(UIInput.java:645)
	javax.faces.component.UIInput.executeValidate(UIInput.java:849)
	javax.faces.component.UIInput.processValidators(UIInput.java:412)
	javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:912)
	javax.faces.component.UIForm.processValidators(UIForm.java:170)
	javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:912)
	javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:912)
	javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:342)
	com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:78)
	com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
	com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
	javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)



Any help /commens/ pointers appreciated to resolve this problem.  I open to
different solution too.


Thanks,
sanjay

Re: Defining mask globally

Posted by Sanjay Choudhary <ch...@gmail.com>.
Hi Hermod,

I am using version 1.0.4 of shale-validator.

Is this the right approach to manage the regex for the mask?

I also double checked about typo error, that error was in email message but
not in the code.

Thanks




On 3/14/07, Hermod Opstvedt <he...@opstvedt.com> wrote:
>
> Hi
>
> Another question: Which version is this of shale-validator? The
> linenumbers
> don't match up with the current.
>
> Hermod
>
>
> -----Opprinnelig melding-----
> Fra: Sanjay Choudhary [mailto:choudharysanjay@gmail.com]
> Sendt: 14. mars 2007 21:33
> Til: user@shale.apache.org
> Emne: Defining mask globally
>
> hi
>
> I wish to define the global regex for masks in a common file. For example
> ,
> name field mask will be like ^[a-zA-Z]+$.
>
> <h:inputText id="nameame" styleClass="inputText"
>                     value="#{BrokerRepresentative.name}" size="20">
>                     <val:commonsValidator type="mask" arg="Company Name"
> server="true"
>                         client="false">
>                         <val:validatorVar name="mask" value="^[a-zA-Z]+$"
> />
>                     </val:commonsValidator>
>                 </h:inputText>
>
> I wish to replace this with something like
>
> <f:loadBundle basename="globalmasks" val="globalmask"/>
>
> <h:inputText id="nameame" styleClass="inputText"
>                     value="#{BrokerRepresentative.name}" size="20">
>                     <val:commonsValidator type="mask" arg="Company Name"
> server="true"
>                         client="false">
>                         <val:validatorVar name="mask" value="#{
> globalmask.name}" />
>                     </val:commonsValidator>
>                 </h:inputText>
>
> This will enable me to validate the name field in a uniform way through
> out
> my application. Also if any change is need in regex then it needs to
> applied
> in one place.  When I tried this solution  I got
>
>
> java.lang.NullPointerException
>
> org.apache.shale.validator.CommonsValidator.convert(CommonsValidator.java
> :95
> 4)
>
> org.apache.shale.validator.CommonsValidator.loadMethodParamValues
> (CommonsVal
> idator.java:715)
>
> org.apache.shale.validator.CommonsValidator.validate(CommonsValidator.java
> :7
> 93)
>         javax.faces.component.UIInput.validateValue(UIInput.java:781)
>         javax.faces.component.UIInput.validate(UIInput.java:645)
>         javax.faces.component.UIInput.executeValidate(UIInput.java:849)
>         javax.faces.component.UIInput.processValidators(UIInput.java:412)
>
> javax.faces.component.UIComponentBase.processValidators(
> UIComponentBase.java
> :912)
>         javax.faces.component.UIForm.processValidators(UIForm.java:170)
>
> javax.faces.component.UIComponentBase.processValidators(
> UIComponentBase.java
> :912)
>
> javax.faces.component.UIComponentBase.processValidators(
> UIComponentBase.java
> :912)
>
> javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:342)
>
> com.sun.faces.lifecycle.ProcessValidationsPhase.execute
> (ProcessValidationsPh
> ase.java:78)
>         com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java
> :200)
>         com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java
> :90)
>         javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
>
>
>
> Any help /commens/ pointers appreciated to resolve this problem.  I open
> to
> different solution too.
>
>
> Thanks,
> sanjay
>
>

SV: Defining mask globally

Posted by Hermod Opstvedt <he...@opstvedt.com>.
Hi

Another question: Which version is this of shale-validator? The linenumbers
don't match up with the current.

Hermod


-----Opprinnelig melding-----
Fra: Sanjay Choudhary [mailto:choudharysanjay@gmail.com] 
Sendt: 14. mars 2007 21:33
Til: user@shale.apache.org
Emne: Defining mask globally

hi

I wish to define the global regex for masks in a common file. For example ,
name field mask will be like ^[a-zA-Z]+$.

<h:inputText id="nameame" styleClass="inputText"
                    value="#{BrokerRepresentative.name}" size="20">
                    <val:commonsValidator type="mask" arg="Company Name"
server="true"
                        client="false">
                        <val:validatorVar name="mask" value="^[a-zA-Z]+$" />
                    </val:commonsValidator>
                </h:inputText>

I wish to replace this with something like

<f:loadBundle basename="globalmasks" val="globalmask"/>

<h:inputText id="nameame" styleClass="inputText"
                    value="#{BrokerRepresentative.name}" size="20">
                    <val:commonsValidator type="mask" arg="Company Name"
server="true"
                        client="false">
                        <val:validatorVar name="mask" value="#{
globalmask.name}" />
                    </val:commonsValidator>
                </h:inputText>

This will enable me to validate the name field in a uniform way through out
my application. Also if any change is need in regex then it needs to applied
in one place.  When I tried this solution  I got


java.lang.NullPointerException
	
org.apache.shale.validator.CommonsValidator.convert(CommonsValidator.java:95
4)
	
org.apache.shale.validator.CommonsValidator.loadMethodParamValues(CommonsVal
idator.java:715)
	
org.apache.shale.validator.CommonsValidator.validate(CommonsValidator.java:7
93)
	javax.faces.component.UIInput.validateValue(UIInput.java:781)
	javax.faces.component.UIInput.validate(UIInput.java:645)
	javax.faces.component.UIInput.executeValidate(UIInput.java:849)
	javax.faces.component.UIInput.processValidators(UIInput.java:412)
	
javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java
:912)
	javax.faces.component.UIForm.processValidators(UIForm.java:170)
	
javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java
:912)
	
javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java
:912)
	
javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:342)
	
com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPh
ase.java:78)
	com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
	com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
	javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)



Any help /commens/ pointers appreciated to resolve this problem.  I open to
different solution too.


Thanks,
sanjay


SV: Defining mask globally

Posted by Hermod Opstvedt <he...@opstvedt.com>.
Hi

Is it a typo that you have: value="#{ globalmask.name}" />? Note the space
after the curlybracket

Hermod


-----Opprinnelig melding-----
Fra: Sanjay Choudhary [mailto:choudharysanjay@gmail.com] 
Sendt: 14. mars 2007 21:33
Til: user@shale.apache.org
Emne: Defining mask globally

hi

I wish to define the global regex for masks in a common file. For example ,
name field mask will be like ^[a-zA-Z]+$.

<h:inputText id="nameame" styleClass="inputText"
                    value="#{BrokerRepresentative.name}" size="20">
                    <val:commonsValidator type="mask" arg="Company Name"
server="true"
                        client="false">
                        <val:validatorVar name="mask" value="^[a-zA-Z]+$" />
                    </val:commonsValidator>
                </h:inputText>

I wish to replace this with something like

<f:loadBundle basename="globalmasks" val="globalmask"/>

<h:inputText id="nameame" styleClass="inputText"
                    value="#{BrokerRepresentative.name}" size="20">
                    <val:commonsValidator type="mask" arg="Company Name"
server="true"
                        client="false">
                        <val:validatorVar name="mask" value="#{
globalmask.name}" />
                    </val:commonsValidator>
                </h:inputText>

This will enable me to validate the name field in a uniform way through out
my application. Also if any change is need in regex then it needs to applied
in one place.  When I tried this solution  I got


java.lang.NullPointerException
	
org.apache.shale.validator.CommonsValidator.convert(CommonsValidator.java:95
4)
	
org.apache.shale.validator.CommonsValidator.loadMethodParamValues(CommonsVal
idator.java:715)
	
org.apache.shale.validator.CommonsValidator.validate(CommonsValidator.java:7
93)
	javax.faces.component.UIInput.validateValue(UIInput.java:781)
	javax.faces.component.UIInput.validate(UIInput.java:645)
	javax.faces.component.UIInput.executeValidate(UIInput.java:849)
	javax.faces.component.UIInput.processValidators(UIInput.java:412)
	
javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java
:912)
	javax.faces.component.UIForm.processValidators(UIForm.java:170)
	
javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java
:912)
	
javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java
:912)
	
javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:342)
	
com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPh
ase.java:78)
	com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
	com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
	javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)



Any help /commens/ pointers appreciated to resolve this problem.  I open to
different solution too.


Thanks,
sanjay