Class: JavaMappingCalendar

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



106
107
108
# File 'lib/ontomde-uml2-struts/mappingForBean.rb', line 106

def getFormCopyTo(field)
  return "if(get#{field.java_NameBean}().length()>0){try {_to.set#{field.java_NameBean}(#{::Muml_Classifier::STRUTS_DATE_FORMATER_INSTANCE}.parse(get#{field.java_NameBean}()));\n} catch(java.text.ParseException e) {log.error(e);}}/*TPL:9006a*/\n"
end

#getFormInitFrom(field) ⇒ Object



110
111
112
# File 'lib/ontomde-uml2-struts/mappingForBean.rb', line 110

def getFormInitFrom(field)
  return "this.set#{field.java_NameBean}(_from.get#{field.java_NameBean}()==null?null:#{::Muml_Classifier::STRUTS_DATE_FORMATER_INSTANCE}.format(_from.get#{field.java_NameBean}()));\n"
end

#getJSP(datatype, field, owner) ⇒ Object



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/ontomde-uml2-struts/mappingForJsp.rb', line 117

def getJSP(datatype,field,owner)
  n="string"
  #TODO: provide nicer html template
  #isCalendar="true"
  return <<END
 <xmda:dateText isCalendar="true" property="#{field.java_Name}" size="20%" maxlength="#{self.maxStringLength}" 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)
 onUpdate       :    formatDate
\});
 </script>
END
end

#struts_edit_writeFieldGeneric_DisplayTable_displayTag_column(prop) ⇒ Object



835
836
837
838
839
840
# File 'lib/ontomde-uml2-struts/jsp_edit.rb', line 835

def struts_edit_writeFieldGeneric_DisplayTable_displayTag_column(prop)
  #TODO: on ne passe pas ici
  #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.I18nCalendarColumnDecorator" />\n}
end