Search in sources :

Example 76 with Widget

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

the class TestSimpleWidgetConfigAction method testSave.

public void testSave() throws Throwable {
    String pageCode = "pagina_2";
    int frame = 3;
    IPage page = this._pageManager.getDraftPage(pageCode);
    Widget widget = page.getWidgets()[frame];
    assertNull(widget);
    try {
        this.setUserOnSession("admin");
        this.initAction("/do/Page/SpecialWidget", "saveConfigSimpleParameter");
        this.addParameter("pageCode", pageCode);
        this.addParameter("frame", String.valueOf(frame));
        this.addParameter("widgetTypeCode", "formAction");
        this.addParameter("actionPath", "/WEB-INF/pippo.jsp");
        String result = this.executeAction();
        assertEquals("configure", result);
        page = this._pageManager.getDraftPage(pageCode);
        widget = page.getWidgets()[frame];
        assertNotNull(widget);
        assertEquals("formAction", widget.getType().getCode());
        assertEquals(1, widget.getConfig().size());
        assertEquals("/WEB-INF/pippo.jsp", widget.getConfig().getProperty("actionPath"));
    } 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)

Example 77 with Widget

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

the class TestSimpleWidgetConfigAction method testInitConfigSimpleParameter_2.

public void testInitConfigSimpleParameter_2() throws Throwable {
    String result = this.executeConfigSimpleParameter("admin", "pagina_2", "2", null);
    assertEquals(Action.SUCCESS, result);
    SimpleWidgetConfigAction action = (SimpleWidgetConfigAction) this.getAction();
    Widget widget = action.getWidget();
    assertNotNull(widget);
    ApsProperties props = widget.getConfig();
    assertEquals(1, props.size());
    String value = props.getProperty("actionPath");
    assertEquals("/do/login", value);
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 78 with Widget

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

the class TestNavigatorWidgetConfigAction method testInitConfigNavigator_2.

public void testInitConfigNavigator_2() throws Throwable {
    String result = this.executeConfigNavigator("admin", "pagina_1", "2", null);
    assertEquals(Action.SUCCESS, result);
    NavigatorWidgetConfigAction action = (NavigatorWidgetConfigAction) this.getAction();
    Widget widget = action.getWidget();
    assertNotNull(widget);
    ApsProperties props = widget.getConfig();
    assertEquals(1, props.size());
    assertEquals("abs(1).subtree(2)", props.getProperty("navSpec"));
    List<NavigatorExpression> expressions = action.getExpressions();
    assertEquals(1, expressions.size());
    NavigatorExpression expression = expressions.get(0);
    assertEquals(NavigatorExpression.SPEC_ABS_ID, expression.getSpecId());
    assertEquals(1, expression.getSpecAbsLevel());
    assertEquals(NavigatorExpression.OPERATOR_SUBTREE_ID, expression.getOperatorId());
    assertEquals(2, expression.getOperatorSubtreeLevel());
}
Also used : NavigatorExpression(com.agiletec.aps.system.services.page.widget.NavigatorExpression) Widget(com.agiletec.aps.system.services.page.Widget) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 79 with Widget

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

the class TestNavigatorWidgetConfigAction method testSave.

public void testSave() throws Throwable {
    String pageCode = "pagina_2";
    int frame = 3;
    IPage page = this._pageManager.getDraftPage(pageCode);
    Widget widget = page.getWidgets()[frame];
    assertNull(widget);
    try {
        this.setUserOnSession("admin");
        this.initAction("/do/Page/SpecialWidget/Navigator", "saveNavigatorConfig");
        this.addParameter("pageCode", pageCode);
        this.addParameter("frame", String.valueOf(frame));
        this.addParameter("widgetTypeCode", "leftmenu");
        this.addParameter("navSpec", "parent.subtree(2)");
        String result = this.executeAction();
        assertEquals("configure", result);
        page = this._pageManager.getDraftPage(pageCode);
        widget = page.getWidgets()[frame];
        assertNotNull(widget);
        assertEquals("leftmenu", widget.getType().getCode());
        assertEquals(1, widget.getConfig().size());
        assertEquals("parent.subtree(2)", widget.getConfig().getProperty("navSpec"));
    } 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)

Example 80 with Widget

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

the class TestNavigatorWidgetConfigAction method testExecuteRemoveExpression_1.

public void testExecuteRemoveExpression_1() throws Throwable {
    Map<String, String> params = new HashMap<String, String>();
    params.put("pageCode", "pagina_2");
    params.put("frame", "0");
    params.put("widgetTypeCode", "leftmenu");
    params.put("navSpec", "parent.subtree(2)+abs(1).subtree(2)+current");
    params.put("expressionIndex", "1");
    String result = this.executeRemoveExpression("admin", params);
    assertEquals(Action.SUCCESS, result);
    NavigatorWidgetConfigAction action = (NavigatorWidgetConfigAction) this.getAction();
    Widget widget = action.getWidget();
    assertNotNull(widget);
    ApsProperties props = widget.getConfig();
    assertEquals(1, props.size());
    assertEquals("parent.subtree(2) + current", props.getProperty("navSpec"));
    List<NavigatorExpression> expressions = action.getExpressions();
    assertEquals(2, expressions.size());
    NavigatorExpression expression1 = expressions.get(1);
    assertEquals(NavigatorExpression.SPEC_CURRENT_PAGE_ID, expression1.getSpecId());
    assertTrue(expression1.getOperatorId() < 0);
}
Also used : NavigatorExpression(com.agiletec.aps.system.services.page.widget.NavigatorExpression) HashMap(java.util.HashMap) Widget(com.agiletec.aps.system.services.page.Widget) ApsProperties(com.agiletec.aps.util.ApsProperties)

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