Package org.displaytag.util

Examples of org.displaytag.util.Href


     * @throws ObjectLookupException for errors in lookin up object properties
     */
    private Href getColumnHref(String columnContent) throws ObjectLookupException
    {
        // copy href
        Href colHref = (Href) this.header.getHref().clone();

        // do we need to add a param?
        if (this.header.getParamName() != null)
        {

            Object paramValue;

            if (this.header.getParamProperty() != null)
            {
                // different property, go get it
                paramValue = LookupUtil.getBeanProperty(this.row.getObject(), this.header.getParamProperty());

            }
            else
            {
                // same property as content
                paramValue = columnContent;
            }

            if (paramValue != null)
            {
                try
                {
                    colHref.addParameter(this.header.getParamName(), URLEncoder.encode(
                            paramValue.toString(),
                            StringUtils.defaultString(this.row.getParentTable().getEncoding(), "UTF8"))); //$NON-NLS-1$
                }
                catch (UnsupportedEncodingException e)
                {
View Full Code Here


        headerCell.setSortName(this.sortName);

        // href and parameter, create link
        if (this.href != null)
        {
            Href colHref;

            // empty base url, use href with parameters from parent table
            if (StringUtils.isEmpty(this.href.getBaseUrl()))
            {
                colHref = (Href) tableTag.getBaseHref().clone();
            }
            else
            {
                colHref = (Href) this.href.clone();
            }

            if (this.paramId != null)
            {
                // parameter value is in a different object than the iterated one
                if (this.paramName != null || this.paramScope != null)
                {
                    // create a complete string for compatibility with previous version before expression evaluation.
                    // this approach is optimized for new expressions, not for previous property/scope parameters
                    StringBuffer expression = new StringBuffer();

                    // append scope
                    if (StringUtils.isNotBlank(this.paramScope))
                    {
                        expression.append(this.paramScope).append("Scope.");
                    }

                    // base bean name
                    if (this.paramId != null)
                    {
                        expression.append(this.paramName);
                    }
                    else
                    {
                        expression.append(tableTag.getName());
                    }

                    // append property
                    if (StringUtils.isNotBlank(this.paramProperty))
                    {
                        expression.append('.').append(this.paramProperty);
                    }

                    // evaluate expression.
                    // note the value is fixed, not based on any object created during iteration
                    // this is here for compatibility with the old version mainly
                    Object paramValue = tableTag.evaluateExpression(expression.toString());

                    // add parameter
                    colHref.addParameter(this.paramId, paramValue);
                }
                else
                {
                    // set id
                    headerCell.setParamName(this.paramId);
View Full Code Here

     * @param requestHelper request helper used to extract the base Href
     */
    protected void initHref(RequestHelper requestHelper)
    {
        // get the href for this request
        Href normalHref = requestHelper.getHref();

        if (this.requestUri != null)
        {
            // if user has added a requestURI create a new href

            // call encodeURL to preserve session id when cookies are disabled
            String encodedURI = ((HttpServletResponse) this.pageContext.getResponse()).encodeURL(this.requestUri);
            this.baseHref = new Href(encodedURI);

            // ... and copy parameters from the current request
            Map parameterMap = normalHref.getParameterMap();
            this.baseHref.addParameterMap(parameterMap);
        }
        else
        {
            // simply copy href
View Full Code Here

     * @return Href for sorting
     */
    private Href getSortingHref(HeaderCell headerCell)
    {
        // costruct Href from base href, preserving parameters
        Href href = new Href(this.baseHref);

        // add column number as link parameter
        href.addParameter(encodeParameter(TableTagParameters.PARAMETER_SORT), headerCell.getColumnNumber());

        boolean nowOrderAscending = !(headerCell.isAlreadySorted() && this.tableModel.isSortOrderAscending());
        //@todo optimize this using SortOrderEnum
        if (nowOrderAscending)
        {
            href.addParameter(encodeParameter(TableTagParameters.PARAMETER_ORDER), SortOrderEnum.ASCENDING.getCode());
        }
        else
        {
            href.addParameter(encodeParameter(TableTagParameters.PARAMETER_ORDER), SortOrderEnum.DESCENDING.getCode());
        }

        // only if user want to sort the full table. Check if I need to reset the page number
        if (this.tableModel.isSortFullTable())
        {
            // if sorting (column or order) is changed reset page
            if (headerCell.getColumnNumber() != this.previousSortedColumn || ((nowOrderAscending ^ this.previousOrder)))
            {
                href.addParameter(encodeParameter(TableTagParameters.PARAMETER_PAGE), 1);
            }
        }

        return href;
    }
View Full Code Here

        }

        if (this.pagesize != 0 && this.listHelper != null)
        {
            // create a new href
            Href navigationHref = new Href(this.baseHref);

            StringBuffer buffer = new StringBuffer().append(this.listHelper.getSearchResultsSummary()).append(
                this.listHelper
                    .getPageNavigationBar(navigationHref, encodeParameter(TableTagParameters.PARAMETER_PAGE)));
View Full Code Here

    private String getExportLinks()
    {

        // Figure out what formats they want to export, make up a little string

        Href exportHref = new Href(this.baseHref);

        StringBuffer buffer = new StringBuffer();

        Iterator iterator = MediaTypeEnum.iterator();

        while (iterator.hasNext())
        {
            MediaTypeEnum currentExportType = (MediaTypeEnum) iterator.next();

            if (this.properties.getAddExport(currentExportType))
            {

                if (buffer.length() > 0)
                {
                    buffer.append(this.properties.getExportBannerSeparator());
                }

                exportHref.addParameter(encodeParameter(TableTagParameters.PARAMETER_EXPORTTYPE), currentExportType
                    .getCode());

                Anchor anchor = new Anchor(exportHref, this.properties.getExportLabel(currentExportType));
                buffer.append(anchor.toString());
            }
View Full Code Here

   
    public int doStartTag() throws JspException {
        RequestHelper helper = new DefaultRequestHelper((HttpServletRequest) pageContext.getRequest(),
                                                        (HttpServletResponse) pageContext.getResponse());
        Href basehref = helper.getHref();
        Href href = new Href("");
        href.setParameterMap(basehref.getParameterMap());
        href.addParameter(PrintLinkTag.PRINT_PARAMETER_NAME,"");
        setHref(href.toString());
        return super.doStartTag();
    }
View Full Code Here

    public void setHref(String value)
    {
        // call encodeURL to preserve session id when cookies are disabled
        String encodedHref = ((HttpServletResponse) this.pageContext.getResponse()).encodeURL(StringUtils
            .defaultString(value));
        this.href = new Href(encodedHref);
    }
View Full Code Here

        headerCell.setGroup(this.group);

        // href and parameter, create link
        if (this.href != null && this.paramId != null)
        {
            Href colHref = new Href(this.href);

            // parameter value is in a different object than the iterated one
            if (this.paramName != null || this.paramScope != null)
            {
                // create a complete string for compatibility with previous version before expression evaluation.
                // this approach is optimized for new expressions, not for previous property/scope parameters
                StringBuffer expression = new StringBuffer();

                // append scope
                if (StringUtils.isNotBlank(this.paramScope))
                {
                    expression.append(this.paramScope).append("Scope.");
                }

                // base bean name
                if (this.paramId != null)
                {
                    expression.append(this.paramName);
                }
                else
                {
                    expression.append(tableTag.getName());
                }

                // append property
                if (StringUtils.isNotBlank(this.paramProperty))
                {
                    expression.append('.').append(this.paramProperty);
                }

                // evaluate expression.
                // note the value is fixed, not based on any object created during iteration
                // this is here for compatibility with the old version mainly
                Object paramValue = tableTag.evaluateExpression(expression.toString());

                // add parameter
                colHref.addParameter(this.paramId, paramValue);
            }
            else
            {
                //@todo lookup value as a property on the list object. This should not be done here to avoid useless
                // work when only a part of the list is displayed
View Full Code Here

     * @return Href for sorting
     */
    private Href getSortingHref(HeaderCell headerCell)
    {
        // costruct Href from base href, preserving parameters
        Href href = (Href) this.baseHref.clone();

        if (this.paginatedList == null)
        {
            // add column number as link parameter
            if (!this.tableModel.isLocalSort() && (headerCell.getSortName() != null))
            {
                href.addParameter(encodeParameter(TableTagParameters.PARAMETER_SORT), headerCell.getSortName());
                href.addParameter(encodeParameter(TableTagParameters.PARAMETER_SORTUSINGNAME), "1");
            }
            else
            {
                href.addParameter(encodeParameter(TableTagParameters.PARAMETER_SORT), headerCell.getColumnNumber());
            }

            boolean nowOrderAscending = true;

            if (headerCell.getDefaultSortOrder() != null)
            {
                boolean sortAscending = SortOrderEnum.ASCENDING.equals(headerCell.getDefaultSortOrder());
                nowOrderAscending = headerCell.isAlreadySorted()
                    ? !this.tableModel.isSortOrderAscending()
                    : sortAscending;
            }
            else
            {
                nowOrderAscending = !(headerCell.isAlreadySorted() && this.tableModel.isSortOrderAscending());
            }

            int sortOrderParam = nowOrderAscending ? SortOrderEnum.ASCENDING.getCode() : SortOrderEnum.DESCENDING
                .getCode();
            href.addParameter(encodeParameter(TableTagParameters.PARAMETER_ORDER), sortOrderParam);

            // If user want to sort the full table I need to reset the page number.
            // or if we aren't sorting locally we need to reset the page as well.
            if (this.tableModel.isSortFullTable() || !this.tableModel.isLocalSort())
            {
                href.addParameter(encodeParameter(TableTagParameters.PARAMETER_PAGE), 1);
            }
        }
        else
        {
            if (properties.getPaginationSkipPageNumberInSort())
            {
                href.removeParameter(properties.getPaginationPageNumberParam());
            }

            String sortProperty = headerCell.getSortProperty();
            if (sortProperty == null)
            {
                sortProperty = headerCell.getBeanPropertyName();
            }

            href.addParameter(properties.getPaginationSortParam(), sortProperty);
            String dirParam;
            if (headerCell.isAlreadySorted())
            {
                dirParam = tableModel.isSortOrderAscending() ? properties.getPaginationDescValue() : properties
                    .getPaginationAscValue();
            }
            else
            {
                dirParam = properties.getPaginationAscValue();
            }
            href.addParameter(properties.getPaginationSortDirectionParam(), dirParam);
            if (paginatedList.getSearchId() != null)
            {
                href.addParameter(properties.getPaginationSearchIdParam(), paginatedList.getSearchId());
            }
        }

        return href;
    }
View Full Code Here

TOP

Related Classes of org.displaytag.util.Href

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.