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);
}
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);
}
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());
}
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);
}
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;
}
Aggregations