本文整理匯總了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();
}
示例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);
}
}
}
}
示例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());
}
示例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());
}
示例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);
}
示例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
}
}
示例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;
}
}
}
示例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"));
}
}