Search in sources :

Example 86 with Widget

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

the class TestNavigatorWidgetConfigAction method testFailureAddExpression_3.

public void testFailureAddExpression_3() throws Throwable {
    Map<String, String> params = new HashMap<String, String>();
    params.put("pageCode", "pagina_2");
    params.put("frame", "3");
    params.put("widgetTypeCode", "leftmenu");
    params.put("navSpec", "parent.subtree(2)+current");
    params.put("specId", "4");
    params.put("specAbsLevel", "-1");
    String result = this.executeAddExpression("admin", params);
    assertEquals(Action.INPUT, result);
    ActionSupport action = this.getAction();
    assertEquals(1, action.getActionErrors().size());
    NavigatorWidgetConfigAction navAction = (NavigatorWidgetConfigAction) action;
    Widget widget = navAction.getWidget();
    assertNotNull(widget);
    ApsProperties props = widget.getConfig();
    assertEquals(0, props.size());
    assertEquals("parent.subtree(2)+current", navAction.getNavSpec());
    assertEquals(2, navAction.getExpressions().size());
}
Also used : HashMap(java.util.HashMap) Widget(com.agiletec.aps.system.services.page.Widget) ActionSupport(com.opensymphony.xwork2.ActionSupport) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 87 with Widget

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

the class TestNavigatorWidgetConfigAction method testInitConfigNavigator_1.

public void testInitConfigNavigator_1() throws Throwable {
    String result = this.executeConfigNavigator("admin", "homepage", "1", "leftmenu");
    assertEquals(Action.SUCCESS, result);
    NavigatorWidgetConfigAction action = (NavigatorWidgetConfigAction) this.getAction();
    Widget widget = action.getWidget();
    assertNotNull(widget);
    assertEquals(0, widget.getConfig().size());
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget)

Example 88 with Widget

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

the class TestContentListViewerWidgetAction method testFailureConfigContentType_1.

public void testFailureConfigContentType_1() throws Throwable {
    String result = this.executeConfigContentType("admin", "homepage", "1", "content_viewer_list", "");
    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 89 with Widget

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

the class PageAction method setViewerPageAPI.

public String setViewerPageAPI() {
    IPage page = null;
    try {
        page = this.getPage(this.getPageCode());
        int mainFrame = page.getMetadata().getModel().getMainFrame();
        if (mainFrame > -1) {
            IWidgetTypeManager showletTypeManager = (IWidgetTypeManager) ApsWebApplicationUtils.getBean(SystemConstants.WIDGET_TYPE_MANAGER, this.getRequest());
            Widget viewer = new Widget();
            viewer.setConfig(new ApsProperties());
            WidgetType type = showletTypeManager.getWidgetType(this.getViewerWidgetCode());
            if (null == type) {
                _logger.warn("No widget found for on-the-fly publishing config for page {}", page.getCode());
                return SUCCESS;
            }
            viewer.setType(type);
            Widget[] widgets = page.getWidgets();
            widgets[mainFrame] = viewer;
        }
        this.getPageManager().updatePage(page);
    } catch (Throwable t) {
        _logger.error("Error setting on-the-fly publishing config to page {}", page.getCode(), t);
        return FAILURE;
    }
    return SUCCESS;
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) IWidgetTypeManager(org.entando.entando.aps.system.services.widgettype.IWidgetTypeManager) Widget(com.agiletec.aps.system.services.page.Widget) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 90 with Widget

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

the class PageConfigAction method joinWidgetJson.

public String joinWidgetJson() {
    try {
        String result = this.checkBaseParams();
        if (null != result) {
            return result;
        }
        IPage page = this.getPage(this.getPageCode());
        if (null != page.getWidgets()[this.getFrame()]) {
            this.addActionError(this.getText("error.page.join.frameNotEmpty"));
            return "pageTree";
        }
        if (null != this.getWidgetTypeCode() && this.getWidgetTypeCode().length() == 0) {
            this.addActionError(this.getText("error.page.widgetTypeCodeUnknown"));
            return INPUT;
        }
        _logger.debug("code={}, pageCode={}, frame={}" + this.getWidgetTypeCode(), this.getPageCode(), this.getFrame());
        WidgetType widgetType = this.getShowletType(this.getWidgetTypeCode());
        if (null == widgetType) {
            this.addActionError(this.getText("error.page.widgetTypeCodeUnknown"));
            return INPUT;
        }
        if (null == widgetType.getConfig() && null != widgetType.getAction()) {
            this.setWidgetAction(widgetType.getAction());
            // continue to widget configuration
            return "configureSpecialWidget";
        }
        Widget widget = new Widget();
        widget.setType(widgetType);
        this.getPageManager().joinWidget(this.getPageCode(), widget, this.getFrame());
        this.addActivityStreamInfo(ApsAdminSystemConstants.ADD, true);
    } catch (Exception e) {
        _logger.error("error in joinWidget", e);
        return FAILURE;
    }
    return SUCCESS;
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) Widget(com.agiletec.aps.system.services.page.Widget) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType)

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