Package org.apache.click.util

Examples of org.apache.click.util.HtmlStringBuffer


     *
     * @param select the parent Select
     * @return rendered HTML Option string
     */
    public String renderHTML(Select select) {
        HtmlStringBuffer buffer = new HtmlStringBuffer(48);
        render(select, buffer);
        return buffer.toString();
    }
View Full Code Here


                controlLink.setParameter(Table.PAGE, String.valueOf(table.getPageNumber() - 1));
                controlLink.setTitle(previousTitle);
                previousLabel = controlLink.toString();
            }

            HtmlStringBuffer pagesBuffer =
                new HtmlStringBuffer(table.getNumberPages() * 70);

            // Create sliding window of paging links
            int lowerBound = Math.max(0, table.getPageNumber() - 5);
            int upperBound = Math.min(lowerBound + 10, table.getNumberPages());
            if (upperBound - lowerBound < 10) {
                lowerBound = Math.max(upperBound - 10, 0);
            }

            for (int i = lowerBound; i < upperBound; i++) {
                String pageNumber = String.valueOf(i + 1);
                if (i == table.getPageNumber()) {
                    pagesBuffer.append("<strong>" + pageNumber + "</strong>");

                } else {
                    controlLink.setLabel(pageNumber);
                    controlLink.setParameter(Table.PAGE, String.valueOf(i));
                    controlLink.setTitle(gotoTitle + " " + pageNumber);
                    controlLink.render(pagesBuffer);
                }

                if (i < upperBound - 1) {
                    pagesBuffer.append(", ");
                }
            }
            String pageLinks = pagesBuffer.toString();

            if (table.getPageNumber() < table.getNumberPages() - 1) {
                controlLink.setLabel(nextLabel);
                controlLink.setParameter(Table.PAGE, String.valueOf(table.getPageNumber() + 1));
                controlLink.setTitle(nextTitle);
View Full Code Here

     * @see Object#toString()
     *
     * @return the HTML representation of this paginator
     */
    public String toString() {
        HtmlStringBuffer buffer = new HtmlStringBuffer();

        render(buffer);

        return buffer.toString();
    }
View Full Code Here

     * @see org.apache.click.Control#getHtmlImports()
     *
     * @return the HTML head import statements for the control
     */
     public String getHtmlImports() {
        HtmlStringBuffer buffer = new HtmlStringBuffer(512);
        buffer.append(super.getHtmlImports());
        buffer.append(ClickUtils.createHtmlImport(TabbedForm.HTML_IMPORTS, getContext()));
        return buffer.toString();
    }
View Full Code Here

     * @param config the filter configuration
     * @throws RuntimeException if an initialization error occurs
     */
    public synchronized void init(FilterConfig config) {

         HtmlStringBuffer buffer = new HtmlStringBuffer();
         buffer.append("DataContextFilter initialized: ");

        filterConfig = config;

        ServletUtil.initializeSharedConfiguration(config.getServletContext());

        dataDomain = Configuration.getSharedConfiguration().getDomain();

        String value = null;

        value = config.getInitParameter("auto-rollback");
        if (StringUtils.isNotBlank(value)) {
            autoRollback = "true".equalsIgnoreCase(value);
        }
        buffer.append(" auto-rollback=" + autoRollback);


        value = config.getInitParameter("session-scope");
        if (StringUtils.isNotBlank(value)) {
            sessionScope = "true".equalsIgnoreCase(value);
        }
        buffer.append(", session-scope=" + sessionScope);

        value = config.getInitParameter("shared-cache");
        if (StringUtils.isNotBlank(value)) {
            sharedCache = "true".equalsIgnoreCase(value);
        }
        buffer.append(", shared-cache=");
        buffer.append((sharedCache != null) ? sharedCache : "default");

        value = config.getInitParameter("oscache-enabled");
        boolean oscacheEnabled = "true".equalsIgnoreCase(value);
        if (oscacheEnabled) {
            dataDomain.setQueryCacheFactory(new OSQueryCacheFactory());
        }
        buffer.append(", oscache-enabled=" + oscacheEnabled);

        String classname = config.getInitParameter("lifecycle-listener");

        if (StringUtils.isNotEmpty(classname)) {
            try {
                @SuppressWarnings("unchecked")
                Class listenerClass = ClickUtils.classForName(classname);

                LifecycleCallbackRegistry registry =
                    dataDomain.getEntityResolver().getCallbackRegistry();

                LifecycleListener lifecycleListener = (LifecycleListener)
                    listenerClass.newInstance();

                if (registry.isEmpty(LifecycleEvent.POST_LOAD)) {
                    registry.addDefaultListener(lifecycleListener);
                    buffer.append(", lifecycle-listener=" + classname);

                } else {
                    String message =
                        "Could not get LifecycleCallbackRegistry from domain: "
                        + dataDomain.getName();
                    throw new RuntimeException(message);
                }

            } catch (Exception e) {
                String message =
                    "Could not configure LifecycleCallbackRegistry: " + classname;
                throw new RuntimeException(message, e);
            }
        }

        // Log init data, note LogService is not yet initialized
        getFilterConfig().getServletContext().log(buffer.toString());
    }
View Full Code Here

        } else {
            dataContext = dataDomain.createDataContext();
        }

        if (logger.isTraceEnabled()) {
            HtmlStringBuffer buffer = new HtmlStringBuffer();
            buffer.append("DataContext created with ");
            if (sessionScope) {
                buffer.append("session scope");
            } else {
                buffer.append("request scope");
            }
            if (sharedCache != null) {
                buffer.append(", and shared cache ");
                buffer.append(sharedCache);
            }
            buffer.append(".");
            logger.trace(buffer);
        }

        return dataContext;
    }
