Skip to content

Commit

Permalink
zk6 refresh of the passive screen example to SelectorComposer
Browse files Browse the repository at this point in the history
  • Loading branch information
simbo1905 committed Apr 6, 2012
1 parent 5dd592a commit 684e747
Show file tree
Hide file tree
Showing 21 changed files with 40 additions and 1,285 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<groupId>org.zkforge.zktodo2</groupId>
<artifactId>zktodo2</artifactId>
<packaging>war</packaging>
<version>1.6.0</version>
<version>1.7.0</version>
<name>zktodo2</name>
<url>http://java.dzone.com/articles/using-desktop-model-view</url>
<url>http://www.slideshare.net/simbo1905/design-patterns-in-zk-java-mvvm-as-modelviewbinder</url>
<repositories>
<repository>
<id>zk repository</id>
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/org/zkforge/zktodo2/DateFormatConverter.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/*
ZK.forge is distributed under Lesser GPL Version see also http://www.gnu.org/licenses/lgpl.html
*/

package org.zkforge.zktodo2;

import java.util.Date;
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/org/zkforge/zktodo2/Reminder.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/*
ZK.forge is distributed under Lesser GPL Version see also http://www.gnu.org/licenses/lgpl.html
*/

package org.zkforge.zktodo2;

import java.util.Date;
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/org/zkforge/zktodo2/ReminderService.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/*
ZK.forge is distributed under Lesser GPL Version see also http://www.gnu.org/licenses/lgpl.html
*/
public class ReminderService {
protected BasicDao basicDao;

Expand Down
56 changes: 26 additions & 30 deletions src/main/java/org/zkforge/zktodo2/ZkToDoControllerV1.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/*
ZK.forge is distributed under Lesser GPL Version see also http://www.gnu.org/licenses/lgpl.html
*/
package org.zkforge.zktodo2;

import static java.lang.System.out;
Expand All @@ -11,7 +8,11 @@

import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zk.ui.select.SelectorComposer;
import org.zkoss.zk.ui.select.annotation.Listen;
import org.zkoss.zk.ui.select.annotation.VariableResolver;
import org.zkoss.zk.ui.select.annotation.Wire;
import org.zkoss.zk.ui.select.annotation.WireVariable;
import org.zkoss.zul.Datebox;
import org.zkoss.zul.Intbox;
import org.zkoss.zul.ListModelList;
Expand All @@ -23,32 +24,30 @@
import org.zkoss.zul.Window;

/**
* This class demonstrates "Model-View-Presenter" pattern as the Composer is
* This class demonstrates "Passive View" pattern as the Composer is
* doing all the explicit work of updating the UI.
*
* see http://martinfowler.com/eaaDev/uiArchs.html
*
* also known as Supervising Controller and Passive View.
* {@link http://martinfowler.com/eaaDev/PassiveScreen.html}
*/
public class ZkToDoControllerV1 extends GenericForwardComposer<Window> implements
@VariableResolver(org.zkoss.zkplus.spring.DelegatingVariableResolver.class)
public class ZkToDoControllerV1 extends SelectorComposer<Window> implements
ListitemRenderer<Reminder> {

private static final long serialVersionUID = -3486059156312322420L;

public ZkToDoControllerV1() {
}

protected ReminderService reminderService;

public ReminderService getReminderService() {
return reminderService;
}
@WireVariable ReminderService reminderService;

public void setReminderService(ReminderService reminderService) {
this.reminderService = reminderService;
@Wire Textbox name;
@Wire Intbox priority;
@Wire Datebox date;
@Wire Listbox list;

ListModelList<Reminder> listModelList;
Reminder selectedReminder = null;

public ZkToDoControllerV1() {
// no nothing
}

protected Reminder selectedReminder = null;

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
Expand All @@ -71,13 +70,8 @@ public void onEvent(Event e)
}});
}

