You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2007/12/12 11:38:27 UTC
svn commit: r603544 - in /myfaces/tobago/trunk:
example/sandbox/src/main/java/org/apache/myfaces/tobago/example/sandbox/
sandbox/src/main/java/org/apache/myfaces/tobago/application/
sandbox/src/main/java/org/apache/myfaces/tobago/model/ sandbox/src/mai...
Author: lofwyr
Date: Wed Dec 12 02:38:26 2007
New Revision: 603544
URL: http://svn.apache.org/viewvc?rev=603544&view=rev
Log:
TOBAGO-518: some refactorings + cleanup
Added:
myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/model/AbstractWizard.java
- copied, changed from r603198, myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/model/AbstractWizardController.java
myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/model/WizardStep.java
Removed:
myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/application/WizardNavigationHandler.java
myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/model/UIWizard.java
Modified:
myfaces/tobago/trunk/example/sandbox/src/main/java/org/apache/myfaces/tobago/example/sandbox/SampleWizard.java
myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/model/Wizard.java
myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/taglib/sandbox/WizardTag.java
Modified: myfaces/tobago/trunk/example/sandbox/src/main/java/org/apache/myfaces/tobago/example/sandbox/SampleWizard.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/sandbox/src/main/java/org/apache/myfaces/tobago/example/sandbox/SampleWizard.java?rev=603544&r1=603543&r2=603544&view=diff
==============================================================================
--- myfaces/tobago/trunk/example/sandbox/src/main/java/org/apache/myfaces/tobago/example/sandbox/SampleWizard.java (original)
+++ myfaces/tobago/trunk/example/sandbox/src/main/java/org/apache/myfaces/tobago/example/sandbox/SampleWizard.java Wed Dec 12 02:38:26 2007
@@ -21,10 +21,10 @@
import org.apache.commons.logging.LogFactory;
import org.apache.myfaces.tobago.component.UIOutput;
import org.apache.myfaces.tobago.component.UIPanel;
-import org.apache.myfaces.tobago.model.AbstractWizardController;
+import org.apache.myfaces.tobago.model.AbstractWizard;
//import org.apache.myfaces.tobago.model.BeanItem;
-public class SampleWizard extends AbstractWizardController {
+public class SampleWizard extends AbstractWizard {
private static final Log LOG = LogFactory.getLog(SampleWizard.class);
Copied: myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/model/AbstractWizard.java (from r603198, myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/model/AbstractWizardController.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/model/AbstractWizard.java?p2=myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/model/AbstractWizard.java&p1=myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/model/AbstractWizardController.java&r1=603198&r2=603544&rev=603544&view=diff
==============================================================================
--- myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/model/AbstractWizardController.java (original)
+++ myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/model/AbstractWizard.java Wed Dec 12 02:38:26 2007
@@ -28,10 +28,9 @@
import java.util.ArrayList;
import java.util.List;
-public abstract class AbstractWizardController implements Wizard {
+public abstract class AbstractWizard implements Wizard {
- private static final Log LOG = LogFactory
- .getLog(AbstractWizardController.class);
+ private static final Log LOG = LogFactory.getLog(AbstractWizard.class);
private static final String WIZARD_FINISH_OUTCOME = "wizard-finish";
@@ -54,13 +53,11 @@
private WizardBackwardNavigationStrategy backNavStrategy = WizardBackwardNavigationStrategy.NOT_ALLOWED;
- private String viewId;
-
- private List<Info> course;
+ private List<WizardStep> course;
/* Constructor */
- protected AbstractWizardController() {
+ protected AbstractWizard() {
reset();
}
@@ -86,13 +83,13 @@
// return getDefaultOutcome();
- return getOutcome(index);
+ return getOutcome();
}
/**
* <p>
* Hook for the implementation of business logic, after invoking the action
- * {@link org.apache.myfaces.tobago.model.AbstractWizardController#next()}.
+ * {@link AbstractWizard#next()}.
* If the execution of the business logic completed successfully, the method
* has to return <i>true</i>. Otherwise the method has to return <i>false</i>.
* </p>
@@ -108,8 +105,7 @@
// TODO : javadoc
public void gotoStep(ActionEvent event) {
- int step = Integer.parseInt((String) (event.getComponent().getAttributes()
- .get("step")));
+ int step = Integer.parseInt((String) (event.getComponent().getAttributes().get("step")));
index = step;
}
@@ -155,14 +151,14 @@
// makeContentDecision(index);
- return getOutcome(index);
+ return getOutcome();
// return getDefaultOutcome();
}
/**
* <p>
* Hook for the implementation of business logic, after invoking the action
- * {@link org.apache.myfaces.tobago.model.AbstractWizardController#previous()}.
+ * {@link AbstractWizard#previous()}.
* If the execution of the business logic completed successfully, the method
* has to return <i>true</i>. Otherwise the method has to return <i>false</i>.
* </p>
@@ -235,7 +231,7 @@
/**
* <p>
* Hook for the implementation of business logic, after invoking the action
- * {@link org.apache.myfaces.tobago.model.AbstractWizardController#finish()}.
+ * {@link AbstractWizard#finish()}.
* If the execution of the business logic completed successfully, the method
* has to return <i>true</i>. Otherwise the method has to return <i>false</i>.
* </p>
@@ -270,7 +266,7 @@
/**
* <p>
* Hook for the implementation of business logic, after invoking the action
- * {@link org.apache.myfaces.tobago.model.AbstractWizardController#cancel()}.
+ * {@link AbstractWizard#cancel()}.
* If the execution of the business logic completed successfully, the method
* has to return <i>true</i>. Otherwise the method has to return <i>false</i>.
* </p>
@@ -326,13 +322,13 @@
// reset requestIndex
requestedIndex = 0;
// return getDefaultOutcome();
- return getOutcome(index);
+ return getOutcome();
}
/**
* <p>
* Hook for the implementation of business logic, after invoking the action
- * {@link org.apache.myfaces.tobago.model.AbstractWizardController#gotoStep()}.
+ * {@link AbstractWizard#gotoStep()}.
* If the execution of the business logic completed successfully, the method
* has to return <i>true</i>. Otherwise the method has to return <i>false</i>.
* </p>
@@ -413,7 +409,7 @@
if (!sizeSet) {
size = 0;
}
- course = new ArrayList<Info>();
+ course = new ArrayList<WizardStep>();
}
/**
@@ -482,17 +478,10 @@
}
}
- // todo
- public String getViewId() {
- viewId = FacesContext.getCurrentInstance().getViewRoot().getViewId();
- return viewId; // To change body of implemented methods use File | Settings
- // | File Templates.
- }
-
/**
* @see Wizard#getCourse()
*/
- public List<Info> getCourse() {
+ public List<WizardStep> getCourse() {
return course;
}
@@ -502,9 +491,9 @@
public void registerOutcome(String outcome, String title) {
if (index == course.size()) { // this is a new page
- course.add(new Info(outcome, title, index));
+ course.add(createWizardStep(outcome, title));
} else if (index < course.size()) {
- course.set(index, new Info(outcome, title, index));
+ course.set(index, createWizardStep(outcome, title));
} else {
throw new IllegalStateException("Index too large for course: index="
+ index + " course.size()=" + course.size());
@@ -512,10 +501,14 @@
LOG.info("course: " + course);
}
+ protected WizardStep createWizardStep(String outcome, String title) {
+ return new WizardStep(outcome, title, index);
+ }
+
public void registerOutcome(String outcome, String title, int index) {
if (index == course.size()) { // this is a new page
- course.add(new Info(outcome, title, index));
+ course.add(new WizardStep(outcome, title, index));
} else {
registerOutcome(outcome, title);
}
@@ -524,49 +517,10 @@
/**
* Returns the outcome for the requested wizard view
*
- * @param forIndex
- * The index of the requested wizard view
* @return The outcome for the view index
*/
- public final String getOutcome(int forIndex) {
+ private String getOutcome() {
return course.get(index).getOutcome();
- }
-
- // XXX
- public static class Info {
- private String outcome;
- private String title;
- private int index;
-
- public Info(String outcome, String title, int index) {
- this.outcome = outcome;
- this.title = title;
- this.index = index;
- }
-
- public String getOutcome() {
- return outcome;
- }
-
- public void setOutcome(String outcome) {
- this.outcome = outcome;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public int getIndex() {
- return index;
- }
-
- public void setIndex(int index) {
- this.index = index;
- }
}
}
Modified: myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/model/Wizard.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/model/Wizard.java?rev=603544&r1=603543&r2=603544&view=diff
==============================================================================
--- myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/model/Wizard.java (original)
+++ myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/model/Wizard.java Wed Dec 12 02:38:26 2007
@@ -165,9 +165,7 @@
*/
void setBackwardNavigationStrategy(String strategy);
- String getViewId();
-
- List<AbstractWizardController.Info> getCourse();
+ List<WizardStep> getCourse();
void registerOutcome(String outcome, String title);
}
Added: myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/model/WizardStep.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/model/WizardStep.java?rev=603544&view=auto
==============================================================================
--- myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/model/WizardStep.java (added)
+++ myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/model/WizardStep.java Wed Dec 12 02:38:26 2007
@@ -0,0 +1,54 @@
+package org.apache.myfaces.tobago.model;
+
+/*
+ * 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.
+ */
+public class WizardStep {
+
+ private String outcome;
+ private String title;
+ private int index;
+
+ public WizardStep(String outcome, String title, int index) {
+ this.outcome = outcome;
+ this.title = title;
+ this.index = index;
+ }
+
+ public String getOutcome() {
+ return outcome;
+ }
+
+ public void setOutcome(String outcome) {
+ this.outcome = outcome;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getIndex() {
+ return index;
+ }
+
+ public void setIndex(int index) {
+ this.index = index;
+ }
+}
Modified: myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/taglib/sandbox/WizardTag.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/taglib/sandbox/WizardTag.java?rev=603544&r1=603543&r2=603544&view=diff
==============================================================================
--- myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/taglib/sandbox/WizardTag.java (original)
+++ myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/taglib/sandbox/WizardTag.java Wed Dec 12 02:38:26 2007
@@ -25,8 +25,8 @@
import org.apache.myfaces.tobago.apt.annotation.Tag;
import org.apache.myfaces.tobago.apt.annotation.TagAttribute;
import org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute;
-import org.apache.myfaces.tobago.model.AbstractWizardController;
import org.apache.myfaces.tobago.model.Wizard;
+import org.apache.myfaces.tobago.model.WizardStep;
import org.apache.myfaces.tobago.taglib.component.AttributeTag;
import org.apache.myfaces.tobago.taglib.component.ButtonTag;
import org.apache.myfaces.tobago.taglib.component.CellTag;
@@ -90,7 +90,7 @@
private void processTrain() throws JspException {
- List<AbstractWizardController.Info> course = null;
+ List<WizardStep> course = null;
try {
Object bean = VariableResolverUtil.resolveVariable(FacesContext.getCurrentInstance(), "controller");
Wizard wizard = (Wizard) PropertyUtils.getProperty(bean, "wizard");
@@ -115,7 +115,7 @@
gridLayoutTag.setPageContext(pageContext);
// gridLayoutTag.setColumns("*");
StringBuilder columns = new StringBuilder();
- for (AbstractWizardController.Info info : course) {
+ for (WizardStep info : course) {
columns.append("fixed;");
}
gridLayoutTag.setColumns(columns + "*");
@@ -125,7 +125,7 @@
facetTag.doEndTag();
- for (AbstractWizardController.Info info : course) {
+ for (WizardStep info : course) {
ButtonTag button = new ButtonTag();
button.setPageContext(pageContext);
button.setParent(p);