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/10/23 20:50:11 UTC
svn commit: r587603 - in /myfaces/tobago/trunk: example/sandbox/
example/sandbox/src/main/java/org/apache/myfaces/tobago/example/sandbox/
example/sandbox/src/main/webapp/ example/sandbox/src/main/webapp/WEB-INF/
sandbox/src/main/java/org/apache/myfaces...
Author: lofwyr
Date: Tue Oct 23 11:50:09 2007
New Revision: 587603
URL: http://svn.apache.org/viewvc?rev=587603&view=rev
Log:
TOBAGO-518: Wizard
Adding also Facelets to the Sandbox Example
Added:
myfaces/tobago/trunk/example/sandbox/src/main/java/org/apache/myfaces/tobago/example/sandbox/SampleWizard.java
myfaces/tobago/trunk/example/sandbox/src/main/webapp/snip-0.jsp
- copied, changed from r586044, myfaces/tobago/trunk/example/sandbox/src/main/webapp/inputSlider.jsp
myfaces/tobago/trunk/example/sandbox/src/main/webapp/snip-0.xml
myfaces/tobago/trunk/example/sandbox/src/main/webapp/snip-1.jsp
myfaces/tobago/trunk/example/sandbox/src/main/webapp/snip-1.xml
myfaces/tobago/trunk/example/sandbox/src/main/webapp/wizard.jsp
- copied, changed from r586044, myfaces/tobago/trunk/example/sandbox/src/main/webapp/tree-normal.jsp
myfaces/tobago/trunk/example/sandbox/src/main/webapp/wizard.xml
myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/component/UIWizard.java
- copied, changed from r586044, myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/component/UITree.java
myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/model/AbstractWizard.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/renderkit/html/scarborough/standard/tag/WizardRenderer.java
- copied, changed from r586044, myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeRenderer.java
myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/taglib/sandbox/WizardTag.java
- copied, changed from r586044, myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/taglib/sandbox/TreeTag.java
myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/taglib/sandbox/WizardTagDeclaration.java
- copied, changed from r586044, myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/taglib/sandbox/TreeTagDeclaration.java
myfaces/tobago/trunk/sandbox/src/main/resources/META-INF/wizard.xml
- copied, changed from r587462, myfaces/tobago/trunk/extension/facelets/src/main/resources/META-INF/time.xml
Modified:
myfaces/tobago/trunk/example/sandbox/pom.xml
myfaces/tobago/trunk/example/sandbox/src/main/java/org/apache/myfaces/tobago/example/sandbox/Controller.java
myfaces/tobago/trunk/example/sandbox/src/main/webapp/WEB-INF/faces-config.xml
myfaces/tobago/trunk/example/sandbox/src/main/webapp/WEB-INF/web.xml
myfaces/tobago/trunk/example/sandbox/src/main/webapp/navigation.jsp
Modified: myfaces/tobago/trunk/example/sandbox/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/sandbox/pom.xml?rev=587603&r1=587602&r2=587603&view=diff
==============================================================================
--- myfaces/tobago/trunk/example/sandbox/pom.xml (original)
+++ myfaces/tobago/trunk/example/sandbox/pom.xml Tue Oct 23 11:50:09 2007
@@ -156,6 +156,11 @@
<version>1.0</version>
<scope>compile</scope>
</dependency>-->
+ <dependency>
+ <groupId>com.sun.el</groupId>
+ <artifactId>el-ri</artifactId>
+ <version>1.0</version>
+ </dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
Modified: myfaces/tobago/trunk/example/sandbox/src/main/java/org/apache/myfaces/tobago/example/sandbox/Controller.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/sandbox/src/main/java/org/apache/myfaces/tobago/example/sandbox/Controller.java?rev=587603&r1=587602&r2=587603&view=diff
==============================================================================
--- myfaces/tobago/trunk/example/sandbox/src/main/java/org/apache/myfaces/tobago/example/sandbox/Controller.java (original)
+++ myfaces/tobago/trunk/example/sandbox/src/main/java/org/apache/myfaces/tobago/example/sandbox/Controller.java Tue Oct 23 11:50:09 2007
@@ -20,6 +20,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.myfaces.tobago.model.TreeState;
+import org.apache.myfaces.tobago.model.Wizard;
import javax.swing.tree.DefaultMutableTreeNode;
import java.text.SimpleDateFormat;
@@ -37,6 +38,8 @@
private int sliderValue;
+ private Wizard wizard;
+
public Controller() {
// tree
tree = new DefaultMutableTreeNode(new Node("1 Category"));
@@ -72,6 +75,10 @@
state.addExpandState(temp);
state.addSelection(temp2);
state.setMarker(music);
+
+ // wizard
+
+ wizard = new SampleWizard();
}
public String action1() {
@@ -113,7 +120,7 @@
return new SimpleDateFormat("hh:MM:ss").format(new Date());
}
- public DefaultMutableTreeNode getTree() {
+ public DefaultMutableTreeNode getTree() {
return tree;
}
@@ -139,7 +146,11 @@
}
public String sliderSubmit() {
- LOG.info("Slider: "+sliderValue);
+ LOG.info("Slider: " + sliderValue);
return null;
+ }
+
+ public Wizard getWizard() {
+ return wizard;
}
}
Added: 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=587603&view=auto
==============================================================================
--- myfaces/tobago/trunk/example/sandbox/src/main/java/org/apache/myfaces/tobago/example/sandbox/SampleWizard.java (added)
+++ myfaces/tobago/trunk/example/sandbox/src/main/java/org/apache/myfaces/tobago/example/sandbox/SampleWizard.java Tue Oct 23 11:50:09 2007
@@ -0,0 +1,78 @@
+package org.apache.myfaces.tobago.example.sandbox;
+
+/*
+ * 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.
+ */
+
+import org.apache.commons.logging.Log;
+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.AbstractWizard;
+import org.apache.myfaces.tobago.model.BeanItem;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class SampleWizard extends AbstractWizard {
+
+ private static final Log LOG = LogFactory.getLog(SampleWizard.class);
+
+ List<BeanItem> items = new ArrayList<BeanItem>();
+
+ public String finish() {
+ return null;
+ }
+
+ public UIPanel getCurrentComponent() {
+
+ UIOutput out = new UIOutput();
+ out.setValue(getIndex());
+
+ UIPanel panel = new UIPanel();
+ panel.getChildren().add(out);
+
+ return panel;
+ }
+
+ @Override
+ public String next() {
+
+ LOG.info("items: " + items);
+ items.clear();
+
+ switch (getIndex()) {
+ case 1:
+ items.add(new BeanItem("out", null, "Bitte geben Sie ihren Namen ein."));
+ items.add(new BeanItem("in", "Vorname", null));
+ items.add(new BeanItem("in", "Nachname", null));
+ break;
+ case 2:
+ items.add(new BeanItem("out", null, "Bitte geben Sie ihre Adresse ein."));
+ items.add(new BeanItem("in", "StraÃe", null));
+ items.add(new BeanItem("in", "Ort", null));
+ items.add(new BeanItem("in", "Land", null));
+ break;
+ }
+
+ return super.next();
+ }
+
+ public List<BeanItem> getItems() {
+ return items;
+ }
+
+}
Modified: myfaces/tobago/trunk/example/sandbox/src/main/webapp/WEB-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/sandbox/src/main/webapp/WEB-INF/faces-config.xml?rev=587603&r1=587602&r2=587603&view=diff
==============================================================================
--- myfaces/tobago/trunk/example/sandbox/src/main/webapp/WEB-INF/faces-config.xml (original)
+++ myfaces/tobago/trunk/example/sandbox/src/main/webapp/WEB-INF/faces-config.xml Tue Oct 23 11:50:09 2007
@@ -24,6 +24,9 @@
<faces-config>
<application>
+ <view-handler>
+ com.sun.facelets.FaceletViewHandler
+ </view-handler>
<locale-config>
<default-locale>en</default-locale>
</locale-config>
@@ -35,5 +38,20 @@
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
+ <navigation-rule>
+ <from-view-id>/wizard.jsp</from-view-id>
+ <navigation-case>
+ <from-outcome>wizard</from-outcome>
+ <to-view-id>/wizard.jsp</to-view-id>
+ </navigation-case>
+ </navigation-rule>
+
+ <navigation-rule>
+ <from-view-id>/wizard.xml</from-view-id>
+ <navigation-case>
+ <from-outcome>wizard</from-outcome>
+ <to-view-id>/wizard.xml</to-view-id>
+ </navigation-case>
+ </navigation-rule>
</faces-config>
Modified: myfaces/tobago/trunk/example/sandbox/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/sandbox/src/main/webapp/WEB-INF/web.xml?rev=587603&r1=587602&r2=587603&view=diff
==============================================================================
--- myfaces/tobago/trunk/example/sandbox/src/main/webapp/WEB-INF/web.xml (original)
+++ myfaces/tobago/trunk/example/sandbox/src/main/webapp/WEB-INF/web.xml Tue Oct 23 11:50:09 2007
@@ -24,6 +24,26 @@
<display-name>Tobago Sandbox Application</display-name>
+ <context-param>
+ <param-name>facelets.DEVELOPMENT</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
+ <context-param>
+ <param-name>facelets.SKIP_COMMENTS</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
+ <context-param>
+ <param-name>facelets.VIEW_MAPPINGS</param-name>
+ <param-value>*.xml</param-value>
+ </context-param>
+
+ <context-param>
+ <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
+ <param-value>.xml</param-value>
+ </context-param>
+
<filter>
<filter-name>multipartFormdataFilter</filter-name>
<filter-class>org.apache.myfaces.tobago.webapp.TobagoMultipartFormdataFilter</filter-class>
Modified: myfaces/tobago/trunk/example/sandbox/src/main/webapp/navigation.jsp
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/sandbox/src/main/webapp/navigation.jsp?rev=587603&r1=587602&r2=587603&view=diff
==============================================================================
--- myfaces/tobago/trunk/example/sandbox/src/main/webapp/navigation.jsp (original)
+++ myfaces/tobago/trunk/example/sandbox/src/main/webapp/navigation.jsp Tue Oct 23 11:50:09 2007
@@ -23,7 +23,7 @@
<tc:page label="Sandbox Menu" id="page" width="200px" height="800px">
<f:facet name="layout">
- <tc:gridLayout margin="5px" rows="fixed;fixed;fixed;fixed;fixed;fixed;*"/>
+ <tc:gridLayout margin="5px" rows="fixed;fixed;fixed;fixed;fixed;fixed;fixed;fixed;*"/>
</f:facet>
<tc:link link="separator.jsp" label="separator.jsp" target="View"/>
@@ -39,6 +39,10 @@
<tc:link link="tree-ajax.jsp" label="tree-ajax.jsp" target="View"/>
<tc:link link="inputSlider.jsp" label="inputSlider.jsp" target="View"/>
+
+ <tc:link link="wizard.jsp" label="wizard.jsp" target="View"/>
+
+ <tc:link link="wizard.xml" label="wizard.xml" target="View"/>
<tc:cell/>
</tc:page>
Copied: myfaces/tobago/trunk/example/sandbox/src/main/webapp/snip-0.jsp (from r586044, myfaces/tobago/trunk/example/sandbox/src/main/webapp/inputSlider.jsp)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/sandbox/src/main/webapp/snip-0.jsp?p2=myfaces/tobago/trunk/example/sandbox/src/main/webapp/snip-0.jsp&p1=myfaces/tobago/trunk/example/sandbox/src/main/webapp/inputSlider.jsp&r1=586044&r2=587603&rev=587603&view=diff
==============================================================================
--- myfaces/tobago/trunk/example/sandbox/src/main/webapp/inputSlider.jsp (original)
+++ myfaces/tobago/trunk/example/sandbox/src/main/webapp/snip-0.jsp Tue Oct 23 11:50:09 2007
@@ -19,22 +19,5 @@
<%@ taglib uri="http://myfaces.apache.org/tobago/component" prefix="tc" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
-<f:view>
- <tc:loadBundle basename="demo" var="bundle"/>
-
- <tc:page label="Sandbox - InputSlider" width="500px" height="800px">
- <f:facet name="layout">
- <tc:gridLayout margin="10px" rows="*"/>
- </f:facet>
- <tc:box label="InputSlider">
- <f:facet name="layout">
- <tc:gridLayout columns="fixed;*" rows="fixed;*"/>
- </f:facet>
- <tcs:numberSlider value="#{controller.sliderValue}" min="0" max="200">
- </tcs:numberSlider>
- <tc:button action="#{controller.sliderSubmit}" label="Submit" />
- <tc:cell/>
- <tc:cell/>
- </tc:box>
- </tc:page>
-</f:view>
\ No newline at end of file
+<tc:box label="First Page">
+</tc:box>
Added: myfaces/tobago/trunk/example/sandbox/src/main/webapp/snip-0.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/sandbox/src/main/webapp/snip-0.xml?rev=587603&view=auto
==============================================================================
--- myfaces/tobago/trunk/example/sandbox/src/main/webapp/snip-0.xml (added)
+++ myfaces/tobago/trunk/example/sandbox/src/main/webapp/snip-0.xml Tue Oct 23 11:50:09 2007
@@ -0,0 +1,5 @@
+<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:tc="http://myfaces.apache.org/tobago/component">
+ <tc:box label="First Page">
+ </tc:box>
+</ui:composition>
Added: myfaces/tobago/trunk/example/sandbox/src/main/webapp/snip-1.jsp
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/sandbox/src/main/webapp/snip-1.jsp?rev=587603&view=auto
==============================================================================
--- myfaces/tobago/trunk/example/sandbox/src/main/webapp/snip-1.jsp (added)
+++ myfaces/tobago/trunk/example/sandbox/src/main/webapp/snip-1.jsp Tue Oct 23 11:50:09 2007
@@ -0,0 +1,22 @@
+<%--
+ * 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.
+--%>
+
+<%@ taglib uri="http://myfaces.apache.org/tobago/sandbox" prefix="tcs" %>
+<%@ taglib uri="http://myfaces.apache.org/tobago/component" prefix="tc" %>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
+
+<tc:out value="Second Page" />
Added: myfaces/tobago/trunk/example/sandbox/src/main/webapp/snip-1.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/sandbox/src/main/webapp/snip-1.xml?rev=587603&view=auto
==============================================================================
--- myfaces/tobago/trunk/example/sandbox/src/main/webapp/snip-1.xml (added)
+++ myfaces/tobago/trunk/example/sandbox/src/main/webapp/snip-1.xml Tue Oct 23 11:50:09 2007
@@ -0,0 +1,5 @@
+<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:tc="http://myfaces.apache.org/tobago/component">
+ <tc:out value="Second Page">
+ </tc:out>
+</ui:composition>
Copied: myfaces/tobago/trunk/example/sandbox/src/main/webapp/wizard.jsp (from r586044, myfaces/tobago/trunk/example/sandbox/src/main/webapp/tree-normal.jsp)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/sandbox/src/main/webapp/wizard.jsp?p2=myfaces/tobago/trunk/example/sandbox/src/main/webapp/wizard.jsp&p1=myfaces/tobago/trunk/example/sandbox/src/main/webapp/tree-normal.jsp&r1=586044&r2=587603&rev=587603&view=diff
==============================================================================
--- myfaces/tobago/trunk/example/sandbox/src/main/webapp/tree-normal.jsp (original)
+++ myfaces/tobago/trunk/example/sandbox/src/main/webapp/wizard.jsp Tue Oct 23 11:50:09 2007
@@ -22,47 +22,13 @@
<f:view>
<tc:loadBundle basename="demo" var="bundle"/>
- <tc:page label="Sandbox - Tree" id="page"
+ <tc:page label="Sandbox - Wizard" id="page"
width="500px" height="800px">
<f:facet name="layout">
<tc:gridLayout margin="10px" rows="600px;*"/>
</f:facet>
- <%--state="#{controller.state}" --%>
- <tcs:tree id="tree"
- showIcons="true"
- showJunctions="true"
- showRootJunction="true"
- showRoot="true"
- >
- <tcs:treeNode label="Root" id="root" expanded="true">
- <tcs:treeData value="#{controller.tree}" var="node" id="data">
- <tcs:treeNode label="#{node.userObject.name}"
- id="template"
- expanded="#{node.userObject.expanded}"
- markup="#{node.userObject.markup}"
- tip="#{node.userObject.tip}"
- action="#{node.userObject.action}"
- disabled="#{node.userObject.disabled}"
- value="#{node}"
- image="feather.png"/>
- </tcs:treeData>
- <tcs:treeNode label="2 Action 1" action="#{controller.action1}" id="action1">
- <f:facet name="addendum">
- <tc:out value="(Addendum)" />
- </f:facet>
- </tcs:treeNode>
- <tcs:treeNode label="3 Action 2" action="#{controller.action2}" id="action2"/>
- <tcs:treeNode label="4 Action 3" action="#{controller.action3}" id="action3">
- <tcs:treeNode label="4.1 On Click 1" onclick="alert('On Click 1');" id="click1"/>
- <tcs:treeNode label="4.2 On Click 2" onclick="alert('On Click 2');" id="click2">
- <tcs:treeNode label="4.2.1 On Click 3" onclick="alert('On Click 3');" id="click3"/>
- </tcs:treeNode>
- </tcs:treeNode>
- <tcs:treeNode label="5 Link" link="http://myfaces.apache.org/tobago/" id="link" tip="Subnode Link"/>
- <tcs:treeNode label="6 Target" action="#{controller.action2}" target="Target Window"/>
- </tcs:treeNode>
- </tcs:tree>
+ <tcs:wizard controller="#{controller.wizard}"/>
<tc:cell/>
Added: myfaces/tobago/trunk/example/sandbox/src/main/webapp/wizard.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/sandbox/src/main/webapp/wizard.xml?rev=587603&view=auto
==============================================================================
--- myfaces/tobago/trunk/example/sandbox/src/main/webapp/wizard.xml (added)
+++ myfaces/tobago/trunk/example/sandbox/src/main/webapp/wizard.xml Tue Oct 23 11:50:09 2007
@@ -0,0 +1,35 @@
+<!--
+ * 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.
+-->
+
+<f:view xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:tc="http://myfaces.apache.org/tobago/component"
+ xmlns:tx="http://myfaces.apache.org/tobago/facelet-extension"
+ xmlns:tcs="http://myfaces.apache.org/tobago/sandbox"
+ xmlns:tfs="http://myfaces.apache.org/tobago/facelet-sandbox">
+ <tc:loadBundle basename="demo" var="bundle"/>
+
+ <tc:page label="Sandbox - Wizard" id="page"
+ width="500px" height="800px">
+ <f:facet name="layout">
+ <tc:gridLayout margin="10px"/>
+ </f:facet>
+
+ <tfs:wizard controller="#{controller.wizard}"/>
+
+ </tc:page>
+</f:view>
Copied: myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/component/UIWizard.java (from r586044, myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/component/UITree.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/component/UIWizard.java?p2=myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/component/UIWizard.java&p1=myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/component/UITree.java&r1=586044&r2=587603&rev=587603&view=diff
==============================================================================
--- myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/component/UITree.java (original)
+++ myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/component/UIWizard.java Tue Oct 23 11:50:09 2007
@@ -1,5 +1,9 @@
package org.apache.myfaces.tobago.component;
+import org.apache.myfaces.tobago.model.Wizard;
+
+import javax.faces.el.ValueBinding;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -17,297 +21,25 @@
* limitations under the License.
*/
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_MODE;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SELECTABLE;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SHOW_ICONS;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SHOW_JUNCTIONS;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SHOW_ROOT;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SHOW_ROOT_JUNCTION;
-import org.apache.myfaces.tobago.model.MixedTreeModel;
-
-import javax.faces.application.FacesMessage;
-import javax.faces.component.NamingContainer;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIInput;
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-import javax.faces.validator.Validator;
-import javax.faces.validator.ValidatorException;
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.Iterator;
-import java.util.List;
-
-public class UITree extends UIInput implements NamingContainer {
-
- public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.Tree";
- public static final String MESSAGE_NOT_LEAF = "tobago.tree.MESSAGE_NOT_LEAF";
-
- public static final String SEP = "-";
-
- public static final String TREE_STATE = SEP + "treeState";
- public static final String SELECT_STATE = SEP + "selectState";
- public static final String MARKER = SEP + "marker";
-
- public static final String FACET_TREE_NODE_COMMAND = "treeNodeCommand";
- public static final String PARAMETER_TREE_NODE_ID = "treeNodeId";
-
- private boolean showJunctions = true;
- private boolean showJunctionsSet = false;
- private boolean showIcons = true;
- private boolean showIconsSet = false;
- private boolean showRoot = true;
- private boolean showRootSet = false;
- private boolean showRootJunction = true;
- private boolean showRootJunctionSet = false;
-
- private String mode;
- private MixedTreeModel model;
-
- public String getMode() {
- if (mode != null) {
- return mode;
- }
- ValueBinding vb = getValueBinding(ATTR_MODE);
- if (vb != null) {
- return (String) vb.getValue(getFacesContext());
- } else {
- return "tree";
- }
- }
-
- public void setMode(String mode) {
- this.mode = mode;
- }
-
- public UIComponent getRoot() {
- // find the UITreeNode in the childen.
- for (UIComponent child : (List<UIComponent>) getChildren()) {
- if (child instanceof UITreeNode) {
- return child;
- }
- if (child instanceof UITreeData) {
- return child;
- }
- }
- return null;
- }
-
- public void encodeEnd(FacesContext context) throws IOException {
- model = new MixedTreeModel();
-
- buildModel();
- super.encodeEnd(context);
- }
-
- private void buildModel() {
- for (Object child : getChildren()) {
- if (child instanceof TreeModelBuilder) {
- TreeModelBuilder builder = (TreeModelBuilder) child;
- builder.buildBegin(model);
- builder.buildChildren(model);
- builder.buildEnd(model);
- }
- }
- }
-
- public boolean getRendersChildren() {
- return true;
- }
-
- public boolean isSelectableTree() {
- final Object selectable
- = ComponentUtil.getAttribute(this, ATTR_SELECTABLE);
- return selectable != null
- && (selectable.equals("multi") || selectable.equals("multiLeafOnly")
- || selectable.equals("single") || selectable.equals("singleLeafOnly")
- || selectable.equals("sibling") || selectable.equals("siblingLeafOnly"));
- }
-
- public void processDecodes(FacesContext facesContext) {
-
- if (!isRendered()) {
- return;
- }
-
- if (ComponentUtil.isOutputOnly(this)) {
- setValid(true);
- } else {
- // in tree first decode node and than decode children
-
- decode(facesContext);
-
- for (Iterator i = getFacetsAndChildren(); i.hasNext();) {
- UIComponent uiComponent = ((UIComponent) i.next());
- uiComponent.processDecodes(facesContext);
- }
- }
- }
-
- public void validate(FacesContext context) {
-
-// todo: validate must be written new, without TreeState
-/*
- if (isRequired() && getState().getSelection().size() == 0) {
- setValid(false);
- FacesMessage facesMessage = MessageFactory.createFacesMessage(context,
- UISelectOne.MESSAGE_VALUE_REQUIRED, FacesMessage.SEVERITY_ERROR);
- context.addMessage(getClientId(context), facesMessage);
- }
-
- String selectable = ComponentUtil.getStringAttribute(this, ATTR_SELECTABLE);
- if (selectable != null && selectable.endsWith("LeafOnly")) {
-
- Set<DefaultMutableTreeNode> selection = getState().getSelection();
-
- for (DefaultMutableTreeNode node : selection) {
- if (!node.isLeaf()) {
- FacesMessage facesMessage = MessageFactory.createFacesMessage(
- context, MESSAGE_NOT_LEAF, FacesMessage.SEVERITY_ERROR);
- context.addMessage(getClientId(context), facesMessage);
- break; // don't continue iteration, no dublicate messages needed
- }
- }
- }
-*/
-// call all validators
- if (getValidators() != null) {
- for (Validator validator : getValidators()) {
- try {
- validator.validate(context, this, null);
- } catch (ValidatorException ve) {
- // If the validator throws an exception, we're
- // invalid, and we need to add a message
- setValid(false);
- FacesMessage message = ve.getFacesMessage();
- if (message != null) {
- message.setSeverity(FacesMessage.SEVERITY_ERROR);
- context.addMessage(getClientId(context), message);
- }
- }
- }
- }
- }
-
- public void updateModel(FacesContext facesContext) {
- // nothig to update for tree's
- // TODO: updateing the model here and *NOT* in the decode phase
- }
-
- public Object saveState(FacesContext context) {
- Object[] state = new Object[6];
- state[0] = super.saveState(context);
- state[1] = showJunctionsSet ? showJunctions : null;
- state[2] = showIconsSet ? showIcons : null;
- state[3] = showRootSet ? showRoot : null;
- state[4] = showRootJunctionSet ? showRootJunction : null;
- state[5] = mode;
- return state;
- }
-
- public void restoreState(FacesContext context, Object state) {
- Object[] values = (Object[]) state;
- super.restoreState(context, values[0]);
- if (values[1] != null) {
- showJunctions = (Boolean) values[1];
- showJunctionsSet = true;
- }
- if (values[2] != null) {
- showIcons = (Boolean) values[2];
- showIconsSet = true;
- }
- if (values[3] != null) {
- showRoot = (Boolean) values[3];
- showRootSet = true;
- }
- if (values[4] != null) {
- showRootJunction = (Boolean) values[4];
- showRootJunctionSet = true;
- }
- mode = (String) values[5];
- }
-
- public boolean isShowJunctions() {
- if (showJunctionsSet) {
- return (showJunctions);
- }
- ValueBinding vb = getValueBinding(ATTR_SHOW_JUNCTIONS);
- if (vb != null) {
- return (!Boolean.FALSE.equals(vb.getValue(getFacesContext())));
- } else {
- return (this.showJunctions);
- }
- }
-
- public void setShowJunctions(boolean showJunctions) {
- this.showJunctions = showJunctions;
- this.showJunctionsSet = true;
- }
+public class UIWizard extends UIPanel {
- public boolean isShowIcons() {
- if (showIconsSet) {
- return (showIcons);
- }
- ValueBinding vb = getValueBinding(ATTR_SHOW_ICONS);
- if (vb != null) {
- return (!Boolean.FALSE.equals(vb.getValue(getFacesContext())));
- } else {
- return (this.showIcons);
- }
- }
+ public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.Wizard";
- public void setShowIcons(boolean showIcons) {
- this.showIcons = showIcons;
- this.showIconsSet = true;
- }
+ private Wizard controller;
- public boolean isShowRoot() {
- if (showRootSet) {
- return (showRoot);
+ public Wizard getController() {
+ if (controller != null) {
+ return controller;
}
- ValueBinding vb = getValueBinding(ATTR_SHOW_ROOT);
+ ValueBinding vb = getValueBinding("controller"); // xxx const
if (vb != null) {
- return (!Boolean.FALSE.equals(vb.getValue(getFacesContext())));
+ return (Wizard) vb.getValue(getFacesContext());
} else {
- return (this.showRoot);
- }
- }
-
- public void setShowRoot(boolean showRoot) {
- this.showRoot = showRoot;
- this.showRootSet = true;
- }
-
- public boolean isShowRootJunction() {
- if (showRootJunctionSet) {
- return (showRootJunction);
- }
- ValueBinding vb = getValueBinding(ATTR_SHOW_ROOT_JUNCTION);
- if (vb != null) {
- return (!Boolean.FALSE.equals(vb.getValue(getFacesContext())));
- } else {
- return (this.showRootJunction);
- }
- }
-
- public void setShowRootJunction(boolean showRootJunction) {
- this.showRootJunction = showRootJunction;
- this.showRootJunctionSet = true;
- }
-
- public static class Command implements Serializable {
- private String command;
-
- public Command(String command) {
- this.command = command;
- }
-
- public String getCommand() {
- return command;
+ return null;
}
}
- public MixedTreeModel getModel() {
- return model;
+ public void setController(Wizard controller) {
+ this.controller = controller;
}
}
Added: myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/model/AbstractWizard.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/model/AbstractWizard.java?rev=587603&view=auto
==============================================================================
--- myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/model/AbstractWizard.java (added)
+++ myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/model/AbstractWizard.java Tue Oct 23 11:50:09 2007
@@ -0,0 +1,70 @@
+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.
+ */
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public abstract class AbstractWizard implements Wizard {
+
+ private static final Log LOG = LogFactory.getLog(AbstractWizard.class);
+
+ int index = 0;
+
+ public String start() {
+ index = 0;
+ return "wizard";
+ }
+
+ public boolean isStartAvailable() {
+ return index > 0;
+ }
+
+ public String next() {
+ index++;
+ LOG.info("next -> " + index);
+ return "wizard";
+ }
+
+ public boolean isNextAvailable() {
+ return getSize() == null || index + 1 < getSize();
+ }
+
+ public String previous() {
+ if (index > 0) {
+ index--;
+ }
+ return "wizard";
+ }
+
+ public boolean isPreviousAvailable() {
+ return index > 0;
+ }
+
+ public boolean isFinishAvailable() {
+ return getSize() == null || index + 1 >= getSize();
+ }
+
+ public int getIndex() {
+ return index;
+ }
+
+ public Integer getSize() {
+ return 6; //xxx not implemented yet
+ }
+}
Added: 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=587603&view=auto
==============================================================================
--- myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/model/Wizard.java (added)
+++ myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/model/Wizard.java Tue Oct 23 11:50:09 2007
@@ -0,0 +1,53 @@
+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.
+ */
+
+import org.apache.myfaces.tobago.component.UIPanel;
+
+import java.util.List;
+
+public interface Wizard {
+
+ String start();
+
+ boolean isStartAvailable();
+
+ String next();
+
+ boolean isNextAvailable();
+
+ String previous();
+
+ boolean isPreviousAvailable();
+
+ String finish();
+
+ boolean isFinishAvailable();
+
+ UIPanel getCurrentComponent();
+
+ List<BeanItem> getItems();
+
+ int getIndex();
+
+ /**
+ *
+ * @return The number of pages in the wizard or null if this information is unavailable.
+ */
+ Integer getSize();
+}
Copied: myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/WizardRenderer.java (from r586044, myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeRenderer.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/WizardRenderer.java?p2=myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/WizardRenderer.java&p1=myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeRenderer.java&r1=586044&r2=587603&rev=587603&view=diff
==============================================================================
--- myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeRenderer.java (original)
+++ myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/WizardRenderer.java Tue Oct 23 11:50:09 2007
@@ -17,173 +17,8 @@
* limitations under the License.
*/
-/*
- * Created 07.02.2003 16:00:00.
- * $Id$
- */
-
-import org.apache.myfaces.tobago.component.ComponentUtil;
-import org.apache.myfaces.tobago.component.UITree;
-import org.apache.myfaces.tobago.component.UITreeNode;
-import org.apache.myfaces.tobago.context.ResourceManagerUtil;
import org.apache.myfaces.tobago.renderkit.LayoutableRendererBase;
-import org.apache.myfaces.tobago.renderkit.RenderUtil;
-import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
-import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
-import org.apache.myfaces.tobago.renderkit.html.HtmlRendererUtil;
-import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
-
-import javax.faces.component.NamingContainer;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.util.List;
-
-public class TreeRenderer extends LayoutableRendererBase {
-
- /**
- * Resources to display the tree.
- */
- private static final String[] TREE_IMAGES = {
- "openfoldericon.gif",
- "foldericon.gif",
- "unchecked.gif",
- "uncheckedDisabled.gif",
- "checked.gif",
- "checkedDisabled.gif",
- "new.gif",
- "T.gif",
- "L.gif",
- "I.gif",
- "Lminus.gif",
- "Tminus.gif",
- "Rminus.gif",
- "Lplus.gif",
- "Tplus.gif",
- "Rplus.gif",
- "treeMenuOpen.gif",
- "treeMenuClose.gif",
- };
-
-
- @Override
- public void decode(FacesContext facesContext, UIComponent component) {
- if (ComponentUtil.isOutputOnly(component)) {
- return;
- }
-
- UITree tree = (UITree) component;
- tree.setValid(true);
- }
-
- public static boolean isSelectable(UITree tree) {
- return tree.isSelectableTree();
- }
-
- public static String createJavascriptVariable(String clientId) {
- return clientId == null
- ? null
- : clientId.replace(NamingContainer.SEPARATOR_CHAR, '_');
- }
-
- @Override
- public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
- // will be rendered in encodeEnd()
- }
-
- @Override
- public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {
-
- UITree tree = (UITree) component;
-
- String clientId = tree.getClientId(facesContext);
- UIComponent root = tree.getRoot();
-
- TobagoResponseWriter writer = HtmlRendererUtil.getTobagoResponseWriter(facesContext);
-
- writer.startElement(HtmlConstants.DIV, tree);
- writer.writeClassAttribute();
- writer.writeStyleAttribute();
-
- writer.startElement(HtmlConstants.INPUT, tree);
- writer.writeAttribute(HtmlAttributes.TYPE, "hidden", false);
- writer.writeNameAttribute(clientId);
- writer.writeIdAttribute(clientId);
- writer.writeAttribute(HtmlAttributes.VALUE, ";", false);
- writer.endElement(HtmlConstants.INPUT);
-
- writer.startElement(HtmlConstants.INPUT, tree);
- writer.writeAttribute(HtmlAttributes.TYPE, "hidden", false);
- writer.writeNameAttribute(clientId + UITree.MARKER);
- writer.writeIdAttribute(clientId + UITree.MARKER);
- writer.writeAttribute(HtmlAttributes.VALUE, "", false);
- writer.endElement(HtmlConstants.INPUT);
-
- if (isSelectable(tree)) {
- writer.startElement(HtmlConstants.INPUT, tree);
- writer.writeAttribute(HtmlAttributes.TYPE, "hidden", false);
- writer.writeNameAttribute(clientId + UITree.SELECT_STATE);
- writer.writeIdAttribute(clientId + UITree.SELECT_STATE);
- writer.writeAttribute(HtmlAttributes.VALUE, ";", false);
- writer.endElement(HtmlConstants.INPUT);
- }
-
- String scriptTexts = createJavascript(facesContext);
-
- String treeScript = "script/tobago-tree.js";
- // todo: this may be removed, it is twice on the page 1. in the header 2. in the ScriptLoader
- List<String> scriptFiles = ComponentUtil.findPage(facesContext, tree).getScriptFiles();
- scriptFiles.add(treeScript);
-
- HtmlRendererUtil.writeScriptLoader(facesContext, new String[]{treeScript}, new String[]{scriptTexts});
-
- RenderUtil.encode(facesContext, root);
-
- writer.endElement(HtmlConstants.DIV);
- }
-
- private String createJavascript(FacesContext facesContext) throws IOException {
- StringBuilder sb = new StringBuilder();
-
- sb.append("{\n");
-
- sb.append(" var treeResourcesHelp = new Object();\n");
- for (String images : TREE_IMAGES) {
- sb.append(" treeResourcesHelp[\"");
- sb.append(images);
- sb.append("\"] = \"");
- sb.append(ResourceManagerUtil.getImageWithPath(facesContext, "image/" + images));
- sb.append("\";\n");
- }
- sb.append(" \n treeResourcesHelp.getImage = function (name) {\n");
- sb.append(" var result = this[name];\n");
- sb.append(" if (result) {\n");
- sb.append(" return result;\n");
- sb.append(" } else {\n");
- sb.append(" return \"");
- sb.append(ResourceManagerUtil.getImageWithPath(facesContext, "image/blank.gif"));
- sb.append("\";\n");
- sb.append(" }\n");
- sb.append(" };\n \n");
- sb.append("}");
- return sb.toString();
- }
- protected String getNodesAsJavascript(FacesContext facesContext, UITreeNode root) throws IOException {
- ResponseWriter writer = facesContext.getResponseWriter();
- StringWriter stringWriter = new StringWriter();
- facesContext.setResponseWriter(writer.cloneWithWriter(stringWriter));
- RenderUtil.encode(facesContext, root);
- facesContext.setResponseWriter(writer);
- return stringWriter.toString();
- }
+public class WizardRenderer extends LayoutableRendererBase {
- protected String nodeStateId(FacesContext facesContext, UITreeNode node) {
- // this must do the same as nodeStateId() in tree.js
- String clientId = node.getClientId(facesContext);
- int last = clientId.lastIndexOf(':') + 1;
- return clientId.substring(last);
- }
}
Copied: myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/taglib/sandbox/WizardTag.java (from r586044, myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/taglib/sandbox/TreeTag.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/taglib/sandbox/WizardTag.java?p2=myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/taglib/sandbox/WizardTag.java&p1=myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/taglib/sandbox/TreeTag.java&r1=586044&r2=587603&rev=587603&view=diff
==============================================================================
--- myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/taglib/sandbox/TreeTag.java (original)
+++ myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/taglib/sandbox/WizardTag.java Tue Oct 23 11:50:09 2007
@@ -17,131 +17,180 @@
* limitations under the License.
*/
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_MODE;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_REQUIRED;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SELECTABLE;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SHOW_ICONS;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SHOW_JUNCTIONS;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SHOW_ROOT;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SHOW_ROOT_JUNCTION;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_VALUE;
+import org.apache.commons.beanutils.PropertyUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import static org.apache.myfaces.tobago.TobagoConstants.FACET_LAYOUT;
import org.apache.myfaces.tobago.component.ComponentUtil;
-import org.apache.myfaces.tobago.component.UITree;
+import org.apache.myfaces.tobago.component.UIWizard;
+import org.apache.myfaces.tobago.model.Wizard;
+import org.apache.myfaces.tobago.taglib.component.ButtonTag;
+import org.apache.myfaces.tobago.taglib.component.CellTag;
+import org.apache.myfaces.tobago.taglib.component.GridLayoutTag;
+import org.apache.myfaces.tobago.taglib.component.IncludeTag;
+import org.apache.myfaces.tobago.taglib.component.PanelTag;
import org.apache.myfaces.tobago.taglib.component.TobagoTag;
+import org.apache.myfaces.tobago.util.VariableResolverUtil;
import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.webapp.FacetTag;
+import javax.servlet.jsp.JspException;
-public class TreeTag extends TobagoTag implements TreeTagDeclaration {
+public class WizardTag extends TobagoTag implements WizardTagDeclaration {
- private String value;
+ private static final Log LOG = LogFactory.getLog(WizardTag.class);
- private String showJunctions;
- private String showIcons;
- private String showRoot;
- private String showRootJunction;
+ private String controller;
- private String selectable;
-
- private String required;
-
- private String mode;
+ private PanelTag panelTag;
@Override
public String getComponentType() {
- return UITree.COMPONENT_TYPE;
+ return UIWizard.COMPONENT_TYPE;
}
@Override
protected void setProperties(UIComponent component) {
super.setProperties(component);
- ComponentUtil.setStringProperty(component, ATTR_VALUE, value);
+ // xxx
+ //ComponentUtil.setStringProperty(component, ATTR_CONTROLLER, controller);
+ ComponentUtil.setStringProperty(component, "controller", controller);
+ }
- ComponentUtil.setBooleanProperty(component, ATTR_SHOW_JUNCTIONS, showJunctions);
- ComponentUtil.setBooleanProperty(component, ATTR_SHOW_ICONS, showIcons);
- ComponentUtil.setBooleanProperty(component, ATTR_SHOW_ROOT, showRoot);
- ComponentUtil.setBooleanProperty(component, ATTR_SHOW_ROOT_JUNCTION, showRootJunction);
+ @Override
+ public int doStartTag() throws JspException {
- ComponentUtil.setStringProperty(component, ATTR_SELECTABLE, selectable);
+ panelTag = new PanelTag();
+ panelTag.setPageContext(pageContext);
+ panelTag.setParent(getParent());
+/* todo
+ if (rendered != null) {
+ panelTag.setRendered(rendered);
+ }
+*/
+ panelTag.doStartTag();
+
+ FacetTag facetTag = new FacetTag();
+ facetTag.setPageContext(pageContext);
+ facetTag.setName(FACET_LAYOUT);
+ facetTag.setParent(panelTag);
+ facetTag.doStartTag();
+
+ GridLayoutTag gridLayoutTag = new GridLayoutTag();
+ gridLayoutTag.setPageContext(pageContext);
+ gridLayoutTag.setColumns("*;fixed;fixed;fixed;fixed");
+ gridLayoutTag.setRows("*;fixed");
+ gridLayoutTag.setParent(facetTag);
+ gridLayoutTag.doStartTag();
+ gridLayoutTag.doEndTag();
+
+ facetTag.doEndTag();
+
+ {
+ CellTag cell = new CellTag();
+ cell.setPageContext(pageContext);
+ cell.setParent(panelTag);
+ cell.setSpanX("5");
+ cell.doStartTag();
+
+ {
+ Object bean = VariableResolverUtil.resolveVariable(FacesContext.getCurrentInstance(), "controller");
+ int index = 0;
+ try {
+ Wizard wizard = (Wizard) PropertyUtils.getProperty(bean, "wizard");
+ index = wizard.getIndex();
+ } catch (Exception e) {
+ LOG.error("", e);
+ }
+
+ if (index < 2) {
+ IncludeTag content = new IncludeTag();
+ content.setPageContext(pageContext);
+ content.setParent(cell);
+ content.setValue("snip-" + index + ".jsp");
+ content.doStartTag();
+ content.doEndTag();
+ } else {
+ PanelTag content = new PanelTag();
+ content.setPageContext(pageContext);
+ content.setParent(cell);
+ content.setBinding(controller.replace("}", ".currentComponent}"));
+ content.doStartTag();
+ content.doEndTag();
+ }
+ }
+
+ cell.doEndTag();
+ }
+
+ {
+ CellTag spacer = new CellTag();
+ spacer.setPageContext(pageContext);
+ spacer.setParent(panelTag);
+ spacer.doStartTag();
+ spacer.doEndTag();
+ }
+
+ {
+ ButtonTag start = new ButtonTag();
+ start.setPageContext(pageContext);
+ start.setParent(panelTag);
+ start.setLabel("Start");
+ start.setAction(controller.replace("}", ".start}"));
+ start.setDisabled(controller.replace("}", ".startAvailable}").replace("#{", "#{!"));
+ start.doStartTag();
+ start.doEndTag();
+ }
+
+ {
+ ButtonTag previous = new ButtonTag();
+ previous.setPageContext(pageContext);
+ previous.setParent(panelTag);
+ previous.setLabel("Previous");
+ previous.setAction(controller.replace("}", ".previous}"));
+ previous.setDisabled(controller.replace("}", ".previousAvailable}").replace("#{", "#{!"));
+ previous.doStartTag();
+ previous.doEndTag();
+ }
+
+ {
+ ButtonTag next = new ButtonTag();
+ next.setPageContext(pageContext);
+ next.setParent(panelTag);
+ next.setLabel("Next");
+ next.setAction(controller.replace("}", ".next}"));
+ next.setDisabled(controller.replace("}", ".nextAvailable}").replace("#{", "#{!"));
+ next.doStartTag();
+ next.doEndTag();
+ }
+
+ {
+ ButtonTag finish = new ButtonTag();
+ finish.setPageContext(pageContext);
+ finish.setParent(panelTag);
+ finish.setLabel("Finish");
+ finish.setAction(controller.replace("}", ".finish}"));
+ finish.setDisabled(controller.replace("}", ".finishAvailable}").replace("#{", "#{!"));
+ finish.doStartTag();
+ finish.doEndTag();
+ }
- ComponentUtil.setBooleanProperty(component, ATTR_REQUIRED, required);
- ComponentUtil.setStringProperty(component, ATTR_MODE, mode);
+ return super.doStartTag();
}
@Override
public void release() {
super.release();
- value = null;
- showJunctions = null;
- showIcons = null;
- showRoot = null;
- showRootJunction = null;
- selectable = null;
- required = null;
- mode = null;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public String getShowIcons() {
- return showIcons;
- }
-
- public void setShowIcons(String showIcons) {
- this.showIcons = showIcons;
- }
-
- public String getShowJunctions() {
- return showJunctions;
- }
-
- public void setShowJunctions(String showJunctions) {
- this.showJunctions = showJunctions;
- }
-
- public String getShowRoot() {
- return showRoot;
- }
-
- public void setShowRoot(String showRoot) {
- this.showRoot = showRoot;
- }
-
- public String getShowRootJunction() {
- return showRootJunction;
- }
-
- public void setShowRootJunction(String showRootJunction) {
- this.showRootJunction = showRootJunction;
- }
-
- public String getSelectable() {
- return selectable;
- }
-
- public void setSelectable(String selectable) {
- this.selectable = selectable;
- }
-
- public String getRequired() {
- return required;
- }
-
- public void setRequired(String required) {
- this.required = required;
+ controller = null;
}
- public String getMode() {
- return mode;
+ public String getController() {
+ return controller;
}
- public void setMode(String mode) {
- this.mode = mode;
+ public void setController(String controller) {
+ this.controller = controller;
}
-}
+}
\ No newline at end of file
Copied: myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/taglib/sandbox/WizardTagDeclaration.java (from r586044, myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/taglib/sandbox/TreeTagDeclaration.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/taglib/sandbox/WizardTagDeclaration.java?p2=myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/taglib/sandbox/WizardTagDeclaration.java&p1=myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/taglib/sandbox/TreeTagDeclaration.java&r1=586044&r2=587603&rev=587603&view=diff
==============================================================================
--- myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/taglib/sandbox/TreeTagDeclaration.java (original)
+++ myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/taglib/sandbox/WizardTagDeclaration.java Tue Oct 23 11:50:09 2007
@@ -22,68 +22,22 @@
import org.apache.myfaces.tobago.apt.annotation.TagAttribute;
import org.apache.myfaces.tobago.apt.annotation.UIComponentTag;
import org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute;
+import org.apache.myfaces.tobago.model.Wizard;
import org.apache.myfaces.tobago.taglib.component.TobagoTagDeclaration;
import org.apache.myfaces.tobago.taglib.decl.HasIdBindingAndRendered;
-import org.apache.myfaces.tobago.taglib.decl.HasTreeNodeValue;
-import org.apache.myfaces.tobago.taglib.decl.IsRequired;
/**
- * Renders a tree view.
- *
- * Date: 11.02.2006 13:28:14
+ * Renders a fexible Wizard.
*/
-@Tag(name = "tree")
-@BodyContentDescription(anyTagOf = "<tcs:treeNode>|<tcs:treeData>")
+@Tag(name = "wizard")
+@BodyContentDescription(anyTagOf = "facestag")
@UIComponentTag(
- uiComponent = "org.apache.myfaces.tobago.component.UITree",
- rendererType = "Tree")
-public interface TreeTagDeclaration
- extends TobagoTagDeclaration, HasIdBindingAndRendered, HasTreeNodeValue, IsRequired {
-
- /**
- * Flag indicating whether or not this component should be render selectable items.
- * Possible values are:
- * <ul>
- * <li><strong>multi</strong> : a multisection tree is rendered
- * <li><strong>single</strong> : a singlesection tree is rendered
- * <li><strong>multiLeafOnly</strong> : a multisection tree is rendered,
- * only Leaf's are selectable
- * <li><strong>singleLeafOnly</strong> : a singlesection tree is rendered,
- * only Leaf's are selectable
- * </ul>
- * For any other value or if this attribute is omited the items are not selectable.
- */
- @TagAttribute
- @UIComponentTagAttribute(defaultValue = "off",
- allowedValues = {"multi", "single", "multiLeafOnly", "singleLeafOnly", "off"})
- void setSelectable(String selectable);
-
- @TagAttribute
- @UIComponentTagAttribute(type = "java.lang.Boolean",
- defaultValue = "false")
- void setShowRootJunction(String showRootJunction);
-
- @TagAttribute
- @UIComponentTagAttribute(type = "java.lang.Boolean",
- defaultValue = "false")
- void setShowIcons(String showIcons);
-
- @TagAttribute
- @UIComponentTagAttribute(type = "java.lang.Boolean",
- defaultValue = "false")
- void setShowJunctions(String showJunctions);
-
- @TagAttribute
- @UIComponentTagAttribute(type = "java.lang.Boolean",
- defaultValue = "false")
- void setShowRoot(String showRoot);
-
- /**
- * Display option: Normal tree or menu.
- */
- @TagAttribute
- @UIComponentTagAttribute(defaultValue = "tree",
- allowedValues = {"tree", "menu"})
- void setMode(String mode);
-
+ uiComponent = "org.apache.myfaces.tobago.component.UIWizard",
+ rendererType = "Wizard")
+public interface WizardTagDeclaration
+ extends TobagoTagDeclaration, HasIdBindingAndRendered {
+
+ @TagAttribute(required = true, type= Wizard.class)
+ @UIComponentTagAttribute(type = "org.apache.myfaces.tobago.model.Wizard")
+ void setController(String controller);
}
Copied: myfaces/tobago/trunk/sandbox/src/main/resources/META-INF/wizard.xml (from r587462, myfaces/tobago/trunk/extension/facelets/src/main/resources/META-INF/time.xml)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/sandbox/src/main/resources/META-INF/wizard.xml?p2=myfaces/tobago/trunk/sandbox/src/main/resources/META-INF/wizard.xml&p1=myfaces/tobago/trunk/extension/facelets/src/main/resources/META-INF/time.xml&r1=587462&r2=587603&rev=587603&view=diff
==============================================================================
--- myfaces/tobago/trunk/extension/facelets/src/main/resources/META-INF/time.xml (original)
+++ myfaces/tobago/trunk/sandbox/src/main/resources/META-INF/wizard.xml Tue Oct 23 11:50:09 2007
@@ -16,35 +16,34 @@
* limitations under the License.
-->
-<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:c="http://java.sun.com/jstl/core"
- xmlns:tc="http://myfaces.apache.org/tobago/component" >
-
- <c:if test="${empty rendered}">
- <c:set var="rendered" value="true"/>
- </c:if>
- <c:if test="${empty labelWidth}">
- <c:set var="labelWidth" value="fixed"/>
- </c:if>
- <tc:panel rendered="${rendered}">
+<ui:composition xmlns:c="http://java.sun.com/jstl/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:tc="http://myfaces.apache.org/tobago/component"
+ xmlns:tfs="http://myfaces.apache.org/tobago/facelet-sandbox">
+
+ <tc:panel>
<f:facet name="layout">
- <tc:gridLayout columns="${labelWidth};*"/>
+ <tc:gridLayout columns="*;fixed;fixed;fixed;fixed" rows="*;fixed"/>
</f:facet>
- <tc:label value="${label}" for="@auto" tip="${tip}"/>
- <c:choose>
- <c:when test="${empty id}">
- <tc:time value="${value}" required="${required}"
- readonly="${readonly}" disabled="${disabled}" >
- <ui:insert/>
- </tc:time>
- </c:when>
- <c:when test="${not empty id}">
- <tc:time id="${id}" value="${value}" required="${required}"
- readonly="${readonly}" disabled="${disabled}" >
- <ui:insert/>
- </tc:time>
- </c:when>
- </c:choose>
+
+ <tc:cell spanX="5">
+
+ <c:if test="${controller.index lt 2}">
+ <ui:include src="/snip-${controller.index}.xml"/>
+ </c:if>
+ <c:if test="${! (controller.index lt 2)}">
+ <tfs:bean controller="${controller}"/>
+ </c:if>
+
+ </tc:cell>
+
+ <tc:cell/>
+ <tc:button action="${controller.start}" disabled="${! controller.startAvailable}" label="Start"/>
+ <tc:button action="${controller.previous}" disabled="${! controller.previousAvailable}" label="Previous"/>
+ <tc:button action="${controller.next}" disabled="${! controller.nextAvailable}" label="Next"/>
+ <tc:button action="${controller.finish}" disabled="${! controller.finishAvailable}" label="Finish"/>
+
</tc:panel>
+
</ui:composition>