当前位置: 首页>>代码示例>>Java>>正文


Java UIInput类代码示例

本文整理汇总了Java中javax.faces.component.UIInput的典型用法代码示例。如果您正苦于以下问题:Java UIInput类的具体用法?Java UIInput怎么用?Java UIInput使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UIInput类属于javax.faces.component包,在下文中一共展示了UIInput类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: show

import javax.faces.component.UIInput; //导入依赖的package包/类
public void show() {
    FacesContext instance = FacesContext.getCurrentInstance();

    String msg;
    if (StringUtils.isEmpty(template)) {
        msg = text;
        if (severity == null) {  // If we are using text, and the developer didn't specify a severity => Assume ERROR.
            severity = FacesMessage.SEVERITY_ERROR;
        }
    } else {
        msg = messageContext.message().template(template).argument(arguments).toString();

        if (severity == null) {
            severity = determineSeverity(template);
        }
    }
    instance.addMessage(clientId, new FacesMessage(severity, msg, msg));
    if (clientId != null) {
        UIComponent component = instance.getViewRoot().findComponent(clientId);
        if (component instanceof UIInput && FacesMessage.SEVERITY_ERROR.equals(severity)) {
            ((UIInput) component).setValid(false);
        }
    }
    resetData();
}
 
开发者ID:atbashEE,项目名称:atbash-octopus,代码行数:26,代码来源:FacesMessages.java

示例2: resetUIInputChildren

import javax.faces.component.UIInput; //导入依赖的package包/类
/**
 * Reset the values of all UIInput children. This might be necessary after a
 * validation error to successfully process an AJAX request. See [Bug 5449]
 * and http://wiki.apache.org/myfaces/ClearInputComponents
 * 
 * @param uiComponent
 *            the root component to be processed.
 */