View Full Code Here

     *
     * @return the HTML head import statements for the control stylesheet and
     * JavaScript files
     */
    public String getHtmlImports() {
        HtmlStringBuffer buffer = new HtmlStringBuffer(512);

        buffer.append(ClickUtils.createHtmlImport(HTML_IMPORTS, getContext()));

        if (hasControls()) {
            for (int i = 0, size = getControls().size(); i < size; i++) {
                Control control = (Control) getControls().get(i);
                String htmlImports = control.getHtmlImports();
                if (htmlImports != null) {
                    buffer.append(htmlImports);
                }
            }
        }

        return buffer.toString();
    }
View Full Code Here

    public String startTag() {
        List formFields = ContainerUtils.getInputFields(this);

        int bufferSize = getFormSizeEst(formFields);

        HtmlStringBuffer buffer = new HtmlStringBuffer(bufferSize);

        renderHeader(buffer, formFields);

        return buffer.toString();
    }
View Full Code Here

     * and validation.
     *
     * @return the rendered form end tag
     */
    public String endTag() {
        HtmlStringBuffer buffer = new HtmlStringBuffer();

        List formFields = ContainerUtils.getInputFields(this);

        renderTagEnd(formFields, buffer);

        return buffer.toString();
    }
View Full Code Here

            methodCache = new HashMap();
        }

        Object value = PropertyUtils.getValue(row, idProperty, methodCache);

        HtmlStringBuffer buffer = new HtmlStringBuffer();

        if (buttonsArray.length == 1) {
            ActionButton button = buttonsArray[0];
            initButton(button, context, value);
            renderActionButton(buffer, button, context, row, value);

        } else {

            for (int i = 0; i < buttonsArray.length; i++) {
                ActionButton button = buttonsArray[i];
                initButton(button, context, value);

                if (i > 0) {
                    buffer.append(getLinkSeparator());
                }

                renderActionButton(buffer, button, context, row, value);
            }

        }
        return buffer.toString();
    }
View Full Code Here

TOP

Related Classes of org.apache.click.util.HtmlStringBuffer

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.