protected Textbox name;
protected Intbox priority;
protected Datebox date;
protected Listbox list;
protected ListModelList<Reminder> listModelList;

public void onClick$add(Event e) {
@Listen("onClick = #add")
public void add(Event e) {
Date dateValue = date.getValue();
Integer priorityValue = priority.getValue();
String nameValue = name.getValue();
Expand All @@ -94,7 +88,8 @@ public void onEvent(Event e)
}
}

public void onClick$update(Event e) {
@Listen("onClick = #update")
public void update(Event e) {
if( selectedReminder != null ){
selectedReminder.setDate(date.getValue());
selectedReminder.setPriority(priority.getValue());
Expand Down Expand Up @@ -122,7 +117,8 @@ public void onEvent(Event e)
}
}

public void onClick$delete(Event e) {
@Listen("onClick = #delete")
public void delete(Event e) {
if( null != selectedReminder ){
int index = listModelList.indexOf(selectedReminder);
try {
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/org/zkforge/zktodo2/ZkToDoControllerV2.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/*
ZK.forge is distributed under Lesser GPL Version see also http://www.gnu.org/licenses/lgpl.html
*/

package org.zkforge.zktodo2;

import static java.lang.System.out;
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/org/zkforge/zktodo2/ZkToDoModel.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/*
ZK.forge is distributed under Lesser GPL Version see also http://www.gnu.org/licenses/lgpl.html
*/
package org.zkforge.zktodo2;

import java.util.List;
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/org/zkforge/zktodo2/ZkToDoModelImpl.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/*
ZK.forge is distributed under Lesser GPL Version see also http://www.gnu.org/licenses/lgpl.html
*/
package org.zkforge.zktodo2;

import java.util.List;
Expand Down
41 changes: 0 additions & 41 deletions src/main/java/org/zkforge/zktodo2/loadtest/HelloVM.java

This file was deleted.

This file was deleted.

65 changes: 0 additions & 65 deletions src/main/resources/default.application-context.xml

This file was deleted.

6 changes: 0 additions & 6 deletions src/main/webapp/WEB-INF/spring/application-context.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,6 @@
<bean id="reminderService" class="org.zkforge.zktodo2.ReminderService"
p:basicDao-ref="basicDao" />

<!-- Classes used with MVP pattern version (original zkoss.org mvc4 article)
http://www.zkoss.org/smalltalks/mvc4/ -->

<bean id="toDoControllerV1" class="org.zkforge.zktodo2.ZkToDoControllerV1"
p:reminderService-ref="reminderService" scope="prototype" />

<!-- Note that the following bean has desktop scope. -->
<bean id="toDoModel" class="org.zkforge.zktodo2.ZkToDoModelImpl"
p:reminderService-ref="reminderService" scope="desktop" />
Expand Down
12 changes: 2 additions & 10 deletions src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</listener>
<listener>
<!-- The Spring RequestContextLister uses thread bound variables so to
use this Spring freatures requires that we apply <disable-event-thread />
use this Spring features requires that we apply <disable-event-thread />
within zk.xml -->
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
Expand All @@ -25,15 +25,7 @@
</listener>
<servlet>
<servlet-name>zkLoader</servlet-name>

<!--
Do not enabled the following unless you fully understand the documentation and implication at
http://books.zkoss.org/wiki/Small_Talks/2007/July/ZK_Using_Grinder_3.0#IdGenerator
-->
<servlet-class>org.zkforge.zktodo2.loadtest.SimpleLoadTestIdGenerator</servlet-class>

<!-- <servlet-class>org.zkoss.zk.ui.http.DHtmlLayoutServlet</servlet-class>
-->
<servlet-class>org.zkoss.zk.ui.http.DHtmlLayoutServlet</servlet-class>
<init-param>
<param-name>update-uri</param-name>
<param-value>/zkau</param-value>
Expand Down
Loading

0 comments on commit 684e747

Please sign in to comment.