Class: JavaMappingTimeStamp

Inherits:
JavaMapping show all
Defined in:
lib/ontomde-uml2-struts/jsp_edit.rb,
lib/ontomde-uml2-struts/mappingForJsp.rb,
lib/ontomde-uml2-struts/mappingForBean.rb

Instance Method Summary collapse

Methods inherited from JavaMapping

#addActionFieldMethod!, #getFormType, #java_Name, #java_helper_addMethods!, #java_helper_customCode, #java_qualifiedName, #rdf_uri, #struts_generateHelper

Instance Method Details

#getFormCopyTo(field) ⇒ Object



89
90
91
92
93
94
95
96
97
98
# File 'lib/ontomde-uml2-struts/mappingForBean.rb', line 89

def getFormCopyTo(field)
  return %{
      if(get#{field.java_NameBean}().length()>0) { try {
          java.util.Date local=#{::Muml_Classifier::STRUTS_TIMESTAMP_FORMATER_INSTANCE}.parse(get#{field.java_NameBean}());
  java.util.Date gmt = xmda.struts.FormHelper.transformFromCurrentTZToGMT(currentTimeZone, local);
  // the date is saved in the GMT timeZone
  _to.set#{field.java_NameBean}(gmt);
  } catch(java.text.ParseException e) { log.error(e);}/*TPL:9006b*/\n
  }}
end

#getFormInitFrom(field) ⇒ Object



100
101
102
# File 'lib/ontomde-uml2-struts/mappingForBean.rb', line 100

def getFormInitFrom(field)
  return "this.set#{field.java_NameBean}(_from.get#{field.java_NameBean}()==null?null:#{::Muml_Classifier::STRUTS_TIMESTAMP_FORMATER_INSTANCE}.format(xmda.struts.FormHelper.transformFromGMTToCurrentTZ(currentTimeZone,_from.get#{field.java_NameBean}())));\n"
end

#getJSP(datatype, field, owner) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/ontomde-uml2-struts/mappingForJsp.rb', line 89

def getJSP(datatype,field,owner)
  n="string"
  #TODO: provide nicer html template
  #xmda:dateText isCalendar defaults to "false"
  return <<END
 <xmda:dateText property="#{field.java_Name}" size="20%" maxlength="30" styleId="#{field.java_Name}Id" #{::Muml_DataType::STRUTS_ERROR_STYLE}/>
 <script type="text/javascript">
  function formatDate(cal) {
      var date = cal.date;
      var field = document.getElementById("#{field.java_Name}");
      var locale = document.getElementById("#{field.java_Name}Locale").value;
      field.value = transformToServerFormat(date, field, locale);

  }
Calendar.setup(\{
 inputField     :    "#{field.java_Name}Id",   // id of the input field
 localeField	  :	   "#{field.java_Name}Locale", //field containing locale (hidden)
 showsTime      :    true,
 timeFormat     :    "24",
 onUpdate       :    formatDate
\});
 </script>
END

end

#struts_edit_writeFieldGeneric_DisplayTable_displayTag_column(prop) ⇒ Object



844
845
846
847
848
# File 'lib/ontomde-uml2-struts/jsp_edit.rb', line 844

def struts_edit_writeFieldGeneric_DisplayTable_displayTag_column(prop)
  #Note: Because Calendar and TimeStamp share the same java type (java.util.Date)
  #      the decorator cannot detect which is which.
  prop.write %{<display:column property="#{prop.java_Name}" titleKey="#{prop.umlx_owner_one.java_qualifiedName}.#{prop.java_Name}" decorator="xmda.displayTag.extensions.I18nColumnDecorator" />\n}
end