Search in sources :

Example 1 with NavigatorTarget

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());
}
Also used : NavigatorTarget(com.agiletec.aps.system.services.page.widget.NavigatorTarget) RequestContext(com.agiletec.aps.system.RequestContext)

Example 2 with NavigatorTarget

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());
}
Also used : NavigatorTarget(com.agiletec.aps.system.services.page.widget.NavigatorTarget) RequestContext(com.agiletec.aps.system.RequestContext)

Example 3 with NavigatorTarget

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;
    }
}
Also used : NavigatorTarget(com.agiletec.aps.system.services.page.widget.NavigatorTarget)

Example 4 with NavigatorTarget

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;
}
Also used : NavigatorTarget(com.agiletec.aps.system.services.page.widget.NavigatorTarget)

Example 5 with NavigatorTarget

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);
    }
}
Also used : ServletRequest(javax.servlet.ServletRequest) JspException(javax.servlet.jsp.JspException) IPage(com.agiletec.aps.system.services.page.IPage) UserDetails(com.agiletec.aps.system.services.user.UserDetails) NavigatorTarget(com.agiletec.aps.system.services.page.widget.NavigatorTarget) Widget(com.agiletec.aps.system.services.page.Widget) INavigatorParser(com.agiletec.aps.system.services.page.widget.INavigatorParser) ApsProperties(com.agiletec.aps.util.ApsProperties)

Aggregations

NavigatorTarget (com.agiletec.aps.system.services.page.widget.NavigatorTarget)8 RequestContext (com.agiletec.aps.system.RequestContext)5 IPage (com.agiletec.aps.system.services.page.IPage)1 Widget (com.agiletec.aps.system.services.page.Widget)1 INavigatorParser (com.agiletec.aps.system.services.page.widget.INavigatorParser)1 UserDetails (com.agiletec.aps.system.services.user.UserDetails)1 ApsProperties (com.agiletec.aps.util.ApsProperties)1 ServletRequest (javax.servlet.ServletRequest)1 JspException (javax.servlet.jsp.JspException)1