Package org.apache.click

Examples of org.apache.click.Page


     * @throws Exception if an error occurs creating the Page
     */
    protected Page newPageInstance(String path, Class pageClass,
            HttpServletRequest request) throws Exception {

        Page page = null;

        String beanName = toBeanName(pageClass);

        if (getApplicationContext().containsBean(beanName)) {
            page = (Page) getApplicationContext().getBean(beanName);

        } else if (getApplicationContext().containsBean(pageClass.getName())) {
            page = (Page) getApplicationContext().getBean(pageClass.getName());

        } else {
            page = (Page) pageClass.newInstance();

            // Inject any Spring beans into the page instance
            if (!pageSetterBeansMap.isEmpty()) {
                List beanList = (List) pageSetterBeansMap.get(page.getClass());
                if (beanList != null) {
                    for (int i = 0; i < beanList.size(); i++) {
                        BeanNameAndMethod bnam = (BeanNameAndMethod) beanList.get(i);
                        Object bean = getApplicationContext().getBean(bnam.beanName);

View Full Code Here


                    if (parent == null) {
                        return control.getMessages();
                    }

                } else if (parent instanceof Page) {
                    Page page = (Page) parent;
                    return page.getMessages();

                } else if (parent != null) {
                    // Unknown parent class
                    return Collections.EMPTY_MAP;
                }
View Full Code Here

                    if (parent == null) {
                        return message;
                    }

                } else if (parent instanceof Page) {
                    Page page = (Page) parent;
                    if (page.getMessages().containsKey(name)) {
                        message = (String) page.getMessages().get(name);
                    }
                    return message;

                } else if (parent != null) {
                    // Unknown parent class
View Full Code Here

     * processing.
     *
     * @return false to abort any further processing
     */
    public boolean onClick() {
        Page page = ClickUtils.getParentPage(this);
        if (page == null) {
            throw new RuntimeException("parent page not available");
        }
        if (pageClass == null) {
            throw  new RuntimeException("target pageClass is not defined");
        }
        page.setRedirect(pageClass);
        return false;
    }
View Full Code Here

     */
    public void setParent(Object parent) {
        if (parent == null) {
            // If the field parent control is set to null (indicating the field
            // is being removed), also remove the field from its parent page
            Page page = getPage();
            if (page != null) {
                page.getControls().remove(this);
                page.getModel().remove(getName());
            }
        }
        super.setParent(parent);
    }
View Full Code Here

            throw new IllegalStateException("AutoCompleteTextField name"
                + " is not defined. Set the name before calling"
                + " getHeadElements().");
        }

        Page page = getPage();
        if (page == null) {
            throw new IllegalStateException("The AutoCompleteTextField, '"
                + fieldName + "', is not attached to the Page. Add"
                + " AutoCompleteTextField to a parent form or container and"
                + " attach the parent to the Page before calling"
                + " getHeadElements().");
        }

        Context context = getContext();

        if (headElements == null) {
            headElements = super.getHeadElements();

            String versionIndicator = ClickUtils.getResourceVersionIndicator(context);

            headElements.add(new CssImport("/click/extras-control.css",
                versionIndicator));
            headElements.add(new JsImport("/click/control.js", versionIndicator));
            headElements.add(new JsImport("/click/prototype/prototype.js",
                versionIndicator));
            headElements.add(new JsImport("/click/prototype/effects.js",
                versionIndicator));
            headElements.add(new JsImport("/click/prototype/controls.js",
                versionIndicator));
        }

        // Note the addLoadEvent script is recreated and checked if it
        // is contained in the headElement.
        String fieldId = getId();
        JsScript script = new JsScript();
        script.setId(fieldId + "_autocomplete");
        if (!headElements.contains(script)) {
            // Script must be executed as soon as browser dom is ready
            script.setExecuteOnDomReady(true);

            String contextPath = context.getRequest().getContextPath();
            HtmlStringBuffer buffer = new HtmlStringBuffer(150);
            buffer.append("new Ajax.Autocompleter(");
            buffer.append("'").append(fieldId).append("'");
            buffer.append(",'").append(fieldId).append("_auto_complete_div'");
            buffer.append(",'").append(contextPath).append(page.getPath()).append(
                "'");
            buffer.append(",").append(getAutoCompleteOptions()).append(");");
            script.setContent(buffer.toString());
            headElements.add(script);
        }
View Full Code Here

     * @see org.apache.click.Control#onInit()
     */
    public void onInit() {
        super.onInit();

        Page page = getPage();
        if (page == null) {
            // If parent page is not reachable, exit early
            return;
        }

        // See whether control has been registered at Page level.
        Object control = page.getModel().get(getName());

        // If not registered, then register control
        if (control == null) {
            // Ensure current parent control does not change
            Object parent = getParent();
            page.addControl(this);
            setParent(parent);

        } else if (!(control instanceof AutoCompleteTextField)) {
            String message =
                "Non AutoCompleteTextField object '"
View Full Code Here

        Context context = getContext();

        final HttpServletRequest request = context.getRequest();

        final Page page = ClickUtils.getParentPage(this);

        final Map renderModel = new HashMap(page.getModel());

        renderModel.putAll(getModel());

        if (hasAttributes()) {
            renderModel.put("attributes", getAttributes());
        } else {
            renderModel.put("attributes", Collections.EMPTY_MAP);
        }

        renderModel.put("this", this);

        renderModel.put("context", request.getContextPath());

        Format format = page.getFormat();
        if (format != null) {
            renderModel.put("format", format);
        }

        Map templateMessages = new HashMap(getMessages());
        templateMessages.putAll(page.getMessages());
        renderModel.put("messages", templateMessages);

        renderModel.put("request", request);

        renderModel.put("response", context.getResponse());
View Full Code Here

    public void testDuplicateOnSubmitCheck() {
        MockContext context = MockContext.initContext("test-form.htm");
        MockRequest request = (MockRequest) context.getMockRequest();
        request.setParameter("form_name", "form");

        Page page = new Page();

        // Set the page to stateful
        page.setStateful(true);
        Form form = new Form("form");

        // Construct name of submit token
        String submitCheckName = Form.SUBMIT_CHECK + form.getName() + "_" + context.getResourcePath();
View Full Code Here

     */
    public void testOnSubmitCheckMissingParam() {
        MockContext context = (MockContext) MockContext.initContext("test-form.htm");
        MockRequest request = (MockRequest) context.getMockRequest();
        request.getParameterMap().put("form_name", "form");
        Page page = new Page();
        Form form = new Form("form");

        // Construct name of submit token
        String submitTokenName = Form.SUBMIT_CHECK + form.getName() + "_" + context.getResourcePath();

View Full Code Here

TOP

Related Classes of org.apache.click.Page

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.