Search in sources :

Example 21 with Widget

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

the class ContentMapperCacheWrapper method searchPublishedDataObjects.

private void searchPublishedDataObjects(ContentPageMapper contentPageMapper, IPage page, IPageManager pageManager) {
    PageModel pageModel = page.getModel();
    if (pageModel != null) {
        int mainFrame = pageModel.getMainFrame();
        Widget[] widgets = page.getWidgets();
        Widget widget = null;
        if (null != widgets && mainFrame != -1) {
            widget = widgets[mainFrame];
        }
        ApsProperties config = (null != widget) ? widget.getConfig() : null;
        String contentId = (null != config) ? config.getProperty("contentId") : null;
        if (null != contentId) {
            contentPageMapper.add(contentId, page.getCode());
        }
        String[] childCodes = page.getChildrenCodes();
        for (String childCode : childCodes) {
            IPage child = pageManager.getOnlinePage(childCode);
            if (null != child) {
                this.searchPublishedDataObjects(contentPageMapper, child, pageManager);
            }
        }
    }
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) Widget(com.agiletec.aps.system.services.page.Widget) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 22 with Widget

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

the class TestContentListViewerWidgetAction method testInitConfigListViewer_2.

public void testInitConfigListViewer_2() throws Throwable {
    String result = this.executeConfigListViewer("admin", "homepage", "0", null);
    assertEquals(Action.SUCCESS, result);
    ContentListViewerWidgetAction action = (ContentListViewerWidgetAction) this.getAction();
    Widget widget = action.getWidget();
    assertNotNull(widget);
    assertEquals("content_viewer_list", widget.getType().getCode());
    ApsProperties props = widget.getConfig();
    assertEquals(4, props.size());
    assertEquals("NEW", props.getProperty("contentType"));
    assertEquals("5", props.getProperty("maxElemForItem"));
    assertEquals("11", props.getProperty("modelId"));
    assertEquals("(order=DESC;attributeFilter=true;likeOption=false;key=Date)+(order=ASC;attributeFilter=true;likeOption=false;key=Title)", props.getProperty("filters"));
    List<Properties> filtersProperties = action.getFiltersProperties();
    assertEquals(2, filtersProperties.size());
    Properties firstFilter = filtersProperties.get(0);
    assertEquals("DESC", firstFilter.getProperty(EntitySearchFilter.ORDER_PARAM));
    assertEquals("true", firstFilter.getProperty(EntitySearchFilter.FILTER_TYPE_PARAM));
    assertEquals("false", firstFilter.getProperty(EntitySearchFilter.LIKE_OPTION_PARAM));
    assertEquals("Date", firstFilter.getProperty(EntitySearchFilter.KEY_PARAM));
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget) Properties(java.util.Properties) ApsProperties(com.agiletec.aps.util.ApsProperties) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 23 with Widget

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

the class TestContentListViewerWidgetAction method testFailureConfigContentType_2.

public void testFailureConfigContentType_2() throws Throwable {
    // Tipo contenuto inesistente
    String result = this.executeConfigContentType("admin", "homepage", "1", "content_viewer_list", "WRO");
    assertEquals(Action.INPUT, result);
    ContentListViewerWidgetAction action = (ContentListViewerWidgetAction) this.getAction();
    Widget widget = action.getWidget();
    assertNotNull(widget);
    ApsProperties props = widget.getConfig();
    assertEquals(0, props.size());
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 24 with Widget

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

the class TestContentViewerWidgetAction method intSaveViewerConfig.

private void intSaveViewerConfig(String contentId, String pageCode, int frame) throws Throwable {
    IPage page = this._pageManager.getDraftPage(pageCode);
    Widget widget = page.getWidgets()[frame];
    assertNull(widget);
    this.setUserOnSession("admin");
    this.initAction("/do/jacms/Page/SpecialWidget/Viewer", "saveViewerConfig");
    Map<String, String> params = new HashMap<String, String>();
    params.put("pageCode", pageCode);
    params.put("frame", String.valueOf(frame));
    params.put("widgetTypeCode", "content_viewer");
    params.put("contentId", contentId);
    this.addParameters(params);
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) HashMap(java.util.HashMap) Widget(com.agiletec.aps.system.services.page.Widget)

Example 25 with Widget

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

the class TestContentViewerWidgetAction method testSave_1.

public void testSave_1() throws Throwable {
    String pageCode = "pagina_2";
    int frame = 3;
    IPage page = this._pageManager.getDraftPage(pageCode);
    IPage onlinePage = this._pageManager.getOnlinePage(pageCode);
    Widget widget = page.getWidgets()[frame];
    assertNull(widget);
    assertNull(onlinePage.getWidgets()[frame]);
    try {
        this.setUserOnSession("admin");
        this.initAction("/do/jacms/Page/SpecialWidget/Viewer", "saveViewerConfig");
        this.addParameter("pageCode", pageCode);
        this.addParameter("frame", String.valueOf(frame));
        this.addParameter("widgetTypeCode", "content_viewer");
        this.addParameter("contentId", "ART187");
        this.addParameter("modelId", "1");
        String result = this.executeAction();
        assertEquals("configure", result);
        page = this._pageManager.getDraftPage(pageCode);
        onlinePage = this._pageManager.getOnlinePage(pageCode);
        widget = page.getWidgets()[frame];
        assertNotNull(widget);
        assertNull(onlinePage.getWidgets()[frame]);
        assertEquals("content_viewer", widget.getType().getCode());
        assertEquals(2, widget.getConfig().size());
        assertEquals("ART187", widget.getConfig().getProperty("contentId"));
        assertEquals("1", widget.getConfig().getProperty("modelId"));
    } catch (Throwable t) {
        throw t;
    } finally {
        page = this._pageManager.getDraftPage(pageCode);
        page.getWidgets()[frame] = null;
        this._pageManager.updatePage(page);
    }
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) Widget(com.agiletec.aps.system.services.page.Widget)

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