Search in sources :

Example 36 with Widget

use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.

the class PageWithWidgetTag method filterByConfigParamValue.

protected List<IPage> filterByConfigParamValue(List<IPage> pages) {
    List<IPage> filteredPages = new ArrayList<IPage>();
    Iterator<IPage> it = pages.iterator();
    while (it.hasNext()) {
        IPage currentPage = it.next();
        Widget[] widgets = currentPage.getWidgets();
        if (widgets != null) {
            for (Widget currentWidget : widgets) {
                if (null != currentWidget && currentWidget.getType().getCode().equals(this.getWidgetTypeCode())) {
                    ApsProperties config = currentWidget.getConfig();
                    if (null != config) {
                        String value = config.getProperty(this.getFilterParamName());
                        if (StringUtils.isNotBlank(value) && value.equals(this.getFilterParamValue())) {
                            filteredPages.add(currentPage);
                        }
                    }
                }
            }
        }
    }
    return filteredPages;
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) ArrayList(java.util.ArrayList) Widget(com.agiletec.aps.system.services.page.Widget) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 37 with Widget

use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.

the class PageAction method addPublishedContents.

protected void addPublishedContents(Widget[] widgets, Collection<Content> contents) {
    try {
        if (widgets != null) {
            for (Widget widget : widgets) {
                ApsProperties config = (null != widget) ? widget.getConfig() : null;
                if (null == config || config.isEmpty()) {
                    continue;
                }
                String extracted = config.getProperty("contentId");
                this.addContent(contents, extracted);
                String contentsParam = config.getProperty("contents");
                List<Properties> properties = (null != contentsParam) ? RowContentListHelper.fromParameterToContents(contentsParam) : null;
                if (null == properties || properties.isEmpty()) {
                    continue;
                }
                for (int j = 0; j < properties.size(); j++) {
                    Properties widgProp = properties.get(j);
                    String extracted2 = widgProp.getProperty("contentId");
                    this.addContent(contents, extracted2);
                }
            }
        }
    } catch (Throwable t) {
        String msg = "Error extracting published contents on page";
        _logger.error("Error extracting published contents on page", t);
        throw new RuntimeException(msg, t);
    }
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget) ApsProperties(com.agiletec.aps.util.ApsProperties) Properties(java.util.Properties) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 38 with Widget

use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.

the class ContentListViewerWidgetAction method changeContentType.

public String changeContentType() {
    try {
        Widget widget = super.createNewShowlet();
        this.setWidget(widget);
    } catch (Throwable t) {
        _logger.error("error in changeContentType", t);
        return FAILURE;
    }
    return SUCCESS;
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget)

Example 39 with Widget

use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.

the class ContentListViewerWidgetAction method configContentType.

public String configContentType() {
    try {
        Widget widget = super.createNewShowlet();
        widget.getConfig().setProperty(IContentListWidgetHelper.WIDGET_PARAM_CONTENT_TYPE, this.getContentType());
        this.setWidget(widget);
    } catch (Throwable t) {
        _logger.error("error in configContentType", t);
        return FAILURE;
    }
    return SUCCESS;
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget)

Example 40 with Widget

use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.

the class PageAction method setDefaultWidgets.

public String setDefaultWidgets() {
    Page page = null;
    try {
        page = (Page) this.getPage(this.getPageCode());
        PageModel model = page.getMetadata().getModel();
        Widget[] defaultWidgets = model.getDefaultWidget();
        if (null == defaultWidgets) {
            _logger.info("No default Widget found for pagemodel '{}' of page '{}'", model.getCode(), page.getCode());
            return SUCCESS;
        }
        Widget[] widgets = new Widget[defaultWidgets.length];
        for (int i = 0; i < defaultWidgets.length; i++) {
            Widget defaultWidget = defaultWidgets[i];
            if (null != defaultWidget) {
                if (null == defaultWidget.getType()) {
                    _logger.info("Widget Type null when adding defaulWidget (of pagemodel '{}') on frame '{}' of page '{}'", model.getCode(), i, page.getCode());
                    continue;
                }
                widgets[i] = defaultWidget;
            }
        }
        page.setWidgets(widgets);
        this.getPageManager().updatePage(page);
    } catch (Throwable t) {
        _logger.error("Error setting default widget to page {}", page.getCode(), t);
        return FAILURE;
    }
    return SUCCESS;
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget) Page(com.agiletec.aps.system.services.page.Page) IPage(com.agiletec.aps.system.services.page.IPage) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel)

Aggregations

Widget (com.agiletec.aps.system.services.page.Widget)117 ApsProperties (com.agiletec.aps.util.ApsProperties)60 IPage (com.agiletec.aps.system.services.page.IPage)41 WidgetType (org.entando.entando.aps.system.services.widgettype.WidgetType)20 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)17 HashMap (java.util.HashMap)12 Lang (com.agiletec.aps.system.services.lang.Lang)10 Page (com.agiletec.aps.system.services.page.Page)7 PageModel (com.agiletec.aps.system.services.pagemodel.PageModel)7 ArrayList (java.util.ArrayList)7 PageMetadata (com.agiletec.aps.system.services.page.PageMetadata)6 NavigatorExpression (com.agiletec.aps.system.services.page.widget.NavigatorExpression)6 Properties (java.util.Properties)6 RequestContext (com.agiletec.aps.system.RequestContext)5 ActionSupport (com.opensymphony.xwork2.ActionSupport)4 JspException (javax.servlet.jsp.JspException)4 WidgetTypeParameter (org.entando.entando.aps.system.services.widgettype.WidgetTypeParameter)4 List (java.util.List)3 ServletRequest (javax.servlet.ServletRequest)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3