public static void resetUIInputChildren(UIComponent uiComponent) {
    if (uiComponent != null) {
        List<UIComponent> children = uiComponent.getChildren();
        for (UIComponent child : children) {
            if (child instanceof UIInput) {
                UIInput uiInput = (UIInput) child;
                uiInput.setSubmittedValue(null);
                uiInput.setValue(null);
                uiInput.setLocalValueSet(false);
            } else {
                resetUIInputChildren(child);
            }
        }
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:24,代码来源:JSFUtils.java

示例3: testValidateSubscriptionId

import javax.faces.component.UIInput; //导入依赖的package包/类
@Test
public void testValidateSubscriptionId() throws Exception {

    // given
    SubscriptionServiceInternal ssi = mock(SubscriptionServiceInternal.class);
    doReturn(true).when(ssi).validateSubscriptionIdForOrganization(
            anyString());
    doReturn(ssi).when(bean).getSubscriptionServiceInternal();

    UIComponent uiInputMock = mock(UIInput.class);
    FacesContext contextMock = mock(FacesContext.class);

    // when
    bean.validateSubscriptionId(contextMock, uiInputMock, "value");

    // then
    verify(ui, times(1)).handleError(anyString(),
            eq(SUBSCRIPTION_NAME_ALREADY_EXISTS), anyObject());
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:20,代码来源:SubscriptionWizardConversationTest.java

示例4: billingTypeChanged

import javax.faces.component.UIInput; //导入依赖的package包/类
@Test
public void billingTypeChanged() {
    // given
    UIInput input = mock(UIInput.class);
    ValueChangeEvent e = new ValueChangeEvent(input, null,
            BillingDataType.RevenueShare);

    // when
    ctrl.billingTypeChanged(e);

    // then
    assertEquals(BillingDataType.RevenueShare,
            model.getSelectedBillingDataType());
    assertNull(model.getFromDate());
    assertNull(model.getToDate());
    assertNull(model.getSelectedSharesResultType());
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:18,代码来源:ExportBillingDataCtrlTest.java

示例5: testVerySimpleFinder

import javax.faces.component.UIInput; //导入依赖的package包/类
public void testVerySimpleFinder()
{
  UIViewRoot root = facesContext.getViewRoot();
  root.setId("root");
  UIInput input1 = new UIInput(); input1.setId("input1");

  // build the Tree...
  root.getChildren().add(input1);

  // Get the ComponentReference util
  ComponentReference<UIInput> uiRef = ComponentReference.newUIComponentReference(input1);

  // find the component...
  UIInput referencedComp = uiRef.getComponent();

  assertEquals(input1, referencedComp);
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:18,代码来源:ComponentReferenceTest.java

示例6: testNoComponentWithoutAnId

import javax.faces.component.UIInput; //导入依赖的package包/类
public void testNoComponentWithoutAnId()
{
  UIViewRoot root = facesContext.getViewRoot();
  root.setId("root");
  UIInput input1 = new UIInput();

  // build the Tree...
  root.getChildren().add(input1);

  ComponentReference ref = ComponentReference.newUIComponentReference(input1);

  // Get the ComponentReference util
  try
  {
    ref.getComponent();
    
    // find the component...
    fail("IllegalStateException expected");
  }
  catch (IllegalStateException e)
  {
    // suppress it - this is as expected
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:25,代码来源:ComponentReferenceTest.java

示例7: validateGroupIdentifier

import javax.faces.component.UIInput; //导入依赖的package包/类
public void validateGroupIdentifier(FacesContext context, UIComponent toValidate, Object rawValue) {
    String value = (String) rawValue;
    UIInput input = (UIInput) toValidate;
    input.setValid(true); // Optimistic approach
    
    if ( context.getExternalContext().getRequestParameterMap().get("DO_GROUP_VALIDATION") != null 
            && !StringUtils.isEmpty(value) ) {
        
        // cheap test - regex
        if (! Pattern.matches("^[a-zA-Z0-9\\_\\-]+$", value) ) {
            input.setValid(false);
            context.addMessage(toValidate.getClientId(),
                new FacesMessage(FacesMessage.SEVERITY_ERROR, "", JH.localize("dataverse.permissions.explicitGroupEditDialog.groupIdentifier.invalid")));
        
        } else if ( explicitGroupSvc.findInOwner(getDvObject().getId(), value) != null ) {
            // Ok, see that the alias is not taken
            input.setValid(false);
            context.addMessage(toValidate.getClientId(),
                new FacesMessage(FacesMessage.SEVERITY_ERROR, "", JH.localize("dataverse.permissions.explicitGroupEditDialog.groupIdentifier.taken")));
        }
    }
}
 
开发者ID:pengchengluo,项目名称:Peking-University-Open-Research-Data-Platform,代码行数:23,代码来源:ManagePermissionsPage.java

示例8: validateUserName

import javax.faces.component.UIInput; //导入依赖的package包/类
public void validateUserName(FacesContext context, UIComponent toValidate, Object value) {
    String userName = (String) value;
    boolean userNameFound = false;
    BuiltinUser user = builtinUserService.findByUserName(userName);
    if (editMode == EditMode.CREATE) {
        if (user != null) {
            userNameFound = true;
        }
    } else {
        if (user != null && !user.getId().equals(builtinUser.getId())) {
            userNameFound = true;
        }
    }
    if (userNameFound) {
        ((UIInput) toValidate).setValid(false);
        FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, JH.localize("user.username.taken"), null);
        context.addMessage(toValidate.getClientId(context), message);
    }
}
 
开发者ID:pengchengluo,项目名称:Peking-University-Open-Research-Data-Platform,代码行数:20,代码来源:BuiltinUserPage.java

示例9: validateUserNameEmail

import javax.faces.component.UIInput; //导入依赖的package包/类
public void validateUserNameEmail(FacesContext context, UIComponent toValidate, Object value) {
    String userName = (String) value;
    boolean userNameFound = false;
    BuiltinUser user = builtinUserService.findByUserName(userName);
    if (user != null) {
        userNameFound = true;
    } else {
        BuiltinUser user2 = builtinUserService.findByEmail(userName);
        if (user2 != null) {
            userNameFound = true;
        }
    }
    if (!userNameFound) {
        ((UIInput) toValidate).setValid(false);
        FacesMessage message = new FacesMessage("Username or Email is incorrect.");
        context.addMessage(toValidate.getClientId(context), message);
    }
}
 
开发者ID:pengchengluo,项目名称:Peking-University-Open-Research-Data-Platform,代码行数:19,代码来源:BuiltinUserPage.java

示例10: validateAlias

import javax.faces.component.UIInput; //导入依赖的package包/类
public void validateAlias(FacesContext context, UIComponent toValidate, Object value) {
    if (!StringUtils.isEmpty((String) value)) {
        String alias = (String) value;

        boolean aliasFound = false;
        Dataverse dv = dataverseService.findByAlias(alias);
        if (editMode == DataversePage.EditMode.CREATE) {
            if (dv != null) {
                aliasFound = true;
            }
        } else {
            if (dv != null && !dv.getId().equals(dataverse.getId())) {
                aliasFound = true;
            }
        }
        if (aliasFound) {
            ((UIInput) toValidate).setValid(false);
            FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "alias", "This Alias is already taken.");
            context.addMessage(toValidate.getClientId(context), message);
        }
    }
}
 
开发者ID:pengchengluo,项目名称:Peking-University-Open-Research-Data-Platform,代码行数:23,代码来源:DataversePage.java

示例11: validate

import javax.faces.component.UIInput; //导入依赖的package包/类
@Override
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
    UIInput taglineInput = (UIInput) component.getAttributes().get("taglineInput");
    UIInput linkUrlInput = (UIInput) component.getAttributes().get("linkUrlInput");

    String taglineStr = (String) taglineInput.getSubmittedValue();
    String urlStr = (String) linkUrlInput.getSubmittedValue();

    FacesMessage msg = null;
    if (taglineStr.isEmpty() && !urlStr.isEmpty()) {
        msg = new FacesMessage("Please enter a tagline for the website to be hyperlinked with.");
        msg.setSeverity(FacesMessage.SEVERITY_ERROR);
        FacesContext.getCurrentInstance().addMessage(taglineInput.getClientId(), msg);
    }

    if (msg != null) {
        throw new ValidatorException(msg);
    }

}
 
开发者ID:pengchengluo,项目名称:Peking-University-Open-Research-Data-Platform,代码行数:21,代码来源:LinkValidator.java

示例12: validate

import javax.faces.component.UIInput; //导入依赖的package包/类
@Override
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
    if (value.equals(Boolean.FALSE)) {
        String requiredMessage = ((UIInput) component).getRequiredMessage();
        if (requiredMessage == null) {
            Object label = component.getAttributes().get("label");
            if (label == null || (label instanceof String && ((String) label).length() == 0)) {
                label = component.getValueExpression("label");
            }
            if (label == null) {
                label = component.getClientId(context);
            }
            requiredMessage = MessageFormat.format(UIInput.REQUIRED_MESSAGE_ID, label);
        }
        throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, requiredMessage, requiredMessage));
    }
}
 
开发者ID:pengchengluo,项目名称:Peking-University-Open-Research-Data-Platform,代码行数:18,代码来源:RequiredCheckboxValidator.java

示例13: validate

import javax.faces.component.UIInput; //导入依赖的package包/类
@Override
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
    UIInput positionUI = (UIInput)component.findComponent("position");
    UIInput userTypeUI = (UIInput)component.findComponent("userType");
    String position = (String)positionUI.getLocalValue();
    UserType userType = (UserType)userTypeUI.getLocalValue();
    String inputValue = (String)value;
    if(position.equals("student") && userType == UserType.ADVANCE){
        if(inputValue == null || inputValue.trim().length()==0){
            FacesMessage message = new FacesMessage(
                    ResourceBundle.getBundle("ValidationMessages",context.getViewRoot().getLocale())
                            .getString("cn.edu.pku.lib.dataverse.validation.AdvanceBuiltinUserSupervisorValidation.message"));
            message.setSeverity(FacesMessage.SEVERITY_ERROR);
            throw new ValidatorException(message);
        }
    }
}
 
