You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@click.apache.org by sa...@apache.org on 2011/01/30 04:40:15 UTC
svn commit: r1065172 - in
/click/trunk/click/examples/src/org/apache/click/examples/page/wizard:
Step1.java Step2.java Step3.java
Author: sabob
Date: Sun Jan 30 03:40:14 2011
New Revision: 1065172
URL: http://svn.apache.org/viewvc?rev=1065172&view=rev
Log:
cleanup
Modified:
click/trunk/click/examples/src/org/apache/click/examples/page/wizard/Step1.java
click/trunk/click/examples/src/org/apache/click/examples/page/wizard/Step2.java
click/trunk/click/examples/src/org/apache/click/examples/page/wizard/Step3.java
Modified: click/trunk/click/examples/src/org/apache/click/examples/page/wizard/Step1.java
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/src/org/apache/click/examples/page/wizard/Step1.java?rev=1065172&r1=1065171&r2=1065172&view=diff
==============================================================================
--- click/trunk/click/examples/src/org/apache/click/examples/page/wizard/Step1.java (original)
+++ click/trunk/click/examples/src/org/apache/click/examples/page/wizard/Step1.java Sun Jan 30 03:40:14 2011
@@ -40,11 +40,16 @@ public class Step1 extends Step {
private static final long serialVersionUID = 1L;
+ // Variables --------------------------------------------------------------
+
/** The client domain object created through the wizard. */
private Client client;
+ /** The client service. */
private ClientService clientService;
+ // Constructors -----------------------------------------------------------
+
/**
* Construct Step1 with the specified name, label, description and page.
*
@@ -56,7 +61,8 @@ public class Step1 extends Step {
public Step1(String name, String label, String description, WizardPage page) {
super(name, label, description, page);
- Select titleSelect = createTitleSelect();
+ Select titleSelect = new Select("title", true);
+ setupTitleSelect(titleSelect);
getForm().add(titleSelect);
getForm().add(new TextField("firstName", true));
@@ -70,6 +76,8 @@ public class Step1 extends Step {
}
}
+ // Public methods ---------------------------------------------------------
+
/**
* The onNext action of Step1 sets the Page to stateful, checks if the form
* is valid, moves to the next step in the process and passes the client to
@@ -106,12 +114,12 @@ public class Step1 extends Step {
return clientService;
}
- private Select createTitleSelect() {
- Select titleSelect = new Select("title", true);
+ // Private methods --------------------------------------------------------
- titleSelect.setDefaultOption(Option.EMPTY_OPTION);
+ private void setupTitleSelect(Select select) {
+ select.setDefaultOption(Option.EMPTY_OPTION);
- titleSelect.setDataProvider(new DataProvider() {
+ select.setDataProvider(new DataProvider() {
public List<Option> getData() {
List<Option> options = new ArrayList<Option>();
@@ -122,6 +130,5 @@ public class Step1 extends Step {
return options;
}
});
- return titleSelect;
}
}
Modified: click/trunk/click/examples/src/org/apache/click/examples/page/wizard/Step2.java
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/src/org/apache/click/examples/page/wizard/Step2.java?rev=1065172&r1=1065171&r2=1065172&view=diff
==============================================================================
--- click/trunk/click/examples/src/org/apache/click/examples/page/wizard/Step2.java (original)
+++ click/trunk/click/examples/src/org/apache/click/examples/page/wizard/Step2.java Sun Jan 30 03:40:14 2011
@@ -18,11 +18,17 @@
*/
package org.apache.click.examples.page.wizard;
+import java.util.ArrayList;
+import java.util.List;
import org.apache.click.control.AbstractContainer;
+import org.apache.click.control.Option;
import org.apache.click.control.PageLink;
+import org.apache.click.control.Select;
import org.apache.click.control.TextField;
+import org.apache.click.dataprovider.DataProvider;
import org.apache.click.examples.domain.Client;
-import org.apache.click.extras.cayenne.QuerySelect;
+import org.apache.click.examples.domain.SystemCode;
+import org.apache.click.examples.service.ClientService;
import org.apache.click.extras.control.IntegerField;
/**
@@ -34,15 +40,22 @@ public class Step2 extends Step {
private static final long serialVersionUID = 1L;
+ // Variables --------------------------------------------------------------
+
/** Reference to the postCode field. */
private IntegerField postCodeField;
/** Reference to the state field. */
- private QuerySelect stateSelect;
+ private Select stateSelect;
/** The client domain object created through the wizard. */
private Client client;
+ /** The client service. */
+ private ClientService clientService;
+
+ // Constructors -----------------------------------------------------------
+
/**
* Construct Step2 with the specified name, label, description and page.
*
@@ -70,9 +83,9 @@ public class Step2 extends Step {
getForm().add(new TextField("address.line2", "Line Two"));
getForm().add(new TextField("address.suburb", "Suburb", true));
- stateSelect = new QuerySelect("address.state", "State", true);
+ stateSelect = new Select("address.state", "State", true);
+ setupStateSelect(stateSelect);
- stateSelect.setQueryValueLabel("states", "value", "label");
getForm().add(stateSelect);
postCodeField = new IntegerField("address.postCode", "Post Code");
postCodeField.setRequired(true);
@@ -86,6 +99,8 @@ public class Step2 extends Step {
}
}
+ // Public methods ---------------------------------------------------------
+
/**
* Step2 links to a lookup table for populating the post code and state values.
*
@@ -143,6 +158,33 @@ public class Step2 extends Step {
return false;
}
+ public ClientService getClientService() {
+ if (clientService == null) {
+ clientService = new ClientService();
+ }
+ return clientService;
+ }
+
+ // Private methods --------------------------------------------------------
+
+ private void setupStateSelect(Select select) {
+ select.setDefaultOption(Option.EMPTY_OPTION);
+
+ select.setDataProvider(new DataProvider() {
+
+ public List<Option> getData() {
+ List<Option> options = new ArrayList<Option>();
+ List<SystemCode> states = getClientService().getStates();
+ for (SystemCode state : states) {
+ options.add(new Option(state.getValue(), state.getLabel()));
+ }
+ return options;
+ }
+ });
+ }
+
+ // Inner classes ----------------------------------------------------------
+
/**
* Represents a Div HTML element.
*/
Modified: click/trunk/click/examples/src/org/apache/click/examples/page/wizard/Step3.java
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/src/org/apache/click/examples/page/wizard/Step3.java?rev=1065172&r1=1065171&r2=1065172&view=diff
==============================================================================
--- click/trunk/click/examples/src/org/apache/click/examples/page/wizard/Step3.java (original)
+++ click/trunk/click/examples/src/org/apache/click/examples/page/wizard/Step3.java Sun Jan 30 03:40:14 2011
@@ -34,9 +34,13 @@ public class Step3 extends Step {
private static final long serialVersionUID = 1L;
+ // Variables --------------------------------------------------------------
+
/** The client domain object created through the wizard. */
private Client client;
+ // Constructors -----------------------------------------------------------
+
/**
* Construct Step3 with the specified name, label, description and page.
*
@@ -50,6 +54,8 @@ public class Step3 extends Step {
client = WizardUils.getClientFromSession();
}
+ // Public methods ---------------------------------------------------------
+
/**
* The onFinish action of Step3 checks if the form is valid, saves the
* client and address in the database, sets up a success message, and