Search in sources :

Example 31 with Widget

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

the class TestNavigatorWidgetConfigAction method testExecuteMoveExpression_1.

public void testExecuteMoveExpression_1() 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)+abs(1).subtree(2)+current");
    params.put("movement", ApsAdminSystemConstants.MOVEMENT_DOWN_CODE);
    params.put("expressionIndex", "1");
    String result = this.executeMoveExpression("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 + abs(1).subtree(2)", props.getProperty("navSpec"));
    List<NavigatorExpression> expressions = action.getExpressions();
    assertEquals(3, 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)

Example 32 with Widget

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

the class TestNavigatorWidgetConfigAction method testExecuteRemoveExpression_2.

public void testExecuteRemoveExpression_2() 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");
    // INDICE SUPERIORE AL SIZE
    params.put("expressionIndex", "3");
    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) + abs(1).subtree(2) + current", props.getProperty("navSpec"));
    List<NavigatorExpression> expressions = action.getExpressions();
    assertEquals(3, expressions.size());
    NavigatorExpression expression2 = expressions.get(2);
    assertEquals(NavigatorExpression.SPEC_CURRENT_PAGE_ID, expression2.getSpecId());
    assertTrue(expression2.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)

Example 33 with Widget

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

the class TestNavigatorWidgetConfigAction method testFailureAddExpression_2.

public void testFailureAddExpression_2() 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)+abs(1).subtree(2)+current");
    params.put("specId", "3");
    params.put("specSuperLevel", "-2");
    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)+abs(1).subtree(2)+current", navAction.getNavSpec());
    assertEquals(3, 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 34 with Widget

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

the class PageModelDOM method buildDefaultWidget.

private void buildDefaultWidget(Frame frame, Element defaultWidgetElement, int pos, IWidgetTypeManager widgetTypeManager) {
    Widget widget = new Widget();
    String widgetCode = defaultWidgetElement.getAttributeValue(ATTRIBUTE_CODE);
    WidgetType type = widgetTypeManager.getWidgetType(widgetCode);
    if (null == type) {
        _logger.error("Unknown code of the default widget - '{}'", widgetCode);
        return;
    }
    widget.setType(type);
    Element propertiesElement = defaultWidgetElement.getChild(TAB_PROPERTIES);
    if (null != propertiesElement) {
        ApsProperties prop = this.buildProperties(propertiesElement);
        widget.setConfig(prop);
    }
    // else {
    // widget.setConfig(new ApsProperties());
    // }
    frame.setDefaultWidget(widget);
}
Also used : Element(org.jdom.Element) Widget(com.agiletec.aps.system.services.page.Widget) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 35 with Widget

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

the class InternalServletTag method buildWidgetOutput.

protected String buildWidgetOutput(IPage page, ResponseWrapper responseWrapper) throws JspException {
    String output = null;
    ServletRequest req = this.pageContext.getRequest();
    RequestContext reqCtx = (RequestContext) req.getAttribute(RequestContext.REQCTX);
    try {
        Widget widget = (Widget) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET);
        this.includeWidget(reqCtx, responseWrapper, widget);
        Cookie[] cookies = responseWrapper.getCookiesToAdd();
        if (null != cookies) {
            for (int i = 0; i < cookies.length; i++) {
                Cookie cookie = cookies[i];
                cookie.setHttpOnly(true);
                reqCtx.getResponse().addCookie(cookie);
            }
        }
        output = responseWrapper.toString();
        responseWrapper.getWriter().close();
    } catch (Throwable t) {
        String msg = "Error building widget output";
        throw new JspException(msg, t);
    }
    return output;
}
Also used : Cookie(javax.servlet.http.Cookie) ServletRequest(javax.servlet.ServletRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) JspException(javax.servlet.jsp.JspException) Widget(com.agiletec.aps.system.services.page.Widget) RequestContext(com.agiletec.aps.system.RequestContext)

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