javax.faces.component.html.HtmlInputText Java Examples

The following examples show how to use javax.faces.component.html.HtmlInputText. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CaptchaValidator.java    From development with Apache License 2.0 6 votes vote down vote up
/**
 * Validates if the user input and captchaInputField contain the same value
 * 
 * @param context
 *            FacesContext for the request we are processing
 * @param component
 *            UIComponent we are checking for correctness
 * @param value
 *            the value to validate
 * @throws ValidatorException
 *             if validation fails
 */
@Override
public void validate(final FacesContext context,
        final UIComponent captchaInputField, final Object value)
        throws ValidatorException {
    String userInput = (String) value;
    String captchaKey = (String) JSFUtils
            .getSessionAttribute(Constants.CAPTCHA_KEY);
    if (userInput != null && userInput.equals(captchaKey)) {
        JSFUtils.setSessionAttribute(Constants.CAPTCHA_INPUT_STATUS,
                Boolean.TRUE);
    } else {
        HtmlInputText htmlInputText = (HtmlInputText) captchaInputField;
        htmlInputText.setValid(false);
        JSFUtils.setSessionAttribute(Constants.CAPTCHA_INPUT_STATUS,
                Boolean.FALSE);
        htmlInputText.setValue("");
        String text = JSFUtils.getText(BaseBean.ERROR_CAPTCHA,
                (Object[]) null);
        throw new ValidatorException(new FacesMessage(
                FacesMessage.SEVERITY_ERROR, text, null));
    }
}
 
Example #2
Source File: CaptchaValidatorTest.java    From development with Apache License 2.0 6 votes vote down vote up
@Before
public void setup() {
    validator = new CaptchaValidator();
    sessionMock = new HttpSessionStub(Locale.ENGLISH);
    context = new FacesContextStub(Locale.ENGLISH) {
        @Override
        public ExternalContext getExternalContext() {
            ExternalContext exContext = spy(new ExternalContextStub(
                    Locale.ENGLISH));
            doReturn(sessionMock).when(exContext).getSession(false);
            return exContext;
        }
    };

    inputField = new HtmlInputText() {
        @Override
        public String getClientId(FacesContext ctx) {
            return "";
        }
    };
}
 
Example #3
Source File: PackageValidator.java    From microprofile-starter with Apache License 2.0 5 votes vote down vote up
@Override
public void validate(FacesContext facesContext, UIComponent uiComponent, Object value) throws ValidatorException {

    PackageNameValidator validator = retrieveInstance(PackageNameValidator.class);
    if (!validator.isValidPackageName(value.toString())) {
        FacesMessage msg =
                new FacesMessage(((HtmlInputText) uiComponent).getLabel() + " field validation failed.",
                        "Please provide a valid package name");
        msg.setSeverity(FacesMessage.SEVERITY_ERROR);

        throw new ValidatorException(msg);
    }
}
 
Example #4
Source File: DegreeManagementBackingBean.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public HtmlInputText getNameInputComponent() {
    if (this.nameInputComponent == null) {
        this.nameInputComponent = new HtmlInputText();
        ExecutionYear executionYear =
                (getSelectedExecutionYear() != null) ? getSelectedExecutionYear() : ExecutionYear.readCurrentExecutionYear();

        DegreeInfo degreeInfo = getDegreeInfo(executionYear);
        setSelectedExecutionYearId(degreeInfo.getExecutionYear().getExternalId());
        this.nameInputComponent.setValue(degreeInfo.getName().getContent(org.fenixedu.academic.util.LocaleUtils.PT));
    }
    return this.nameInputComponent;
}
 
Example #5
Source File: DegreeManagementBackingBean.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public HtmlInputText getNameEnInputComponent() {
    if (this.nameEnInputComponent == null) {
        this.nameEnInputComponent = new HtmlInputText();
        ExecutionYear executionYear =
            (getSelectedExecutionYear() != null) ? getSelectedExecutionYear() : ExecutionYear.readCurrentExecutionYear();
        final DegreeInfo degreeInfo = getDegreeInfo(executionYear);
        this.nameEnInputComponent.setValue(degreeInfo.getName().getContent(org.fenixedu.academic.util.LocaleUtils.EN));
    }

    return this.nameEnInputComponent;
}
 
Example #6
Source File: DegreeManagementBackingBean.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public HtmlInputText getAssociatedInstitutionsInputComponent() {
    if (this.associatedInstitutionsInputComponent == null) {
        this.associatedInstitutionsInputComponent = new HtmlInputText();
        this.associatedInstitutionsInputComponent.setValue(getAssociatedInstitutions());
    }

    return this.associatedInstitutionsInputComponent;
}
 
Example #7
Source File: DegreeManagementBackingBean.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public HtmlInputText getAssociatedInstitutionsEnInputComponent() {
    if (this.associatedInstitutionsEnInputComponent == null) {
        this.associatedInstitutionsEnInputComponent = new HtmlInputText();
        this.associatedInstitutionsEnInputComponent.setValue(getAssociatedInstitutionsEn());
    }

    return this.associatedInstitutionsEnInputComponent;
}
 
Example #8
Source File: EvaluationManagementBackingBean.java    From fenixedu-academic with GNU Lesser General Public License v3.0 4 votes vote down vote up
public HtmlInputText getSubmitEvaluationDateTextBox() {
    return submitEvaluationDateTextBox;
}
 
Example #9
Source File: EvaluationManagementBackingBean.java    From fenixedu-academic with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void setSubmitEvaluationDateTextBox(HtmlInputText submitEvaluationDateTextBox) {
    this.submitEvaluationDateTextBox = submitEvaluationDateTextBox;
}
 
Example #10
Source File: DegreeManagementBackingBean.java    From fenixedu-academic with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void setNameInputComponent(HtmlInputText nameInputComponent) {
    this.nameInputComponent = nameInputComponent;
}
 
Example #11
Source File: DegreeManagementBackingBean.java    From fenixedu-academic with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void setAssociatedInstitutionsInputComponent(HtmlInputText associatedInstitutionsInputComponent) {
    this.associatedInstitutionsInputComponent = associatedInstitutionsInputComponent;
}
 
Example #12
Source File: DegreeManagementBackingBean.java    From fenixedu-academic with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void setAssociatedInstitutionsEnInputComponent(HtmlInputText associatedInstitutionsEnInputComponent) {
    this.associatedInstitutionsEnInputComponent = associatedInstitutionsEnInputComponent;
}
 
Example #13
Source File: DegreeManagementBackingBean.java    From fenixedu-academic with GNU Lesser General Public License v3.0 votes vote down vote up
public void setNameEnInputComponent(HtmlInputText nameEnInputComponent) { this.nameEnInputComponent = nameEnInputComponent;}