开发者ID:pengchengluo,项目名称:Peking-University-Open-Research-Data-Platform,代码行数:18,代码来源:AdvanceBuiltinUserSupervisorValidation.java

示例14: correctPasswordEntered

import javax.faces.component.UIInput; //导入依赖的package包/类
/**
 * Make sure the correct password was entered
 * @param components the component to check
 * @return true is correct, false otherwise
 */
private boolean correctPasswordEntered(UIComponent components) {
    UIInput uiInputVerifyPassword = (UIInput) components.findComponent("verifyPassword");
    String verifyPassword = uiInputVerifyPassword.getLocalValue() == null ? ""
            : uiInputVerifyPassword.getLocalValue().toString();
    if (verifyPassword.isEmpty()) {
        statusMessage = "";
        return false;
    } else {
        if (verifyPassword.equals(password)) {
            return true;
        } else {
            statusMessage = "Invalid password entered!";
            return false;
        }
    }
}
 
开发者ID:McBrosa,项目名称:MapChat,代码行数:22,代码来源:AccountManager.java

示例15: validateMatch

import javax.faces.component.UIInput; //导入依赖的package包/类
/**
 * Make sure the passwords entered by the user match.
 *
 * @param o                 Object containing the password value.
 */
public void validateMatch(FacesContext facesContext, UIComponent uiComponent, Object o) throws ValidatorException {

    ResourceBundle resourceBundle = resourceBundleUtil.getResourceBundle(ResourceBundleUtil.USERS);

    String passwordConfirm = o.toString();
    String oriPassword;

    // Find the actual JSF component for the client ID.
    UIInput textInput = (UIInput) uiComponent.findComponent("passwordInputId");

    if (textInput == null || textInput.getSubmittedValue() == null) {
        oriPassword = this.password;
    }
    else {
        oriPassword = textInput.getSubmittedValue().toString();
    }

    if (!passwordConfirm.equals(oriPassword)) {
        createErrorMessage(resourceBundle.getString("errorPasswordValidationFailed"), resourceBundle.getString("errorPasswordsDontMatch"));
    }
}
 
开发者ID:heather92115,项目名称:photosOpen,代码行数:27,代码来源:PasswordValidator.java


注:本文中的javax.faces.component.UIInput类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。