View Source

h1. Wicket Integration

Wicket integration comes in the form of a Panel. Extending {{org.icepush.integration.wicket.core.PushPanel}} automatically creates a group with the same name as the Panel id, allows you to make push call(s) when necessary, and update your model and GUI by implementing the {{pushCallback()}} method.

h2. Enable Wicket Application for Push

# Add icepush.jar and icepush-wicket.jar to your application.
# In the *web.xml* of your application, add the following:
{code:title=web.xml ICEpush Excerpt} <servlet>
<servlet-name>icepush</servlet-name>
<servlet-class>org.icepush.servlet.ICEpushServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>icepush</servlet-name>
<url-pattern>*.icepush</url-pattern>
</servlet-mapping>
{code}
# Nest the following in the head tag of your page:
{code:title=Script added to head tag} <script type="text/javascript" src="code.icepush"></script>
{code}
h2. Implement Push in Wicket Application

# Create a Wicket Panel by extending org.icepush.integration.wicket.core.PushPanel.
# Add push JavaScript to your panel's html file:
{code:title=Adding push javascript to yourpanel.html}<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns:wicket>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>ExamplePushPanel</title>
</head>
<body>
<wicket:panel>
<script wicket:id="pushJavascript" type="text/javascript">
</script>
<!-- INSERT CONTENTS OF YOUR PANEL HERE -->
</wicket:panel>
</body>
</html>
{code}
{note}Do not nest this script in a component that is updated via AJAX. This will result in the script being executed multiple times.{note}
# Add push call(s), as necessary, to your Java class:
{code:title=Example push call in yourpanel.java}
leftForm.add(new AjaxButton("leftButton") {
protected void onSubmit(AjaxRequestTarget target, Form form) {
// PUSH CALL
push();
isPushMine=true;
target.addComponent(this.getParent());
}
});
{code}
# Implement the {{pushCallback(AjaxRequestTarget target)}} method in your panel's Java class to update your model and render the appropriate components on callback.
{code:title=Example pushCallback in yourpanel.java}
protected void pushCallback(AjaxRequestTarget target) {
if(isPushMine){
pushList.add("My Push.");
}else{
pushList.add("Pushed From Another User.");
}
isPushMine=false;
pushListView.modelChanged();
target.addComponent(leftForm);
}
{code}