validate input field in jsf datatable -
I have an input field in the jsf dataset which I am validating and adding an error message, but the error message is not displayed it happens. What is the best way to validate the input field and add message in JSF Datable?
& lt; H: InputTactress ID = "TextAra1" style = "#Input" "gt; & lt; f: attribute name =" msgRef "value =" valid comment is required. "/ & Gt; & lt; / h: inputTextarea & Lt; h: class = "message" for message style = "textarea1" id = "textarea1 message" & gt; & lt; / h: message & gt;
Any help is great.
Thanks, Sujit
This code looks properly Assuming that they are both placed within & lt; h: Columns & gt;
(though similar column is not), so The problem is elsewhere.
If you want to be valid after all whether the value is filled or not, then you need to add the component to essential = "true"
& lt; h: inputSomething = "true" />
If you want to override the default required message, either Use the Required message
attribute (only after JSF 1.2)
& lt; H: inputSomething Required = "true" Required Message = "Please enter the price ! "/ & Gt;
... or custom messages. Provide
with faces-config.xml
bundle
in the applications
to the properties . > javax.faces.component.UIInput.REQUIRED = Please enter {0}.
... where is controlled by {0}
(since JSF 1.2 only, otherwise it is clientId
).
& lt; H: inputSomething label = "this field" />
> faces-config.xml
& lt; Validator & gt; & Lt; Verifier-ID & gt; MyValidator & lt; / Verifier-ID & gt; & Lt; Verifier category & gt; Com.example.MyValidator & lt; / Verifier category & gt; & Lt; / Verifier & gt;
... and attach it to the input component by validator
attribute
input: some validator = " MyValidator "/ & gt;
... or aspect (so that you can attach multiple components into one component)
& lt; H: inputSomething & gt; & Lt; F: Authenticator ID = "myValidator" /> & Lt; / H: inputSomething & gt;
Implemented within valid ()
method, when desired, whenever needed. ValidatorException throws public {valid for FacesContext reference, UIComponent component, object value} {if the value does not match with certain condition} {New Valuation Expression (new face message ("Enter valid value" Do ")); }}
Then it will automatically appear in the related message component.
Comments
Post a Comment