com.wewebu.ow.server.app
Class OwEditablePropertyDate

java.lang.Object
  extended by com.wewebu.ow.server.app.OwEditablePropertyString
      extended by com.wewebu.ow.server.app.OwEditablePropertyDate
All Implemented Interfaces:
OwEditableProperty

public class OwEditablePropertyDate
extends OwEditablePropertyString

Base class for a single editable date property used in HTML forms.
You can either instantiate a control and use the render and setValue, getValue methods
or alternatively
use the control only with the static methods insertEditHTML and updateField without a instance.

Alfresco Workdesk
Copyright (c) Alfresco Software, Inc.
All rights reserved.

For licensing information read the license.txt file or
go to: http://wiki.alfresco.com


Field Summary
protected  OwMainAppContext m_context
          reference to the app context
protected  String m_sDateFormatString
          string to use to format the date
static int TYPE_DATE
          ENUM for the behavior, only date is shown
static int TYPE_EMPTY_DATE_POSSIBLE
          ENUM for the behavior, the date value can be left empty
static int TYPE_TIME
          ENUM for the behavior, only time is shown
 
Fields inherited from class com.wewebu.ow.server.app.OwEditablePropertyString
m_strError, m_value
 
Constructor Summary
OwEditablePropertyDate(OwMainAppContext context_p)
          construct a date property with context, use default date format
OwEditablePropertyDate(OwMainAppContext context_p, String sDateFormat_p)
          construct a date property with context
OwEditablePropertyDate(OwMainAppContext context_p, String sDateFormat_p, boolean ignoreTime)
           
 
Method Summary
static String convertDateFormat(String javaSimpleDateFormat_p)
          Java and ExtJS use different date format markup strings.
protected  Object getValueFromRequest(Locale locale_p, javax.servlet.http.HttpServletRequest request_p, String strID_p)
          overridable to apply changes on a submitted form
static void insertEditHTML(OwMainAppContext context_p, Locale locale_p, Writer w_p, Date date_p, String strID_p, boolean fUseJS_Control_p, boolean fEmptyDataPossible_p, String sDateFormat_p)
          render the date control with all sub controls
static void insertEditHTML(OwMainAppContext context_p, Locale locale_p, Writer w_p, Date date_p, String strID_p, boolean fUseJS_Control_p, boolean fEmptyDataPossible_p, String sDateFormat_p, String timeFormat)
          render the date control with all sub controls
static void insertJSControl(OwMainAppContext context_p, Locale locale_p, Writer w_p, Date date_p, String strID_p, boolean fEmptyDataPossible_p, String sDateFormat_p)
          Renders the JavaScript version of this control.
static void insertNonJSControl(OwMainAppContext context_p, Locale locale_p, Writer w_p, Date date_p, String strID_p, boolean fEmptyDataPossible_p, String timerFormat)
          Renders the Non Javascript version of the DateTime control.
static boolean isPhpSpecialChar(char testChar_p)
          Check if the character has a meaning as a PHP date format pattern.
 void render(Locale locale_p, Writer w_p)
          overridable to insert a single value into a edit HTML form
static Date updateField(Locale locale_p, javax.servlet.http.HttpServletRequest request_p, String strID_p, boolean fUseJS_Control_p, Date oldDate_p, boolean fEmptyDataPossible_p, String sDateFormat_p)
          update the date variable
static Date updateField(Locale locale_p, javax.servlet.http.HttpServletRequest request_p, String strID_p, boolean fUseJS_Control_p, Date oldDate_p, boolean fEmptyDataPossible_p, String sDateFormat_p, String timeFormatString)
           
 
Methods inherited from class com.wewebu.ow.server.app.OwEditablePropertyString
getFormElementID, getSafePropertyError, getValue, render, setValue, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_DATE

public static final int TYPE_DATE
ENUM for the behavior, only date is shown

See Also:
Constant Field Values

TYPE_TIME

public static final int TYPE_TIME
ENUM for the behavior, only time is shown

See Also:
Constant Field Values

TYPE_EMPTY_DATE_POSSIBLE

public static final int TYPE_EMPTY_DATE_POSSIBLE
ENUM for the behavior, the date value can be left empty

See Also:
Constant Field Values

m_context

protected OwMainAppContext m_context
reference to the app context


m_sDateFormatString

protected String m_sDateFormatString
string to use to format the date

Constructor Detail

OwEditablePropertyDate

public OwEditablePropertyDate(OwMainAppContext context_p)
construct a date property with context, use default date format

Parameters:
context_p - OwMainAppContext

OwEditablePropertyDate

public OwEditablePropertyDate(OwMainAppContext context_p,
                              String sDateFormat_p)
construct a date property with context

Parameters:
sDateFormat_p - String with date format e.g.: dd.MM.yyyy HH:mm
context_p - OwMainAppContext

OwEditablePropertyDate

public OwEditablePropertyDate(OwMainAppContext context_p,
                              String sDateFormat_p,
                              boolean ignoreTime)
Parameters:
context_p -
sDateFormat_p -
ignoreTime -
Since:
4.0.0.0
Method Detail

insertEditHTML

