Search in sources :

Example 1 with IPagerVO

use of com.agiletec.aps.tags.util.IPagerVO in project entando-core by entando.

the class AdminPagerTag method doStartTag.

@Override
public int doStartTag() throws JspException {
    Object source = this.findValue(this.getSource());
    ServletRequest request = this.pageContext.getRequest();
    ValueStack stack = this.getStack();
    ComponentPagerVO compPagerVo = new ComponentPagerVO(stack);
    try {
        AdminPagerTagHelper helper = this.getPagerHelper();
        IPagerVO pagerVo = helper.getPagerVO((Collection) source, this.getPagerId(), this.getCount(), this.isAdvanced(), this.getOffset(), request);
        compPagerVo.initPager(pagerVo);
        stack.getContext().put(this.getObjectName(), compPagerVo);
        stack.setValue("#attr['" + this.getObjectName() + "']", compPagerVo, false);
    } catch (Throwable t) {
        _logger.error("Error creating the pager", t);
        // ApsSystemUtils.logThrowable(t, this, "doStartTag");
        throw new JspException("Error creating the pager", t);
    }
    SubsetIteratorFilter subsetIteratorFilter = new SubsetIteratorFilter();
    subsetIteratorFilter.setCount(this.getCount());
    subsetIteratorFilter.setDecider(null);
    subsetIteratorFilter.setSource(source);
    subsetIteratorFilter.setStart(compPagerVo.getBegin());
    subsetIteratorFilter.execute();
    this.setSubsetIteratorFilter(subsetIteratorFilter);
    this.getStack().push(subsetIteratorFilter);
    if (getId() != null) {
        pageContext.setAttribute(getId(), subsetIteratorFilter);
    }
    return EVAL_BODY_INCLUDE;
}
Also used : ServletRequest(javax.servlet.ServletRequest) JspException(javax.servlet.jsp.JspException) ValueStack(com.opensymphony.xwork2.util.ValueStack) ComponentPagerVO(com.agiletec.apsadmin.tags.util.ComponentPagerVO) AdminPagerTagHelper(com.agiletec.apsadmin.tags.util.AdminPagerTagHelper) SubsetIteratorFilter(org.apache.struts2.util.SubsetIteratorFilter) IPagerVO(com.agiletec.aps.tags.util.IPagerVO)

Example 2 with IPagerVO

use of com.agiletec.aps.tags.util.IPagerVO in project entando-core by entando.

the class AdminPagerTagHelper method getPagerVO.

public IPagerVO getPagerVO(Collection collection, String pagerId, int max, boolean isAdvanced, int offset, ServletRequest request) throws ApsSystemException {
    IPagerVO pagerVo = null;
    try {
        int item = this.getItemNumber(pagerId, request);
        pagerVo = this.buildPageVO(collection, item, max, pagerId, isAdvanced, offset);
    } catch (Throwable t) {
        _logger.error("Error while building pagerVo", t);
        throw new ApsSystemException("Error while building pagerVo", t);
    }
    return pagerVo;
}
Also used : IPagerVO(com.agiletec.aps.tags.util.IPagerVO) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

Example 3 with IPagerVO

use of com.agiletec.aps.tags.util.IPagerVO in project entando-core by entando.

the class PagerTag method doStartTag.

@Override
public int doStartTag() throws JspException {
    ServletRequest request = this.pageContext.getRequest();
    try {
        Object object = this.pageContext.getAttribute(this.getListName());
        Collection collection = (null != object && object instanceof SimpleSequence) ? ((SimpleSequence) object).toList() : (Collection) object;
        if (collection == null) {
            _logger.error("There is no list in the request");
        } else {
            PagerTagHelper helper = new PagerTagHelper();
            IPagerVO pagerVo = helper.getPagerVO(collection, this.getPagerId(), this.isPagerIdFromFrame(), this.getMax(), this.isAdvanced(), this.getOffset(), request);
            this.pageContext.setAttribute(this.getObjectName(), pagerVo);
        }
    } catch (Throwable t) {
        _logger.error("Error detected during tag initialization", t);
        // ApsSystemUtils.logThrowable(e, this, "doStartTag");
        throw new JspException("Error detected during tag initialization", t);
    }
    return EVAL_BODY_INCLUDE;
}
Also used : ServletRequest(javax.servlet.ServletRequest) PagerTagHelper(com.agiletec.aps.tags.util.PagerTagHelper) JspException(javax.servlet.jsp.JspException) Collection(java.util.Collection) IPagerVO(com.agiletec.aps.tags.util.IPagerVO) SimpleSequence(freemarker.template.SimpleSequence)

Aggregations

IPagerVO (com.agiletec.aps.tags.util.IPagerVO)3 ServletRequest (javax.servlet.ServletRequest)2 JspException (javax.servlet.jsp.JspException)2 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)1 PagerTagHelper (com.agiletec.aps.tags.util.PagerTagHelper)1 AdminPagerTagHelper (com.agiletec.apsadmin.tags.util.AdminPagerTagHelper)1 ComponentPagerVO (com.agiletec.apsadmin.tags.util.ComponentPagerVO)1 ValueStack (com.opensymphony.xwork2.util.ValueStack)1 SimpleSequence (freemarker.template.SimpleSequence)1 Collection (java.util.Collection)1 SubsetIteratorFilter (org.apache.struts2.util.SubsetIteratorFilter)1