You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2007/11/18 12:12:32 UTC

svn commit: r596080 - in /myfaces/tobago/trunk/example/test/src/main: java/org/apache/myfaces/tobago/example/test/SessionController.java webapp/selectOneChoice.jsp

Author: bommel
Date: Sun Nov 18 03:12:31 2007
New Revision: 596080

URL: http://svn.apache.org/viewvc?rev=596080&view=rev
Log:
selectOneChoice date example

Added:
    myfaces/tobago/trunk/example/test/src/main/webapp/selectOneChoice.jsp   (with props)
Modified:
    myfaces/tobago/trunk/example/test/src/main/java/org/apache/myfaces/tobago/example/test/SessionController.java

Modified: myfaces/tobago/trunk/example/test/src/main/java/org/apache/myfaces/tobago/example/test/SessionController.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/test/src/main/java/org/apache/myfaces/tobago/example/test/SessionController.java?rev=596080&r1=596079&r2=596080&view=diff
==============================================================================
--- myfaces/tobago/trunk/example/test/src/main/java/org/apache/myfaces/tobago/example/test/SessionController.java (original)
+++ myfaces/tobago/trunk/example/test/src/main/java/org/apache/myfaces/tobago/example/test/SessionController.java Sun Nov 18 03:12:31 2007
@@ -20,14 +20,24 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.tobago.component.UIData;
 import org.apache.myfaces.tobago.event.TabChangeListener;
+import org.apache.myfaces.tobago.model.SelectItem;
 
 import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIParameter;
 import javax.faces.context.FacesContext;
+import javax.faces.event.ActionEvent;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.Arrays;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
+import java.util.Locale;
+import java.util.TimeZone;
 
 public class SessionController {
 
@@ -43,6 +53,8 @@
 
   private String value;
 
+  private Date date;
+
   private Date validityStart;
   private Date validityEnd;
 
@@ -68,6 +80,43 @@
 
     public void setInput(String input) {
       this.input = input;
+    }
+  }
+
+  public Date getDate() {
+    return date;
+  }
+
+  public void setDate(Date date) {
+    this.date = date;
+  }
+
+  public SelectItem[] getDateItems() {
+    SelectItem[] items = new SelectItem[2];
+    DateFormat format = DateFormat.getDateInstance(SimpleDateFormat.SHORT, Locale.GERMANY);
+    format.setTimeZone(TimeZone.getTimeZone("GMT"));
+    try {
+      Date date = format.parse("12.10.2009");
+      items[0] = new SelectItem(date);
+      date = format.parse("13.10.2009");
+      items[1] = new SelectItem(date);
+    } catch (ParseException e) {
+      LOG.error("", e);
+    }
+    return items;
+  }
+
+  public void actionListener(ActionEvent e) {
+    UIComponent component = e.getComponent();
+    for (UIComponent child : (List<UIComponent>)component.getChildren()) {
+      if (child instanceof UIParameter) {
+        LOG.error(((UIParameter) child).getValue());
+      }
+    }
+    while ((component = component.getParent()) != null) {
+      if (component instanceof UIData) {
+        LOG.error(((UIData)component).getRowIndex());
+      }
     }
   }
 

Added: myfaces/tobago/trunk/example/test/src/main/webapp/selectOneChoice.jsp
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/test/src/main/webapp/selectOneChoice.jsp?rev=596080&view=auto
==============================================================================
--- myfaces/tobago/trunk/example/test/src/main/webapp/selectOneChoice.jsp (added)
+++ myfaces/tobago/trunk/example/test/src/main/webapp/selectOneChoice.jsp Sun Nov 18 03:12:31 2007
@@ -0,0 +1,41 @@
+<%--
+ * 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/component" prefix="tc" %>
+<%@ taglib uri="http://myfaces.apache.org/tobago/extension" prefix="tx" %>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<f:view>
+  <tc:page >
+    <tc:panel id="panel">
+      <f:facet name="layout">
+        <tc:gridLayout margin="10px" rows="fixed;fixed;1*" columns="fixed;fixed;*"/>
+      </f:facet>
+      <tc:selectOneChoice value="#{controller.date}" >
+        <f:selectItems value="#{controller.dateItems}"/>
+      </tc:selectOneChoice>
+      <tc:in value="#{controller.date}" readonly="true" />
+      <tc:cell/>
+      <tc:button label="Submit"/>
+      <tc:cell/>
+      <tc:cell/>
+      <tc:messages/>
+      <tc:cell/>
+      <tc:cell/>
+    </tc:panel>
+  </tc:page>
+</f:view>
\ No newline at end of file

Propchange: myfaces/tobago/trunk/example/test/src/main/webapp/selectOneChoice.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tobago/trunk/example/test/src/main/webapp/selectOneChoice.jsp
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL