use of com.agiletec.aps.system.services.page.widget.NavigatorTarget in project entando-core by entando.
the class TestNavigatorParser method testGetTargets_5.
public void testGetTargets_5() throws Throwable {
RequestContext reqCtx = this.valueRequestContext("pagina_1", "editorCoach");
String spec = "current.subtree(1)+parent.children";
List<NavigatorTarget> targets = this._navigatorParser.parseSpec(spec, reqCtx);
assertEquals(7, targets.size());
NavigatorTarget target0 = targets.get(0);
assertEquals("pagina_1", target0.getPage().getCode());
assertEquals(0, target0.getLevel());
NavigatorTarget target1 = targets.get(1);
assertEquals("pagina_11", target1.getPage().getCode());
assertEquals(1, target1.getLevel());
NavigatorTarget target2 = targets.get(2);
assertEquals("pagina_12", target2.getPage().getCode());
assertEquals(1, target2.getLevel());
NavigatorTarget target3 = targets.get(3);
assertEquals("pagina_1", target3.getPage().getCode());
assertEquals(0, target3.getLevel());
NavigatorTarget target4 = targets.get(4);
assertEquals("pagina_2", target4.getPage().getCode());
assertEquals(0, target4.getLevel());
NavigatorTarget target5 = targets.get(5);
assertEquals("coach_page", target5.getPage().getCode());
assertEquals(0, target5.getLevel());
NavigatorTarget target6 = targets.get(6);
assertEquals("customers_page", target6.getPage().getCode());
assertEquals(0, target6.getLevel());
}
use of com.agiletec.aps.system.services.page.widget.NavigatorTarget in project entando-core by entando.
the class TestNavigatorParser method testGetTargets_1.
public void testGetTargets_1() throws Throwable {
RequestContext reqCtx = this.valueRequestContext("pagina_11", "admin");
String spec = "current.path";
List<NavigatorTarget> targets = this._navigatorParser.parseSpec(spec, reqCtx);
assertEquals(3, targets.size());
NavigatorTarget target0 = targets.get(0);
assertEquals("homepage", target0.getPage().getCode());
NavigatorTarget target1 = targets.get(1);
assertEquals("pagina_1", target1.getPage().getCode());
NavigatorTarget target2 = targets.get(2);
assertEquals("pagina_11", target2.getPage().getCode());
}
use of com.agiletec.aps.system.services.page.widget.NavigatorTarget in project entando-core by entando.
the class NavigatorTag method doAfterBody.
@Override
public int doAfterBody() throws JspException {
this._index++;
if (this._index >= _targets.size()) {
return SKIP_BODY;
} else {
NavigatorTarget currentTarget = this.getCurrentTarget();
this.pageContext.setAttribute(this.getVar(), currentTarget);
return EVAL_BODY_AGAIN;
}
}
use of com.agiletec.aps.system.services.page.widget.NavigatorTarget in project entando-core by entando.
the class NavigatorTag method getCurrentTarget.
private NavigatorTarget getCurrentTarget() {
NavigatorTarget item = this._targets.get(this._index);
item.setRequestContext(this._reqCtx);
return item;
}
use of com.agiletec.aps.system.services.page.widget.NavigatorTarget in project entando-core by entando.
the class NavigatorTag method doStartTag.
@Override
public int doStartTag() throws JspException {
ServletRequest request = this.pageContext.getRequest();
try {
this._reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
INavigatorParser navigatorParser = (INavigatorParser) ApsWebApplicationUtils.getBean(SystemConstants.NAVIGATOR_PARSER, this.pageContext);
IPage currPage = (IPage) this._reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_PAGE);
UserDetails currentUser = (UserDetails) this.pageContext.getSession().getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER);
if (this._spec == null) {
Widget currShowlet = (Widget) _reqCtx.getExtraParam((SystemConstants.EXTRAPAR_CURRENT_WIDGET));
ApsProperties showletConfig = currShowlet.getConfig();
String spec = (null != showletConfig) ? showletConfig.getProperty(CONFIG_PARAM_SPEC) : null;
this._targets = navigatorParser.parseSpec(spec, currPage, currentUser);
} else {
this._targets = navigatorParser.parseSpec(this._spec, currPage, currentUser);
}
if (this._targets == null || this._targets.isEmpty()) {
return SKIP_BODY;
}
this._index = 0;
NavigatorTarget currentTarget = this.getCurrentTarget();
this.pageContext.setAttribute(this.getVar(), currentTarget);
return EVAL_BODY_INCLUDE;
} catch (Throwable t) {
_logger.error("Error during tag initialization", t);
// ApsSystemUtils.logThrowable(t, this, "doStartTag");
throw new JspException("Error during tag initialization ", t);
}
}
Aggregations