use of javax.faces.component.UIComponent in project oxCore by GluuFederation.
the class UIInputContainer method assignIds.
// assigning ids seems to break form submissions, but I don't know why
public void assignIds(final InputContainerElements elements, final FacesContext context) {
boolean refreshIds = false;
if (getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX)) {
setId(elements.getPropertyName(context));
refreshIds = true;
}
UIComponent label = elements.getLabel();
if (label != null) {
if (label.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX)) {
label.setId(getDefaultLabelId());
} else if (refreshIds) {
label.setId(label.getId());
}
}
for (int i = 0, len = elements.getInputs().size(); i < len; i++) {
UIComponent input = (UIComponent) elements.getInputs().get(i);
if (input.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX)) {
input.setId(getDefaultInputId() + (i == 0 ? "" : (i + 1)));
} else if (refreshIds) {
input.setId(input.getId());
}
}
for (int i = 0, len = elements.getMessages().size(); i < len; i++) {
UIComponent msg = elements.getMessages().get(i);
if (msg.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX)) {
msg.setId(getDefaultMessageId() + (i == 0 ? "" : (i + 1)));
} else if (refreshIds) {
msg.setId(msg.getId());
}
}
}
use of javax.faces.component.UIComponent in project oxCore by GluuFederation.
the class EnumConverter method getAsObjectImpl.
public Object getAsObjectImpl(FacesContext context, UIComponent comp, String value) throws ConverterException {
ValueExpression expr = comp.getValueExpression("value");
Class enumType = expr == null ? null : expr.getType(context.getELContext());
if (enumType != null && enumType.isEnum()) {
return Enum.valueOf(enumType, value);
} else {
for (Object child : comp.getChildren()) {
if (child instanceof UIComponent) {
UIComponent c = (UIComponent) child;
expr = c.getValueExpression("value");
Object val = expr == null ? null : expr.getValue(context.getELContext());
if (val == null) {
throw new ConverterException("Cannot get items");
}
Class t = val.getClass();
if (t.isArray() && t.getComponentType().isEnum()) {
return Enum.valueOf(t.getComponentType(), value);
} else if (val instanceof Collection) {
Object firstItem = ((Collection) val).iterator().next();
if (firstItem instanceof Enum) {
t = ((Enum) firstItem).getDeclaringClass();
} else {
t = firstItem.getClass();
}
return Enum.valueOf(t, value);
}
}
}
}
throw new ConverterException("Unable to find selectItems with enum values.");
}
use of javax.faces.component.UIComponent in project oxTrust by GluuFederation.
the class FacesComponentUtility method resetInputComponents.
private static void resetInputComponents(UIComponent rootUIComponent) {
if ((rootUIComponent == null) || (rootUIComponent.getChildCount() == 0)) {
return;
}
for (UIComponent comp : rootUIComponent.getChildren()) {
if (comp instanceof UIInput) {
UIInput uiInput = (UIInput) comp;
uiInput.setSubmittedValue(null);
uiInput.setValid(true);
uiInput.setLocalValueSet(false);
uiInput.resetValue();
}
resetInputComponents(comp);
}
}
use of javax.faces.component.UIComponent in project oxTrust by GluuFederation.
the class FacesComponentUtility method resetInputComponents.
public static void resetInputComponents(String rootCompId) {
UIComponent rootUIComponent = findComponentById(rootCompId);
resetInputComponents(rootUIComponent);
}
Aggregations