public static void insertEditHTML(OwMainAppContext context_p,
                                  Locale locale_p,
                                  Writer w_p,
                                  Date date_p,
                                  String strID_p,
                                  boolean fUseJS_Control_p,
                                  boolean fEmptyDataPossible_p,
                                  String sDateFormat_p)
                           throws Exception
render the date control with all sub controls

Parameters:
w_p - Writer object to write HTML to
date_p - Date to display
strID_p - Id for the form element
fEmptyDataPossible_p - true = date can be null
sDateFormat_p - String with date format e.g.: dd.MM.yyyy HH:mm
Throws:
Exception

insertEditHTML

public static void insertEditHTML(OwMainAppContext context_p,
                                  Locale locale_p,
                                  Writer w_p,
                                  Date date_p,
                                  String strID_p,
                                  boolean fUseJS_Control_p,
                                  boolean fEmptyDataPossible_p,
                                  String sDateFormat_p,
                                  String timeFormat)
                           throws Exception
render the date control with all sub controls

Parameters:
w_p - Writer object to write HTML to
date_p - Date to display
strID_p - Id for the form element
fEmptyDataPossible_p - true = date can be null
sDateFormat_p - String with date format e.g.: dd.MM.yyyy HH:mm
timeFormat - String format for time. E.g. HH:mm. If null, the time field will be ignored.
Throws:
Exception
Since:
4.0.0.0

insertJSControl

public static void insertJSControl(OwMainAppContext context_p,
                                   Locale locale_p,
                                   Writer w_p,
                                   Date date_p,
                                   String strID_p,
                                   boolean fEmptyDataPossible_p,
                                   String sDateFormat_p)
                            throws IOException,
                                   Exception
Renders the JavaScript version of this control.

Parameters:
context_p -
locale_p -
w_p -
date_p -
strID_p -
fEmptyDataPossible_p -
sDateFormat_p -
Throws:
IOException
Exception
Since:
4.0.0.0

insertNonJSControl

public static void insertNonJSControl(OwMainAppContext context_p,
                                      Locale locale_p,
                                      Writer w_p,
                                      Date date_p,
                                      String strID_p,
                                      boolean fEmptyDataPossible_p,
                                      String timerFormat)
                               throws IOException,
                                      Exception
Renders the Non Javascript version of the DateTime control.

Parameters:
context_p -
locale_p -
w_p -
date_p -
fEmptyDataPossible_p -
timerFormat - the time format to use for the time field. If null, the time part will be ignored.
Throws:
IOException
Exception
Since:
4.0.0.0

convertDateFormat

public static String convertDateFormat(String javaSimpleDateFormat_p)
Java and ExtJS use different date format markup strings. This method converts the Java date format into the date format used by ExtJS (PHP). ExtJS uses the PHP date format. See source/util/Date.js.

Parameters:
javaSimpleDateFormat_p - String to search and replace
Returns:
String

isPhpSpecialChar

public static boolean isPhpSpecialChar(char testChar_p)
Check if the character has a meaning as a PHP date format pattern. If so, it must be escaped in the PHP date format string.

Parameters:
testChar_p - char character to test
Returns:
boolean

updateField

public static Date updateField(Locale locale_p,
                               javax.servlet.http.HttpServletRequest request_p,
                               String strID_p,
                               boolean fUseJS_Control_p,
                               Date oldDate_p,
                               boolean fEmptyDataPossible_p,
                               String sDateFormat_p)
                        throws Exception
update the date variable

Parameters:
request_p - HttpServletRequest
strID_p - Id for the form element
oldDate_p - old date
fEmptyDataPossible_p - true = date can be null
sDateFormat_p - String with date format e.g.: dd.MM.yyyy HH:mm
Throws:
Exception

updateField

public static Date updateField(Locale locale_p,
                               javax.servlet.http.HttpServletRequest request_p,
                               String strID_p,
                               boolean fUseJS_Control_p,
                               Date oldDate_p,
                               boolean fEmptyDataPossible_p,
                               String sDateFormat_p,
                               String timeFormatString)
                        throws Exception
Parameters:
locale_p -
request_p -
strID_p -
fUseJS_Control_p -
oldDate_p -
fEmptyDataPossible_p -
sDateFormat_p -
timeFormatString - has to match the one used in the call to insertEditHTML(OwMainAppContext, Locale, Writer, Date, String, boolean, boolean, String, String).
Throws:
Exception

render

public void render(Locale locale_p,
                   Writer w_p)
            throws Exception
overridable to insert a single value into a edit HTML form

Parameters:
w_p - Writer to write HTML code to
Throws:
Exception

getValueFromRequest

protected Object getValueFromRequest(Locale locale_p,
                                     javax.servlet.http.HttpServletRequest request_p,
                                     String strID_p)
                              throws Exception
overridable to apply changes on a submitted form

Overrides:
getValueFromRequest in class OwEditablePropertyString
Parameters:
request_p - HttpServletRequest with form data to update the property
strID_p - String the HTML form element id of the requested value
Throws:
Exception


Copyright © 2013 Alfresco Business Solutions. All Rights Reserved.