Return-Path: Delivered-To: apmail-incubator-click-commits-archive@locus.apache.org Received: (qmail 30556 invoked from network); 20 Dec 2008 17:44:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 20 Dec 2008 17:44:37 -0000 Received: (qmail 7925 invoked by uid 500); 20 Dec 2008 17:44:37 -0000 Delivered-To: apmail-incubator-click-commits-archive@incubator.apache.org Received: (qmail 7909 invoked by uid 500); 20 Dec 2008 17:44:36 -0000 Mailing-List: contact click-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: click-dev@incubator.apache.org Delivered-To: mailing list click-commits@incubator.apache.org Received: (qmail 7898 invoked by uid 99); 20 Dec 2008 17:44:36 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 20 Dec 2008 09:44:36 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 20 Dec 2008 17:44:33 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 6EAE823889CD; Sat, 20 Dec 2008 09:44:12 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r728320 [2/2] - in /incubator/click/trunk/click/examples/src/net/sf/click/examples: control/ control/cayenne/ page/table/ page/tree/ page/wizard/ Date: Sat, 20 Dec 2008 17:44:11 -0000 To: click-commits@incubator.apache.org From: sabob@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081220174412.6EAE823889CD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: incubator/click/trunk/click/examples/src/net/sf/click/examples/page/wizard/Step2.java URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/src/net/sf/click/examples/page/wizard/Step2.java?rev=728320&r1=728319&r2=728320&view=diff ============================================================================== --- incubator/click/trunk/click/examples/src/net/sf/click/examples/page/wizard/Step2.java (original) +++ incubator/click/trunk/click/examples/src/net/sf/click/examples/page/wizard/Step2.java Sat Dec 20 09:44:11 2008 @@ -1,138 +1,138 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package net.sf.click.examples.page.wizard; - -import net.sf.click.control.AbstractContainer; -import net.sf.click.control.PageLink; -import net.sf.click.control.TextField; -import net.sf.click.examples.control.cayenne.CayenneIntegerField; -import net.sf.click.extras.cayenne.QuerySelect; -import net.sf.click.extras.control.IntegerField; - -/** - * The second step in the 3 step process is to capture the Client address. - *

- * Note this Panel has no associated template. - * - * @author Bob Schellink - */ -public class Step2 extends Step { - - /** Reference to the postCode field. */ - private IntegerField postCodeField; - - /** Reference to the state field. */ - private QuerySelect stateSelect; - - /** - * Construct Step2 with the specified name, label, description and page. - * - * @param name the step name - * @param label the step label - * @param description the step description - * @param page the wizard page - */ - public Step2(String name, String label, String description, WizardPage page) { - super(name, label, description, page); - - // PageLink to page where post codes can be looked up - final PageLink postCodeLookup = new PageLink("postCodePage", "Lookup Post Code", SelectPostCode.class); - - // We want to right align the postCodeLookup link, however fields must - // be left aligned. In order to do this we wrap postCodeLookupPage inside - // a div (block level element) and set its contents to be right aligned. - Div postCodeLookupWrapper = new Div(); - postCodeLookupWrapper.add(postCodeLookup); - postCodeLookupWrapper.setStyle("text-align", "right"); - - getForm().add(postCodeLookupWrapper); - - getForm().add(new TextField("address.line1", "Line One")); - getForm().add(new TextField("address.line2", "Line Two")); - getForm().add(new TextField("address.suburb", "Suburb")); - - stateSelect = new QuerySelect("address.state", "State", true); - - stateSelect.setQueryValueLabel("states", "value", "label"); - getForm().add(stateSelect); - postCodeField = new CayenneIntegerField("address.postCode", "Post Code"); - postCodeField.setMaxLength(5); - postCodeField.setSize(5); - getForm().add(postCodeField); - } - - /** - * Step2 links to a lookup table for populating the post code and state values. - * - * The onInit phase is overridden to check if the post code and state values - * are passed in from the lookup table. - */ - public void onInit() { - // Invoke default onInit implementation - super.onInit(); - - // Check if postCode is passed to this Page from SelectPostCode page - String postCodeValue = getContext().getRequestParameter(postCodeField.getName()); - if (postCodeValue != null) { - postCodeField.setValue(postCodeValue); - } - // Check if state is passed to this Page from SelectPostCode page - String stateValue = getContext().getRequestParameter(stateSelect.getName()); - if (stateValue != null) { - stateSelect.setValue(stateValue); - } - } - - /** - * The onNext action of Step2 checks if the form is valid, moves to the - * next step in the process and passes the client to the next step. - * - * @return true if page processing should continue or not - */ - public boolean onNext() { - if (getForm().isValid()) { - // Pass client to next Step - getWizardPage().next(); - getWizardPage().getCurrentStep().setClient(getClient()); - } - return true; - } - - /** - * The onPrevious action of Step2 moves to the previous step in the process - * and clears and form errors. - * - * @return true if page processing should continue or not - */ - public boolean onPrevious() { - getWizardPage().previous(); - getForm().clearErrors(); - return false; - } - - /** - * Represents a Div HTML element. - */ - class Div extends AbstractContainer { - public String getTag() { - return "div"; - } - } -} - +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package net.sf.click.examples.page.wizard; + +import net.sf.click.control.AbstractContainer; +import net.sf.click.control.PageLink; +import net.sf.click.control.TextField; +import net.sf.click.examples.control.cayenne.CayenneIntegerField; +import net.sf.click.extras.cayenne.QuerySelect; +import net.sf.click.extras.control.IntegerField; + +/** + * The second step in the 3 step process is to capture the Client address. + *

+ * Note this Panel has no associated template. + * + * @author Bob Schellink + */ +public class Step2 extends Step { + + /** Reference to the postCode field. */ + private IntegerField postCodeField; + + /** Reference to the state field. */ + private QuerySelect stateSelect; + + /** + * Construct Step2 with the specified name, label, description and page. + * + * @param name the step name + * @param label the step label + * @param description the step description + * @param page the wizard page + */ + public Step2(String name, String label, String description, WizardPage page) { + super(name, label, description, page); + + // PageLink to page where post codes can be looked up + final PageLink postCodeLookup = new PageLink("postCodePage", "Lookup Post Code", SelectPostCode.class); + + // We want to right align the postCodeLookup link, however fields must + // be left aligned. In order to do this we wrap postCodeLookupPage inside + // a div (block level element) and set its contents to be right aligned. + Div postCodeLookupWrapper = new Div(); + postCodeLookupWrapper.add(postCodeLookup); + postCodeLookupWrapper.setStyle("text-align", "right"); + + getForm().add(postCodeLookupWrapper); + + getForm().add(new TextField("address.line1", "Line One")); + getForm().add(new TextField("address.line2", "Line Two")); + getForm().add(new TextField("address.suburb", "Suburb")); + + stateSelect = new QuerySelect("address.state", "State", true); + + stateSelect.setQueryValueLabel("states", "value", "label"); + getForm().add(stateSelect); + postCodeField = new CayenneIntegerField("address.postCode", "Post Code"); + postCodeField.setMaxLength(5); + postCodeField.setSize(5); + getForm().add(postCodeField); + } + + /** + * Step2 links to a lookup table for populating the post code and state values. + * + * The onInit phase is overridden to check if the post code and state values + * are passed in from the lookup table. + */ + public void onInit() { + // Invoke default onInit implementation + super.onInit(); + + // Check if postCode is passed to this Page from SelectPostCode page + String postCodeValue = getContext().getRequestParameter(postCodeField.getName()); + if (postCodeValue != null) { + postCodeField.setValue(postCodeValue); + } + // Check if state is passed to this Page from SelectPostCode page + String stateValue = getContext().getRequestParameter(stateSelect.getName()); + if (stateValue != null) { + stateSelect.setValue(stateValue); + } + } + + /** + * The onNext action of Step2 checks if the form is valid, moves to the + * next step in the process and passes the client to the next step. + * + * @return true if page processing should continue or not + */ + public boolean onNext() { + if (getForm().isValid()) { + // Pass client to next Step + getWizardPage().next(); + getWizardPage().getCurrentStep().setClient(getClient()); + } + return true; + } + + /** + * The onPrevious action of Step2 moves to the previous step in the process + * and clears and form errors. + * + * @return true if page processing should continue or not + */ + public boolean onPrevious() { + getWizardPage().previous(); + getForm().clearErrors(); + return false; + } + + /** + * Represents a Div HTML element. + */ + class Div extends AbstractContainer { + public String getTag() { + return "div"; + } + } +} + Modified: incubator/click/trunk/click/examples/src/net/sf/click/examples/page/wizard/Step3.java URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/src/net/sf/click/examples/page/wizard/Step3.java?rev=728320&r1=728319&r2=728320&view=diff ============================================================================== --- incubator/click/trunk/click/examples/src/net/sf/click/examples/page/wizard/Step3.java (original) +++ incubator/click/trunk/click/examples/src/net/sf/click/examples/page/wizard/Step3.java Sat Dec 20 09:44:11 2008 @@ -1,98 +1,98 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package net.sf.click.examples.page.wizard; - -/** - * This step asks for confirmation on the client information added through the - * wizard. If user confirms, the new client is inserted into the database, - * if user cancels the wizard is ended and user is redirected back to the first - * step. - *

- * Step3 uses a Velocity template (Step3.htm) to render client - * information. - * - * @author Bob Schellink - */ -public class Step3 extends Step { - - /** - * Construct Step3 with the specified name, label, description and page. - * - * @param name the step name - * @param label the step label - * @param description the step description - * @param page the wizard - */ - public Step3(String name, String label, String description, WizardPage page) { - super(name, label, description, page); - } - - /** - * 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 - * sets the page back to stateless. - * - * @return true if page processing should continue or not - */ - public boolean onFinish() { - if (getForm().isValid()) { - - // Store client and associated address in the database - getForm().saveChanges(); - - // Set a flash success message - getContext().setFlashAttribute("message", "The client " - + getClient().getName() + " was successfully created."); - - // Set page state to stateless which removes the page from - // the session - getWizardPage().setStateful(false); - - // Redirect to wizard page to start another process - getWizardPage().setRedirect(WizardPage.class); - } - return true; - } - - /** - * The onPrevious action of Step3 moves to the previous step in the process - * and clears and form errors. - * - * @return true if page processing should continue or not - */ - public boolean onPrevious() { - getWizardPage().previous(); - getForm().clearValues(); - return false; - } - - /** - * Override onRender phase to add the client instance to the Template - * model for rendering. - */ - public void onRender() { - // Invoke default onInit implementation - super.onRender(); - - // Add client to model for displaying confirmation message - if (!getModel().containsKey("client")) { - addModel("client", getClient()); - } - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package net.sf.click.examples.page.wizard; + +/** + * This step asks for confirmation on the client information added through the + * wizard. If user confirms, the new client is inserted into the database, + * if user cancels the wizard is ended and user is redirected back to the first + * step. + *

+ * Step3 uses a Velocity template (Step3.htm) to render client + * information. + * + * @author Bob Schellink + */ +public class Step3 extends Step { + + /** + * Construct Step3 with the specified name, label, description and page. + * + * @param name the step name + * @param label the step label + * @param description the step description + * @param page the wizard + */ + public Step3(String name, String label, String description, WizardPage page) { + super(name, label, description, page); + } + + /** + * 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 + * sets the page back to stateless. + * + * @return true if page processing should continue or not + */ + public boolean onFinish() { + if (getForm().isValid()) { + + // Store client and associated address in the database + getForm().saveChanges(); + + // Set a flash success message + getContext().setFlashAttribute("message", "The client " + + getClient().getName() + " was successfully created."); + + // Set page state to stateless which removes the page from + // the session + getWizardPage().setStateful(false); + + // Redirect to wizard page to start another process + getWizardPage().setRedirect(WizardPage.class); + } + return true; + } + + /** + * The onPrevious action of Step3 moves to the previous step in the process + * and clears and form errors. + * + * @return true if page processing should continue or not + */ + public boolean onPrevious() { + getWizardPage().previous(); + getForm().clearValues(); + return false; + } + + /** + * Override onRender phase to add the client instance to the Template + * model for rendering. + */ + public void onRender() { + // Invoke default onInit implementation + super.onRender(); + + // Add client to model for displaying confirmation message + if (!getModel().containsKey("client")) { + addModel("client", getClient()); + } + } +} Modified: incubator/click/trunk/click/examples/src/net/sf/click/examples/page/wizard/WizardPage.java URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/src/net/sf/click/examples/page/wizard/WizardPage.java?rev=728320&r1=728319&r2=728320&view=diff ============================================================================== --- incubator/click/trunk/click/examples/src/net/sf/click/examples/page/wizard/WizardPage.java (original) +++ incubator/click/trunk/click/examples/src/net/sf/click/examples/page/wizard/WizardPage.java Sat Dec 20 09:44:11 2008 @@ -1,146 +1,146 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package net.sf.click.examples.page.wizard; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import net.sf.click.examples.page.BorderPage; - -/** - * This Page manages steps in a wizard process. - * - * @author Bob Schellink - */ -public class WizardPage extends BorderPage { - - /** Current step in the process. */ - private Step currentStep; - - /** List of all steps. */ - private List steps = new ArrayList(); - - /** - * Default constructor. - */ - public WizardPage() { - steps.add(new Step1("step", "Client", "Step 1 of 3", this)); - steps.add(new Step2("step", "Address", "Step 2 of 3", this)); - steps.add(new Step3("step", "Confirmation", "Step 3 of 3", this)); - - // Set first step as current - setCurrentStep((Step) steps.get(0)); - - // Initialize all the steps - Iterator it = steps.iterator(); - while(it.hasNext()) { - Step step = (Step) it.next(); - step.init(); - } - } - - /** - * Return the current step. - * - * @return the current step - */ - public Step getCurrentStep() { - return currentStep; - } - - /** - * Sets the current Step to the specified Step. - * - * @param step the new step to set - */ - public void setCurrentStep(Step step) { - if (this.currentStep != null) { - // Remove the current step from the page list of controls - removeControl(this.currentStep); - } - this.currentStep = step; - // Add the new step to the page list of controls - addControl(step); - } - - /** - * Return true if there is another step before the specified step. - * - * @param step the step to check against - * @return true if there is another step before the specified step - */ - public boolean hasPreviousStep(Step step) { - return steps.indexOf(step) > 0; - } - - /** - * Return true if there is another step after the specified step. - * - * @param step the step to check against - * @return true if there is another step after the specified step - */ - public boolean hasNextStep(Step step) { - return !isLastStep(step); - } - - /** - * Return true if the specified step is the last step in the process. - * - * @param step the step to check against - * @return true if the specified step is the last step in the process - */ - public boolean isLastStep(Step step) { - int numberOfSteps = steps.size(); - int currentStepIndex = steps.indexOf(step); - - // currentStepIndex is a zero based index. Add 1 when comparing to - // numberOfSteps - return (numberOfSteps == currentStepIndex + 1); - } - - /** - * Goto previous step. - */ - public void previous() { - int currentIndex = steps.indexOf(getCurrentStep()); - if (currentIndex > 0) { - setCurrentStep((Step) steps.get(currentIndex - 1)); - } - } - - /** - * Goto next step. - */ - public void next() { - int currentIndex = steps.indexOf(getCurrentStep()); - if (currentIndex < steps.size() - 1) { - setCurrentStep((Step) steps.get(currentIndex + 1)); - } - } - - /** - * Return the page stylesheet: wizard.css. - * - * @return the page stylesheet - */ - public String getHtmlImports() { - String contextPath = getContext().getRequest().getContextPath(); - return ""; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package net.sf.click.examples.page.wizard; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import net.sf.click.examples.page.BorderPage; + +/** + * This Page manages steps in a wizard process. + * + * @author Bob Schellink + */ +public class WizardPage extends BorderPage { + + /** Current step in the process. */ + private Step currentStep; + + /** List of all steps. */ + private List steps = new ArrayList(); + + /** + * Default constructor. + */ + public WizardPage() { + steps.add(new Step1("step", "Client", "Step 1 of 3", this)); + steps.add(new Step2("step", "Address", "Step 2 of 3", this)); + steps.add(new Step3("step", "Confirmation", "Step 3 of 3", this)); + + // Set first step as current + setCurrentStep((Step) steps.get(0)); + + // Initialize all the steps + Iterator it = steps.iterator(); + while(it.hasNext()) { + Step step = (Step) it.next(); + step.init(); + } + } + + /** + * Return the current step. + * + * @return the current step + */ + public Step getCurrentStep() { + return currentStep; + } + + /** + * Sets the current Step to the specified Step. + * + * @param step the new step to set + */ + public void setCurrentStep(Step step) { + if (this.currentStep != null) { + // Remove the current step from the page list of controls + removeControl(this.currentStep); + } + this.currentStep = step; + // Add the new step to the page list of controls + addControl(step); + } + + /** + * Return true if there is another step before the specified step. + * + * @param step the step to check against + * @return true if there is another step before the specified step + */ + public boolean hasPreviousStep(Step step) { + return steps.indexOf(step) > 0; + } + + /** + * Return true if there is another step after the specified step. + * + * @param step the step to check against + * @return true if there is another step after the specified step + */ + public boolean hasNextStep(Step step) { + return !isLastStep(step); + } + + /** + * Return true if the specified step is the last step in the process. + * + * @param step the step to check against + * @return true if the specified step is the last step in the process + */ + public boolean isLastStep(Step step) { + int numberOfSteps = steps.size(); + int currentStepIndex = steps.indexOf(step); + + // currentStepIndex is a zero based index. Add 1 when comparing to + // numberOfSteps + return (numberOfSteps == currentStepIndex + 1); + } + + /** + * Goto previous step. + */ + public void previous() { + int currentIndex = steps.indexOf(getCurrentStep()); + if (currentIndex > 0) { + setCurrentStep((Step) steps.get(currentIndex - 1)); + } + } + + /** + * Goto next step. + */ + public void next() { + int currentIndex = steps.indexOf(getCurrentStep()); + if (currentIndex < steps.size() - 1) { + setCurrentStep((Step) steps.get(currentIndex + 1)); + } + } + + /** + * Return the page stylesheet: wizard.css. + * + * @return the page stylesheet + */ + public String getHtmlImports() { + String contextPath = getContext().getRequest().getContextPath(); + return ""; + } +}