Search in sources :

Example 1 with LocatedWidget

use of fi.otavanopisto.muikku.model.widgets.LocatedWidget in project muikku by otavanopisto.

the class IncludeWidgetsTagHandler method includeWidget.

private void includeWidget(FaceletContext context, UIComponent parent) throws IOException {
    StringBuilder jsfBuilder = new StringBuilder();
    List<LocatedWidget> widgets = getWidgets(context);
    jsfBuilder.append("<ui:composition xmlns:m=\"http://www.ofw.fi/xml/2013/muikku/components-taglib.xsd\" xmlns:ui=\"http://java.sun.com/jsf/facelets\">");
    for (LocatedWidget widget : widgets) {
        appendWidgetJsf(jsfBuilder, widget.getWidget());
    }
    jsfBuilder.append("</ui:composition>");
    VariableMapper orig = context.getVariableMapper();
    context.setVariableMapper(new VariableMapperWrapper(orig));
    try {
        this.nextHandler.apply(context, parent);
        context.includeFacelet(parent, new URL(null, "data://text/plain;base64," + Base64.encodeBase64String(jsfBuilder.toString().getBytes("UTF-8")), new DataStreamHandler()));
    } finally {
        context.setVariableMapper(orig);
    }
}
Also used : LocatedWidget(fi.otavanopisto.muikku.model.widgets.LocatedWidget) VariableMapper(javax.el.VariableMapper) VariableMapperWrapper(com.sun.faces.facelets.el.VariableMapperWrapper) URL(java.net.URL)

Aggregations

VariableMapperWrapper (com.sun.faces.facelets.el.VariableMapperWrapper)1 LocatedWidget (fi.otavanopisto.muikku.model.widgets.LocatedWidget)1 URL (java.net.URL)1 VariableMapper (javax.el.VariableMapper)1