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 2016/09/15 16:11:28 UTC
svn commit: r1760954 - in
/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main:
java/org/apache/myfaces/tobago/example/demo/SheetController.java
webapp/content/20-component/080-sheet/80-editable/sheet-editable.xhtml
Author: lofwyr
Date: Thu Sep 15 16:11:28 2016
New Revision: 1760954
URL: http://svn.apache.org/viewvc?rev=1760954&view=rev
Log:
TOBAGO 1544: Demo
* editable date field in sheet
Modified:
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/SheetController.java
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/080-sheet/80-editable/sheet-editable.xhtml
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/SheetController.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/SheetController.java?rev=1760954&r1=1760953&r2=1760954&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/SheetController.java (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/SheetController.java Thu Sep 15 16:11:28 2016
@@ -27,10 +27,16 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.enterprise.context.SessionScoped;
+import javax.faces.component.UIComponent;
import javax.faces.component.UIData;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.DateTimeConverter;
import javax.faces.event.ActionEvent;
import javax.inject.Named;
import java.io.Serializable;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
import java.util.List;
@SessionScoped
@@ -113,4 +119,29 @@ public class SheetController implements
public int getColumnEventSample() {
return columnEventSample;
}
+
+ public javax.faces.convert.Converter getYearConverter() {
+
+ final DateTimeConverter dateTimeConverter = new DateTimeConverter() {
+
+ @Override
+ public Object getAsObject(FacesContext facesContext, UIComponent uiComponent, String value) {
+ final Date date = (Date) super.getAsObject(facesContext, uiComponent, value);
+ final Calendar calendar = GregorianCalendar.getInstance(facesContext.getViewRoot().getLocale());
+ calendar.setTime(date);
+ return calendar.get(Calendar.YEAR);
+ }
+
+ @Override
+ public String getAsString(FacesContext facesContext, UIComponent uiComponent, Object value) {
+ final Calendar calendar = GregorianCalendar.getInstance(facesContext.getViewRoot().getLocale());
+ calendar.set(Calendar.YEAR, (Integer) value);
+ final Date date = calendar.getTime();
+ return super.getAsString(facesContext, uiComponent, date);
+ }
+ };
+
+ dateTimeConverter.setPattern("yyyy");
+ return dateTimeConverter;
+ }
}
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/080-sheet/80-editable/sheet-editable.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/080-sheet/80-editable/sheet-editable.xhtml?rev=1760954&r1=1760953&r2=1760954&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/080-sheet/80-editable/sheet-editable.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/080-sheet/80-editable/sheet-editable.xhtml Thu Sep 15 16:11:28 2016
@@ -33,13 +33,9 @@
<tc:column label="Distance">
<tc:in value="#{object.distance}"/>
</tc:column>
-<!-- XXX discoverYear year doesn't work, because the java.util.Date conflicts with java.lang.Interger
<tc:column label="discoverYear">
- <tc:date value="#{solarobject.discoverYear}">
- <f:convertDateTime pattern="yyyy"/>
- </tc:date>
+ <tc:date value="#{object.discoverYear}" converter="#{sheetController.yearConverter}"/>
</tc:column>
--->
</tc:sheet>
<tc:button label="Submit"/>
</tc:section>