Example usage for org.apache.wicket.markup.html WebComponent WebComponent

List of usage examples for org.apache.wicket.markup.html WebComponent WebComponent

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html WebComponent WebComponent.

Prototype

public WebComponent(final String id) 

Source Link

Usage

From source file:au.org.theark.core.web.component.panel.table.DataTablePanel.java

License:Open Source License

private void initHeader() {
    // Raw Webcomponent to generate raw HTML with column name as text (DataTables then renders neatly accordingly)
    table.add(new WebComponent("headerList") {
        /**/*  w w w.  j  a va2  s  . co m*/
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
            Response response = getRequestCycle().getResponse();

            for (String col : headerList) {
                //left align the header text
                response.write("<th align='left'>" + col.toUpperCase() + "</th>\n");
            }
        }
    });
}

From source file:com.googlecode.wicketwebbeans.fields.FileUploaderField.java

License:Apache License

/**
 * Hackie method allowing to add a javascript in the page defining the 
 * callback called by the innerIframe /*from ww w  .java 2  s .c  o  m*/
 *
 */
private void addOnUploadedCallback() {
    final OnUploadedBehavior onUploadBehavior = new OnUploadedBehavior();
    add(onUploadBehavior);
    add(new WebComponent("onUploaded") {
        private static final long serialVersionUID = 1L;

        protected void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
            // calling it through setTimeout we ensure that the callback is called
            // in the proper execution context, that is the parent frame
            replaceComponentTagBody(markupStream, openTag,
                    "function onUpload_" + FileUploaderField.this.getMarkupId()
                            + "(clientFileName, newFileUrl) {window.setTimeout(function() { "
                            + onUploadBehavior.getCallback() + " }, 0 )}");
        }
    });
}

From source file:com.googlecode.wicketwebbeans.fields.FileUploaderIFrame.java

License:Apache License

private void addOnUploadedCallback() {
    // Run the callback on the parent
    add(new WebComponent("onUploaded") {
        private static final long serialVersionUID = 1L;

        protected void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
            if (uploaded) {
                if (uploadField.getFileUpload() != null) {
                    replaceComponentTagBody(markupStream, openTag,
                            "window.parent." + getOnUploadedCallback() + "('"
                                    + uploadField.getFileUpload().getClientFileName() + "','" + newFileUrl
                                    + "')");
                }//  w  w w.j a va  2 s.  c  om
                uploaded = false;
            }
        }
    });
}

From source file:com.marc.lastweek.web.components.upload.UploadIFrame.java

License:Open Source License

private void addOnUploadedCallback() {
    //a hacked component to run the callback on the parent 
    add(new WebComponent("onUploaded") {
        /**/*ww w  .  j a va2  s.  com*/
        * 
        */
        private static final long serialVersionUID = 1L;

        @Override
        protected void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
            if (UploadIFrame.this.uploaded) {
                if (UploadIFrame.this.uploadField.getFileUpload() != null) {
                    replaceComponentTagBody(markupStream, openTag,
                            "window.parent." + getOnUploadedCallback() + "('"
                                    + UploadIFrame.this.uploadField.getFileUpload().getClientFileName() + "','"
                                    + UploadIFrame.this.newFileUrl + "')");
                }
                UploadIFrame.this.uploaded = false;
            }
        }
    });
}

From source file:com.marc.lastweek.web.components.upload.UploadPanel.java

License:Open Source License

/**
 * Hackie method allowing to add a javascript in the page defining the
 * callback called by the innerIframe/*from w  w  w. ja  v  a  2 s . co m*/
 *
 */
@SuppressWarnings("synthetic-access")
private void addOnUploadedCallback() {
    final OnUploadedBehavior onUploadBehavior = new OnUploadedBehavior();
    add(onUploadBehavior);
    add(new WebComponent("onUploaded") {
        private static final long serialVersionUID = 6222268354159011845L;

        @Override
        protected void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
            // calling it through setTimeout we ensure that the callback is called 
            // in the proper execution context, that is the parent frame 
            replaceComponentTagBody(markupStream, openTag,
                    "function onUpload_" + UploadPanel.this.getMarkupId()
                            + "(clientFileName, newFileUrl) {window.setTimeout(function() { "
                            + onUploadBehavior.getCallback() + " }, 0 )}");
        }
    });
}

From source file:com.myamamoto.wicket.misc.behavior.AppendErrorClassOnErrorBehaviorTest.java

License:Apache License

@Before
public void setUp() {
    this.tester = new WicketTester();
    this.behavior = new AppendErrorClassOnErrorBehavior();
    this.component = new WebComponent("component");
    this.componentTag = new ComponentTag(new XmlTag());
}

From source file:com.socialsite.ajax.fileupload.UploadIFrame.java

License:Open Source License

private void addOnUploadedCallback() {
    // a hacked component to run the callback on the parent
    add(new WebComponent("onUploaded") {
        /**/*from  w  w w .j  a  v  a 2  s  . co m*/
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        protected void onComponentTagBody(final MarkupStream markupStream, final ComponentTag openTag) {
            if (uploaded) {
                if (uploadField.getFileUpload() != null) {
                    replaceComponentTagBody(markupStream, openTag,
                            "window.parent." + getOnUploadedCallback() + "('"
                                    + uploadField.getFileUpload().getClientFileName() + "','" + newFileUrl
                                    + "')");
                }
                uploaded = false;
            }
        }
    });
}

From source file:com.socialsite.ajax.fileupload.UploadPanel.java

License:Open Source License

/**
 * Hackie method allowing to add a javascript in the page defining the
 * callback called by the innerIframe//ww  w  . java2 s  . com
 * 
 */
private void addOnUploadedCallback() {
    final OnUploadedBehavior onUploadBehavior = new OnUploadedBehavior();
    add(onUploadBehavior);
    add(new WebComponent("onUploaded") {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        protected void onComponentTagBody(final MarkupStream markupStream, final ComponentTag openTag) {
            // calling it through setTimeout we ensure that the callback is
            // called
            // in the proper execution context, that is the parent frame
            replaceComponentTagBody(markupStream, openTag,
                    "function onUpload_" + UploadPanel.this.getMarkupId()
                            + "(clientFileName, newFileUrl) {window.setTimeout(function() { "
                            + onUploadBehavior.getCallback() + " }, 0 )}");
        }
    });
}

From source file:com.userweave.module.methoden.iconunderstandability.page.report.bmi.BMITermReportPanel.java

License:Open Source License

@Override
protected Component createReportContainer(boolean showDetails) {
    if (showDetails) {
        IconTermMatchingConfigurationEntity configuration = getConfiguration();

        TermReport termReport = reportService.getTermReport(configuration,
                getFilterFuctorCallback().getFilterFunctor(), termId);

        if (termReport == null) {
            return new Label("reportPanel", new StringResourceModel("no_report_message", this, null));
        } else {/*from w  w  w .  ja v a 2 s . c  om*/
            return new TermReportPanel("reportPanel", termReport, configuration.getId(), studyLocale);
        }
    } else {
        return new WebComponent("reportPanel");
    }
}

From source file:com.userweave.module.methoden.mockup.page.survey.MockupSurveyUI.java

License:Open Source License

public MockupSurveyUI(String id, MockupConfigurationEntity configuration, int surveyExecutionId,
        OnFinishCallback onFinishCallback, Locale locale) {
    super(id, configuration.getId(), surveyExecutionId, onFinishCallback, locale);

    add(new WebComponent("URL").add(new AttributeModifier("src",
            new Model<String>(LocalizationUtils.getValue(getConfiguration().getLocaleUrl(), getLocale())))));

    /*/*from  w w  w . java2 s .c o  m*/
     * in this case, we have to change visibility of timeVisivle via display:none
     * because for the javascript-function, who implements the countdown, it's mandantory 
     * that the time value is on the site
     */
    WebMarkupContainer timeVisible = new WebMarkupContainer("timeVisible");
    timeVisible.add(new Label("time"));
    if (getConfiguration().getSwitchToNextConfigType() == SwitchToNextConfigType.BUTTON
            || !getConfiguration().isTimeVisible()) {
        timeVisible.add(new AttributeModifier("style", new Model<String>("display:none;")));
    } else if (getConfiguration().getSwitchToNextConfigType() == SwitchToNextConfigType.TIMER) {
        timeVisible.add(new AttributeModifier("style", new Model<String>("margin-right:0px;")));
    }

    add(timeVisible);

    if (getConfiguration().getSwitchToNextConfigType() != SwitchToNextConfigType.BUTTON) {
        add(new AbstractDefaultAjaxBehavior() {
            boolean isEnabled = true;

            @Override
            protected void respond(AjaxRequestTarget target) {
                isEnabled = false;

                target.appendJavaScript("$(document).ready(startTimer());");
            }

            @Override
            public void renderHead(Component component, IHeaderResponse response) {
                super.renderHead(component, response);
                response.renderOnDomReadyJavaScript(getCallbackScript().toString());
            }

            @Override
            public boolean isEnabled(Component component) {
                return isEnabled;
            }
        });
    }

    add(new Label("freetext", new LocalizedPropertyModel(getDefaultModel(), "freetext", getLocale()))
            .setEscapeModelStrings(false));

    WebMarkupContainer layer = new WebMarkupContainer("layer") {
        @Override
        public boolean isVisible() {
            return getConfiguration().isLayerVisible();
        }
    };
    add(layer);
}