Click
Click Examples

Source Viewer : WEB-INF/classes/org/apache/click/examples/page/panel/PanelColumn.java

package org.apache.click.examples.page.panel;

import org.apache.click.Context;
import org.apache.click.control.Column;
import org.apache.click.control.Panel;
import org.apache.click.util.HtmlStringBuffer;

/**
 * Provides a custom Column that wraps a Panel for display in a Table.
 */
public class PanelColumn extends Column {

    private static final long serialVersionUID = 1L;

    private final Panel panel;

    // Constructor ------------------------------------------------------------

    public PanelColumn(String name, Panel panel) {
        super(name);
        this.panel = panel;
    }

    // Event Handlers ---------------------------------------------------------

    /**
     * @see Column#renderTableDataContent(Object, HtmlStringBuffer, Context, int)
     */
    @Override
    protected void renderTableDataContent(Object row, HtmlStringBuffer buffer,
        Context context, int rowIndex) {

        // We use the name of the column in the model. So if the name is
        // "customer" we can access $customer.name in the "panel.htm" template
        panel.getModel().remove(name);
        panel.addModel(name, row);
        panel.render(buffer);
    }
}