Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //I added this into faces-config.xml
- <validator>
- <validator-id>ValidatorController</validator-id>
- <validator-class>com.DX_57.HM_57.FormValidator</validator-class>
- </validator>
- //This is the input field
- <h:panelGroup>
- <h:inputText id="sessionid" value="#{DatabaseController.formMap['sessionid']}" >
- <f:validateLength minimum="0" maximum="15"/>
- <f:validator binding="#{ValidatorController.validateMessage}" >
- <f:attribute name="type" value="sessionid" />
- </f:validator>
- <f:ajax event="blur" render="sessionidvalidate" />
- </h:inputText>
- <h:message id="sessionidMessage" for="sessionid" />
- </h:panelGroup>
- //Validator code
- import javax.enterprise.context.SessionScoped;
- import javax.faces.application.FacesMessage;
- import javax.faces.component.UIComponent;
- import javax.faces.context.FacesContext;
- import javax.faces.validator.Validator;
- import javax.faces.validator.ValidatorException;
- import javax.inject.Named;
- @Named("ValidatorController")
- @SessionScoped
- public class FormValidator {
- public FormValidator() {
- }
- public void validateMessage(FacesContext context, UIComponent component, Object value) throws ValidatorException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement