Example usage for org.apache.wicket.markup.html.basic Label render

List of usage examples for org.apache.wicket.markup.html.basic Label render

Introduction

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

Prototype

public final void render() 

Source Link

Document

Render this component and all its children.

Usage

From source file:jp.javelindev.wicket.ajaxlist.AjaxListPage.java

License:Apache License

public AjaxListPage(PageParameters parameters) {
    super(parameters);

    final RepeatingView view = new RepeatingView("item");
    add(view);/* w w w. ja  v a 2  s .c o  m*/

    Label defaultLabel = new Label(view.newChildId(), "test");
    defaultLabel.setOutputMarkupId(true);
    view.add(defaultLabel);

    add(new AjaxLink<Void>("addNew") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            Label newLabel = new Label(view.newChildId(), new SimpleDateFormat("HH:mm:ss").format(new Date()));
            newLabel.setOutputMarkupId(true);
            view.add(newLabel);

            Response bodyResonse = new StringResponse();
            Response originalResponse = getResponse();

            getRequestCycle().setResponse(bodyResonse);
            newLabel.render();
            String componentString = bodyResonse.toString();
            LOGGER.info("label: {}", componentString);
            getRequestCycle().setResponse(originalResponse);

            target.appendJavaScript("$('#viewContainer').append('" + componentString + "')");
        }
    });

    add(new HeaderResponseFilteredResponseContainer("footerJS", "footerJS"));
}