《wicket学习十三》&InterComponetsEventsExample

今天我们来学习wicket的事件,最后做出的页面如下。

我们来看homepage.java

public class HomePage extends WebPage {
    public HomePage() {
        final WebMarkupContainer containerInTheMiddle = new WebMarkupContainer("containerInTheMiddle"){
            @Override
            public void onEvent(IEvent<?> event) {
                //we use session's info method to keep messages sorted by insertion order
                Session.get().info("I'm the container in the middle and I received an event.");
            }
        };

        WebMarkupContainer innerContainer = new WebMarkupContainer("innerContainer"){
            @Override
            public void onEvent(IEvent<?> event) {
                //we use session's info method to keep messages sorted by insertion order
                Session.get().info("I'm the inner component and I received an event.");
            }
        };

        add(containerInTheMiddle);
        containerInTheMiddle.add(innerContainer);
        FeedbackPanel feedbackPanel = new FeedbackPanel("feedbackPanel");
        add(feedbackPanel);

        StatelessLink breadthLink = new StatelessLink<Void>("breadthLink") {

            @Override
            public void onClick() {
                send(containerInTheMiddle, Broadcast.BREADTH, "Broadcat mode: breadth.");
            }
        };
        add(breadthLink);
        StatelessLink depthLink = new StatelessLink<Void>("depthLink") {

            @Override
            public void onClick() {
                send(containerInTheMiddle, Broadcast.DEPTH, "Broadcat mode: depth.");
            }
        };
        add(depthLink);
        StatelessLink bubbleLink = new StatelessLink<Void>("bubbleLink") {

            @Override
            public void onClick() {
                send(containerInTheMiddle, Broadcast.BUBBLE, "Broadcat mode: bubble.");
            }
        };
        add(bubbleLink);
        StatelessLink exactLink = new StatelessLink<Void>("exactLink") {

            @Override
            public void onClick() {
                send(containerInTheMiddle, Broadcast.EXACT, "Broadcat mode: exact.");
            }
        };
        add(exactLink);
    }
}

html页面

<html lang="en" xmlns:wicket="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<p>
    Click on the links below to send an event to the container in the middle
    using one of the supported broadcast methods. <br/>
    A panel at the bottom of the page will display the order in which
    the event has been received by sinks (page, components, session and application).
</p>

<a wicket:id="breadthLink">Breadth mode</a><br/>
<a wicket:id="depthLink">Depth mode</a><br/>
<a wicket:id="bubbleLink">Bubble mode</a><br/>
<a wicket:id="exactLink">Exact mode</a><br/>
<br/>
<br/>

<div style="border: 1px solid;padding: 8px; width:40%" wicket:id="containerInTheMiddle">
    <p style="padding-bottom: 2px">I'm the container in the middle</p>
    <div style="border: 1px solid;padding: 8px" wicket:id="innerContainer">
        I'm the inner component.
    </div>
</div>
<br/>
<br/>

<div wicket:id="feedbackPanel">
</div>
</body>
</html>

weapplication

public class WicketApplication  extends WebApplication {
    @Override
    public Class<? extends Page> getHomePage() {
        return HomePage.class;
    }
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

yGIS

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值