java - JSF: Accessing Bean from Validator via field -
I have a JSF videorator who checks whether the container number is consistent with string specificity or not.
This works fine, though I must add some conditional processing based on other values in the bean where the container comes from the number. This bean can be of many different types.
Is there a way to use and work on bean in verification? Ideally I would love to keep it as a legitimate, although if there is no solution, then I have to apply it before applying logic in Bean.
I am thinking on the lines of this:
public class ContainerNumberValidator applies javax.faces.validator.validator {public void verification (FacesContext reference, UIComponent component , Object value) Throw ValidatorException {substance bean = UIComponent.getMyBeanSomehowThroughAMagicMethod (); If (BeanA instanceof beans) {// do this} else if (BeanB instanceof beans) {// that}}
Update: In many ways it At the same time there is a similar problem for the recognition of many areas by balusc is useful.
Highly appreciated.
D.
After
use & lt; f: attribute & gt;
You pass a bean to the verifier and can be obtained by the component as a value expression
Then my input is like this.
& lt: (use ; inputText> at & lt
and no validator attribute; validator & gt; Should be done f); H: InputTapped ID = "Container New" Size = "20" Maximum Lang = "20" Value = "# {Container Stop Action". ContainerStock.containerNumber} "& gt; & Lt; F: Validator ID = "Container Number Wieladient" / & gt; & Lt; F: attribute name = "containerbine" value = "# {containerstock action. ContainerStock}" /> & Lt; / H: inputText> ValidatorException {String containerNumber = (string) value: ; Object containerbene = component.get valueexpress ("containerbene"). GetValue (context.getELContext ()); If (container bean example beans) {// do it}
Comments
Post a Comment