use of com.revolsys.ui.model.ParameterInfo in project com.revolsys.open by revolsys.
the class PageInfoHttpMessageConverter method writeMethod.
private void writeMethod(final XmlWriter writer, final String url, final PageInfo pageInfo, final String method, final Map<String, Object> values) {
final Collection<ParameterInfo> parameters = pageInfo.getParameters();
final boolean hasParameters = !parameters.isEmpty();
if (hasParameters) {
if (hasParameters) {
writer.startTag(HtmlElem.DIV);
writer.attribute(HtmlAttr.CLASS, "form");
writer.startTag(HtmlElem.FORM);
writer.attribute(HtmlAttr.ACTION, url);
writer.attribute(HtmlAttr.TARGET, "_top");
if (method.equals("post")) {
boolean isFormData = false;
for (final MediaType mediaType : pageInfo.getInputContentTypes()) {
if (MediaType.MULTIPART_FORM_DATA.isCompatibleWith(mediaType)) {
isFormData = true;
}
}
if (isFormData) {
writer.attribute(HtmlAttr.ENCTYPE, MediaType.MULTIPART_FORM_DATA.toString());
}
}
writer.attribute(HtmlAttr.METHOD, method);
writer.startTag(HtmlElem.DIV);
writer.attribute(HtmlAttr.CLASS, "objectView");
writer.startTag(HtmlElem.TABLE);
writer.attribute(HtmlAttr.CLASS, "data");
writer.startTag(HtmlElem.TBODY);
for (final ParameterInfo parameter : parameters) {
final Map<Object, Object> options = parameter.getAllowedValues();
if (options.isEmpty()) {
if (parameter.getType().equals(DataTypes.BASE64_BINARY)) {
writeHtmlFileField(writer, parameter, values);
} else {
writeHtmlField(writer, parameter, values);
}
} else {
writeHtmlSelect(writer, parameter, values, options);
}
}
}
final List<MediaType> mediaTypes = pageInfo.getMediaTypes();
if (!mediaTypes.isEmpty()) {
final ParameterInfo parameter = new ParameterInfo("format", true, DataTypes.STRING, "Select the file format to return the result data in.", mediaTypes);
writeHtmlSelect(writer, parameter, values, mediaTypes);
}
writer.endTag(HtmlElem.TBODY);
writer.endTag(HtmlElem.TABLE);
writer.endTag(HtmlElem.DIV);
writer.startTag(HtmlElem.DIV);
writer.attribute(HtmlAttr.CLASS, "actionMenu");
HtmlUtil.serializeSubmitInput(writer, "Submit", "submit");
writer.endTag(HtmlElem.DIV);
writer.endTag(HtmlElem.FORM);
writer.endTag(HtmlElem.DIV);
}
}
Aggregations