Search in sources :

Example 1 with ModelScreenWidget

use of org.apache.ofbiz.widget.model.ModelScreenWidget in project ofbiz-framework by apache.

the class MacroScreenRenderer method renderColumnContainer.

@Override
public void renderColumnContainer(Appendable writer, Map<String, Object> context, ColumnContainer columnContainer) throws IOException {
    String id = columnContainer.getId(context);
    String style = columnContainer.getStyle(context);
    StringBuilder sb = new StringBuilder("<@renderColumnContainerBegin");
    sb.append(" id=\"");
    sb.append(id);
    sb.append("\" style=\"");
    sb.append(style);
    sb.append("\" />");
    executeMacro(writer, sb.toString());
    for (Column column : columnContainer.getColumns()) {
        id = column.getId(context);
        style = column.getStyle(context);
        sb = new StringBuilder("<@renderColumnBegin");
        sb.append(" id=\"");
        sb.append(id);
        sb.append("\" style=\"");
        sb.append(style);
        sb.append("\" />");
        executeMacro(writer, sb.toString());
        for (ModelScreenWidget subWidget : column.getSubWidgets()) {
            try {
                subWidget.renderWidgetString(writer, context, this);
            } catch (GeneralException e) {
                throw new IOException(e);
            }
        }
        executeMacro(writer, "<@renderColumnEnd />");
    }
    executeMacro(writer, "<@renderColumnContainerEnd />");
}
Also used : GeneralException(org.apache.ofbiz.base.util.GeneralException) Column(org.apache.ofbiz.widget.model.ModelScreenWidget.Column) ModelScreenWidget(org.apache.ofbiz.widget.model.ModelScreenWidget) IOException(java.io.IOException)

Example 2 with ModelScreenWidget

use of org.apache.ofbiz.widget.model.ModelScreenWidget in project ofbiz-framework by apache.

the class WidgetFactory method loadStandardWidgets.

/**
 * Loads the standard OFBiz screen widgets.
 */
protected static void loadStandardWidgets() {
    for (Class<?> clz : ModelScreenWidget.class.getClasses()) {
        try {
            // Subclass of ModelScreenWidget and non-abstract
            if (ModelScreenWidget.class.isAssignableFrom(clz) && (clz.getModifiers() & Modifier.ABSTRACT) == 0) {
                try {
                    Field field = clz.getField("TAG_NAME");
                    Object fieldObject = field.get(null);
                    if (fieldObject != null) {
                        Class<? extends ModelScreenWidget> widgetClass = UtilGenerics.cast(clz);
                        registerScreenWidget(fieldObject.toString(), widgetClass);
                    }
                } catch (Exception e) {
                    Debug.logError(e, module);
                }
            }
        } catch (Exception e) {
            Debug.logError(e, module);
        }
    }
    try {
        registerScreenWidget("iterate-section", IterateSectionWidget.class);
    } catch (Exception e) {
        Debug.logError(e, module);
    }
}
Also used : Field(java.lang.reflect.Field) ModelScreenWidget(org.apache.ofbiz.widget.model.ModelScreenWidget)

Aggregations

ModelScreenWidget (org.apache.ofbiz.widget.model.ModelScreenWidget)2 IOException (java.io.IOException)1 Field (java.lang.reflect.Field)1 GeneralException (org.apache.ofbiz.base.util.GeneralException)1 Column (org.apache.ofbiz.widget.model.ModelScreenWidget.Column)1