get inputText maxlength attribute in custom validator

UI Components for JSF
Post Reply
rchiu5hk
Posts: 32
Joined: 29 Jun 2015, 03:50

16 Feb 2017, 09:01

Dear all ,

In custom validator, can I get the inputText maxlength attribute value without add attribute tag??

Code: Select all

<p:inputText id="roomInput" maxlength="5" value= "#{detailVo.correnglaRoom}" 		style= "text-transform: uppercase">
									<f:validator validatorId="timEngValidator"/>
<f:attribute name="engValMsg" value="Room cannot contain Chinese" />
							
</p:inputText>

@FacesValidator("timEngValidator")
public class TimEngValidator implements Validator {

	@Override
	public void validate(FacesContext context, UIComponent component,
			Object value) throws ValidatorException {

		// HOW can I GET the inputText maxlength attribute??

	}

}

tandraschko
PrimeFaces Core Developer
Posts: 3979
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

16 Feb 2017, 10:29

Cast to InputText and call getMaxlength ;)
Thomas Andraschko

PrimeFaces | PrimeFaces Extensions

Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE

Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 42 guests