use of jakarta.faces.component.html.HtmlInputFile in project mojarra by eclipse-ee4j.
the class TextRenderer method getEndTextToRender.
// ------------------------------------------------------- Protected Methods
@Override
protected void getEndTextToRender(FacesContext context, UIComponent component, String currentValue) throws IOException {
ResponseWriter writer = context.getResponseWriter();
assert writer != null;
boolean shouldWriteIdAttribute = false;
boolean isOutput = false;
String style = (String) component.getAttributes().get("style");
String styleClass = (String) component.getAttributes().get("styleClass");
String dir = (String) component.getAttributes().get("dir");
String lang = (String) component.getAttributes().get("lang");
String title = (String) component.getAttributes().get("title");
Map<String, Object> passthroughAttributes = component.getPassThroughAttributes(false);
boolean hasPassthroughAttributes = null != passthroughAttributes && !passthroughAttributes.isEmpty();
if (component instanceof UIInput) {
writer.startElement("input", component);
writeIdAttributeIfNecessary(context, writer, component);
if (component instanceof HtmlInputFile) {
writer.writeAttribute("type", "file", null);
String accept = ((HtmlInputFile) component).getAccept();
if (accept != null) {
writer.writeAttribute("accept", accept, "accept");
}
} else if (component instanceof HtmlInputText) {
String type = ((HtmlInputText) component).getType();
if (context.isProjectStage(ProjectStage.Development)) {
String recommendedComponent = RECOMMENDED_COMPONENTS_BY_DISCOMMENDED_TYPES.get(type.trim().toLowerCase());
if (recommendedComponent != null) {
String message = "<h:inputText type=\"" + type + "\"> is discommended, you should instead use " + recommendedComponent;
context.addMessage(component.getClientId(context), new FacesMessage(FacesMessage.SEVERITY_WARN, message, message));
}
}
writer.writeAttribute("type", type, null);
} else {
writer.writeAttribute("type", "text", null);
}
writer.writeAttribute("name", component.getClientId(context), "clientId");
// as 'on' by the browser
if ("off".equals(component.getAttributes().get("autocomplete"))) {
writer.writeAttribute("autocomplete", "off", "autocomplete");
}
// render default text specified
if (currentValue != null) {
writer.writeAttribute("value", currentValue, "value");
}
if (null != styleClass) {
writer.writeAttribute("class", styleClass, "styleClass");
}
// style is rendered as a passthru attribute
Attribute[] attributes = component instanceof HtmlInputFile ? INPUTFILE_ATTRIBUTES : INPUTTEXT_ATTRIBUTES;
RenderKitUtils.renderPassThruAttributes(context, writer, component, attributes, getNonOnChangeBehaviors(component));
RenderKitUtils.renderXHTMLStyleBooleanAttributes(writer, component);
RenderKitUtils.renderOnchange(context, component, false);
writer.endElement("input");
} else if (isOutput = component instanceof UIOutput) {
if (styleClass != null || style != null || dir != null || lang != null || title != null || hasPassthroughAttributes || (shouldWriteIdAttribute = shouldWriteIdAttribute(component))) {
writer.startElement("span", component);
writeIdAttributeIfNecessary(context, writer, component);
if (null != styleClass) {
writer.writeAttribute("class", styleClass, "styleClass");
}
// style is rendered as a passthru attribute
RenderKitUtils.renderPassThruAttributes(context, writer, component, OUTPUT_ATTRIBUTES);
}
if (currentValue != null) {
Object val = component.getAttributes().get("escape");
if (val != null && Boolean.valueOf(val.toString())) {
writer.writeText(currentValue, component, "value");
} else {
writer.write(currentValue);
}
}
}
if (isOutput && (styleClass != null || style != null || dir != null || lang != null || title != null || hasPassthroughAttributes || shouldWriteIdAttribute)) {
writer.endElement("span");
}
}
Aggregations