Search in sources :

Example 1 with FormElement

use of com.manydesigns.elements.FormElement in project Portofino by ManyDesigns.

the class BlobUtils method saveBlobs.

public static void saveBlobs(FieldSet fieldSet, BlobManager blobManager) throws IOException {
    for (FormElement field : fieldSet) {
        if (AbstractBlobField.class.isInstance(field)) {
            AbstractBlobField blobField = AbstractBlobField.class.cast(field);
            Blob blob = blobField.getValue();
            if (blob != null && blob.getCode() != null && blob.getInputStream() != null) {
                blobManager.save(blob);
            }
        }
    }
}
Also used : AbstractBlobField(com.manydesigns.elements.fields.AbstractBlobField) FormElement(com.manydesigns.elements.FormElement)

Example 2 with FormElement

use of com.manydesigns.elements.FormElement in project Portofino by ManyDesigns.

the class FieldSet method toXhtml.

public void toXhtml(@NotNull XhtmlBuffer xb) {
    if (mode.isHidden()) {
        for (FormElement current : this) {
            current.toXhtml(xb);
        }
    } else {
        xb.openElement("fieldset");
        xb.addAttribute("class", "mde-columns-" + nColumns);
        if (name != null) {
            xb.writeLegend(name, null);
        }
        int currentColumn = 0;
        for (FormElement current : this) {
            int colSpan = Math.min(current.getColSpan(), nColumns);
            if (current.isForceNewRow() || currentColumn + colSpan > nColumns) {
                if (currentColumn > 0) {
                    closeCurrentRow(xb, currentColumn);
                    currentColumn = 0;
                }
            }
            if (currentColumn == 0) {
                xb.openElement("div");
                xb.addAttribute("class", "row");
            }
            xb.openElement("div");
            xb.addAttribute("class", "col-md-" + (colSpan * (12 / nColumns)) + " mde-colspan-" + colSpan);
            current.toXhtml(xb);
            xb.closeElement("div");
            currentColumn = currentColumn + colSpan;
            if (currentColumn >= nColumns) {
                closeCurrentRow(xb, currentColumn);
                currentColumn = 0;
            }
        }
        if (currentColumn > 0) {
            closeCurrentRow(xb, currentColumn);
        }
        xb.closeElement("fieldset");
    }
}
Also used : FormElement(com.manydesigns.elements.FormElement)

Example 3 with FormElement

use of com.manydesigns.elements.FormElement in project Portofino by ManyDesigns.

the class AbstractCrudAction method disableBlobFields.

protected void disableBlobFields() {
    // Disable blob fields: we don't support them when bulk editing.
    for (FieldSet fieldSet : form) {
        for (FormElement element : fieldSet) {
            if (element instanceof FileBlobField) {
                ((FileBlobField) element).setInsertable(false);
                ((FileBlobField) element).setUpdatable(false);
            }
        }
    }
}
Also used : FormElement(com.manydesigns.elements.FormElement)

Aggregations

FormElement (com.manydesigns.elements.FormElement)3 AbstractBlobField (com.manydesigns.elements.fields.AbstractBlobField)1