Module: Muml_Class
- Defined in:
- lib/ontomde-uml2-struts/xmlForm.rb,
lib/ontomde-uml2-struts/footer.rb,
lib/ontomde-uml2-struts/footer.rb,
lib/ontomde-uml2-struts/header.rb,
lib/ontomde-uml2-struts/jsp_edit.rb,
lib/ontomde-uml2-struts/validation.rb,
lib/ontomde-uml2-struts/validation.rb,
lib/ontomde-uml2-struts/header_link.rb,
lib/ontomde-uml2-struts/jsp_edit_js.rb,
lib/ontomde-uml2-struts/struts-config.rb,
lib/ontomde-uml2-struts/struts-config.rb
Overview
xml form
adding methods to generate xml form for use by xml client such as Flex.
Constant Summary collapse
- STRUTS_SWITH_TO_FLEX_ACTION =
"switchToFlex"
- STRUTS_XMLFORM_HELPER =
name of the java class used to store helper methods for xml form generation.
"xmda.struts.XMLFormHelper"
- STRUTS_XML_FORM_PROPERTY =
example public StringBuffer getAsXML(StringBuffer sb) {
"xmlForm"
- STRUTS_XML_FORM_GETTER =
"getXmlForm"
- STRUTS_XML_VIEW_PREFIX =
"src."
- STRUTS_SWITCH_TO_FLEX_FORWARD =
"switchToFlexFwd"
- FLEX_SWITCH_TO_JSP_PATH =
"/flex/switchToFlex.jsp"
- NOGIF_FORWARD =
"NOGIF_FWD"
- STRUTS_EDIT_FWD_POSTFIX =
"_fwEdit"
Instance Method Summary collapse
-
#struts_addXmlFormField_row_type!(form, t) ⇒ Object
example: public void xmlForm_field_row_Roue(StringBuffer sb, Roue obj) {.
-
#struts_addXmlFormField_type!(form, t) ⇒ Object
Generate a xml serialization method.
- #struts_create_getXMLFormOperations!(form) ⇒ Object
-
#struts_defaultTabId ⇒ Object
return identifier of the default tab.
- #struts_edit_generate ⇒ Object
-
#struts_edit_writeBody ⇒ Object
name of the javascript openTab method used to switch to the requested tab.
- #struts_edit_writeFields ⇒ Object
- #struts_edit_writeForm ⇒ Object
- #struts_edit_writeHead(&block) ⇒ Object
- #struts_edit_writeHeader ⇒ Object
- #struts_edit_writeHTML(&block) ⇒ Object
- #struts_edit_writePage ⇒ Object
- #struts_edit_writePageXML(f) ⇒ Object
- #struts_edit_writeTitle ⇒ Object
- #struts_editForwardName ⇒ Object
- #struts_footer_generate ⇒ Object
-
#struts_formEncTypeAttribute ⇒ Object
form enctype attribute useful when form includes a field of type blob.
- #struts_formName ⇒ Object
- #struts_get_struts_config_action_mapping_actionTypeClause ⇒ Object
- #struts_getXMLFormHelper! ⇒ Object
- #struts_header_generate ⇒ Object
- #struts_header_link_generate ⇒ Object
-
#struts_jsp_edit_path ⇒ Object
Returns the internal where to generate file for this object.
-
#struts_jsp_row_path ⇒ Object
Returns the internal where to generate file for this object.
-
#struts_jsp_writeTabBar ⇒ Object
write tabs in JSP NOTE: CSS is design in such a way that active tab is the last one and its id is menuOptDivId0.
- #struts_jspEdit_generateJavascript ⇒ Object
- #struts_jspEdit_generateJavascript_commun ⇒ Object
- #struts_jspEdit_generateJavascript_edit_remove_add ⇒ Object
- #struts_jspEdit_generateJavascript_jspHeader ⇒ Object
- #struts_jspEdit_generateJavascript_operations ⇒ Object
- #struts_jspEdit_write_Operation ⇒ Object
- #struts_jspEditwriteSelfJSInclude ⇒ Object
- #struts_row_generate ⇒ Object
- #struts_validation_writeField(field) ⇒ Object
- #struts_validation_writeFields ⇒ Object
- #struts_write_struts_config_action_mapping ⇒ Object
- #struts_write_struts_config_form_bean ⇒ Object
- #struts_write_validation_config_formset ⇒ Object
Instance Method Details
#struts_addXmlFormField_row_type!(form, t) ⇒ Object
example: public void xmlForm_field_row_Roue(StringBuffer sb, Roue obj) {
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
# File 'lib/ontomde-uml2-struts/xmlForm.rb', line 239 def struts_addXmlFormField_row_type!(form,t) helper=struts_getXMLFormHelper!.java_Name m=form.umlx_createAndAddOperation("#{rdf_uri}_fft_#{t.java_Name}","xmlForm_field_row_#{t.java_Name}") p=m.umlx_createAndAddParameter("#{m.rdf_uri}_p1","sb") p.uml_type=umlx_getOrCreateClass("java.lang.StringBuffer") p=m.umlx_createAndAddParameter("#{m.rdf_uri}_p2","obj") p.uml_type=t code="" t.struts_formAttribute.each { |a| code=code+%{#{helper}.xmlForm_field(sb,"#{a.java_Name}",obj.get#{a.java_NameBean}());\n} } m.java_code=code end |
#struts_addXmlFormField_type!(form, t) ⇒ Object
Generate a xml serialization method. Example signature: public void xmlForm_field_type_Roue(StringBuffer sb, String label, String[] currentValue, List<Roue> suggestion) …
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
# File 'lib/ontomde-uml2-struts/xmlForm.rb', line 191 def struts_addXmlFormField_type!(form,t) m=form.umlx_createAndAddOperation("#{rdf_uri}_fft_#{t.java_Name}","xmlForm_field_type_#{t.java_Name}") p=m.umlx_createAndAddParameter("#{m.rdf_uri}_p1","sb") p.uml_type=umlx_getOrCreateClass("java.lang.StringBuffer") p=m.umlx_createAndAddParameter("#{m.rdf_uri}_p2","label") p.uml_type=umlx_dataType_string p=m.umlx_createAndAddParameter("#{m.rdf_uri}_p3","currentValueMany") p.uml_type=umlx_dataType_string #p.uml_isOrdered=RDF_TRUE #force collection type to Collection. p.uml_isUnique=RDF_FALSE p.uml_upperValue=umlx_literal(-1) p.java_use_Arrays=RDF_TRUE p=m.umlx_createAndAddParameter("#{m.rdf_uri}_p4","currentValueOne") p.uml_type=umlx_dataType_string #p.uml_upperValue=umlx_literal(-1) #p.java_use_Arrays=RDF_TRUE p=m.umlx_createAndAddParameter("#{m.rdf_uri}_p5","suggestion") p.uml_upperValue=umlx_literal(-1) p.uml_isOrdered=RDF_TRUE p.uml_type=t p=m.umlx_createAndAddParameter("#{m.rdf_uri}_p6","createSug") p.uml_upperValue=umlx_literal(-1) p.uml_isOrdered=RDF_TRUE p.uml_type=t.java_enumAssignableDataType_one helper=struts_getXMLFormHelper!.java_Name m.java_code=<<END #{helper}.xmlForm_field_head(sb, label, currentValueMany,currentValueOne); for (#{t.java_qualifiedName} item : suggestion) { if (#{helper}.xmlForm_field_sug_ifNull(sb,item)) { #{helper}.xmlFormSugOpen(sb,Long.toString(item.getId())); xmlForm_field_row_#{t.java_Name}(sb, item); #{helper}.xmlFormSugClose(sb); } } XMLFormHelper.xmlForm_field_create(sb,createSug); #{helper}.xmlForm_field_tail(sb, label); END end |
#struts_create_getXMLFormOperations!(form) ⇒ Object
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 |
# File 'lib/ontomde-uml2-struts/xmlForm.rb', line 258 def struts_create_getXMLFormOperations!(form) return unless context[:generateXMLStrutsForm,false] t=form helper=struts_getXMLFormHelper!.java_Name form.java_import_add(struts_getXMLFormHelper!.java_qualifiedName) form.java_import_add("org.apache.struts.util.LabelValueBean") m=form.umlx_createAndAddOperation("#{rdf_uri}_fft_#{t.java_Name}",STRUTS_XML_FORM_GETTER) #p=m.umlx_createAndAddParameter("#{m.rdf_uri}_p1","sb") #p.uml_type=umlx_getOrCreateClass("java.lang.StringBuffer") p=m.umlx_createAndAddReturnParameter("#{m.rdf_uri}_p2","obj") p.uml_type=m.umlx_owner_one.umlx_dataType_string code=<<END StringBuffer sb = new StringBuffer(); END usedTypes=Set.new self.struts_formAttribute.each { |a| next if a.uml_isReadOnly? if a.uml_type_one.kind_of?(Muml_Enumeration) code=code+%{#{helper}.xmlForm_field_type_Enum(sb, "#{a.java_Name}", get#{a.java_NameBean}(), get#{a.java_NameBean}Sug());\n} elsif a.uml_type_one.kind_of?(Muml_DataType) code=code+%{#{helper}.xmlForm_field_type_Lit(sb, "#{a.java_Name}", getReference().get#{a.java_NameBean}());\n} elsif a.umlx_manySide? code=code+%{xmlForm_field_type_#{a.uml_type_one.java_Name}(sb, "#{a.java_Name}", get#{a.java_NameBean}(),null, getReference().get#{a.java_NameBean}Sug(),#{ a.umlx_isComposite? ? "getReference().getCreateAndAdd#{a.java_NameBean}Sug()":"null"});\n} usedTypes.add(a.uml_type_one) else code=code+%{xmlForm_field_type_#{a.uml_type_one.java_Name}(sb, "#{a.java_Name}", null,get#{a.java_NameBean}(), getReference().get#{a.java_NameBean}Sug(),#{ a.umlx_isComposite? ? "getReference().getCreateAndAdd#{a.java_NameBean}Sug()":"null"});\n} usedTypes.add(a.uml_type_one) end } usedTypes.each { |t| struts_addXmlFormField_type!(form,t) struts_addXmlFormField_row_type!(form,t) } code=code+<<END //StrutsHelper.xmlForm_field_type_Lit(sb, "marque", getMarque()); //xmlForm_field_type_Roue(sb, "roues", getRoues(), getReference().getRouesSug()); //xmlForm_field_type_Moteur(sb, "moteur", getMoteur(), getReference().getMoteurSug()); END code=code+<<END return sb.toString(); END m.java_code=code end |
#struts_defaultTabId ⇒ Object
return identifier of the default tab
124 125 126 |
# File 'lib/ontomde-uml2-struts/jsp_edit.rb', line 124 def struts_defaultTabId return "all" end |
#struts_edit_generate ⇒ Object
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/ontomde-uml2-struts/jsp_edit.rb', line 155 def struts_edit_generate return if java_ignoreMe? #path=context[:jspEditMode] ? "form_item" : "view_item" struts_ownedTab.each { |i| label="#{i}" f=self.struts_actionForm_one mtk_context(:struts_tab => i ) { mtk_writeSession( %{#{context[:webContentDir]}/#{struts_jsp_edit_path}} ) { #log.debug { %{#{context[:webContentDir]}/{struts_jsp_edit_path}} } struts_edit_writeHeader before="" after="" if(context[:generateXMLStrutsForm]) before=%{<logic:notPresent parameter="FLEX">\n} after=%{</logic:notPresent>\n} end struts_encloseWrite(before,after) { mtk_context( :struts_curClass => self) { struts_edit_writePage }} before="" after="" if(context[:generateXMLStrutsForm]) before=%{<logic:present parameter="FLEX">\n} after=%{</logic:present>\n} end struts_encloseWrite(before,after) { struts_edit_writePageXML(f) } }}} end |
#struts_edit_writeBody ⇒ Object
name of the javascript openTab method used to switch to the requested tab.
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 |
# File 'lib/ontomde-uml2-struts/jsp_edit.rb', line 314 def struts_edit_writeBody mtk_context(:strutsActionName => "/#{java_Name}#{context[:struts_tab].java_Name}-submit" ) { struts_encloseWrite(%{<body >\n<html:form #{struts_formEncTypeAttribute} action="#{context[:strutsActionName]}">\n<center>},"</center>\n</html:form></body>\n") { if(context[:generateXMLStrutsForm]) write <<END <!-- DEBUG SWITCH --> <input type="checkbox" name="FLEX"/> END end struts_header_generate write <<END <%-- ********* CORPS DE PAGE ********** --%> <logic:messagesPresent> <div> <table class="tableForm"> <tr> <td class="attributeIcons"> <img src="#{css_path_model}/#{css_color_class}/image/btnWarning.gif" alt="" width="25" height="25" border="0" /> </td> <td> <h1> #{struts_writeMsg("errors.header")} </h1> </td> </tr> </table> <html:messages id="error"> <p class="attributeError"> <bean:write name="error"/> </p> </html:messages> </div> </logic:messagesPresent> END struts_jsp_writeTabBar write "<SCRIPT>\n" context[:struts_tab].struts_ownedAttribute.each { |a| next unless a.umlx_isComposite? #next if a.umlx_oneSide? f="createAndAdd#{a.java_NameBean}" write %{ function #{f}(reqType) { document.forms[0].#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}.value="#{f}"; document.forms[0].#{STRUTS_REQUESTED_CREATION_TYPE_FIELD_NAME}.value=reqType; document.forms[0].submit(); } } } write "<!-- THERE -->\n" write <<END_SCRIPT </SCRIPT> END_SCRIPT write <<END <div class="body"> <div class="bodyTop"/><div class="bodyContent"> END write <<END <h1>#{struts_writeMsg("#{java_qualifiedName}.title")}</h1> #{mtk_stss{struts_jspEdit_write_Operation}} END struts_edit_writeForm write <<END </div> <div class="bodyBottom"></div> END write <<END </div> END }} end |
#struts_edit_writeFields ⇒ Object
453 454 455 456 457 458 |
# File 'lib/ontomde-uml2-struts/jsp_edit.rb', line 453 def struts_edit_writeFields context[:struts_tab].struts_ownedAttribute.each { |a| next if a.uml_name_one=="id" a.struts_edit_writeFieldProp(self) } end |
#struts_edit_writeForm ⇒ Object
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 |
# File 'lib/ontomde-uml2-struts/jsp_edit.rb', line 400 def struts_edit_writeForm #<html:text property="xmda_action"/> struts_edit_writeFields write <<END <%-- ****** --%> <%-- SUBMIT --%> <%-- ****** --%> <div> <input type="hidden" name="#{STRUTS_REQUESTED_CREATION_TYPE_FIELD_NAME}"/> <html:hidden property="#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}"/> <input type="hidden" name="#{Muml_Class::STRUTS_REQUESTED_TAB}"/> <html:hidden property="#{Muml_Class::STRUTS_SGBD_STATE}"/> <SCRIPT>function sel(target) {document.forms[0].#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}.value=target;}</SCRIPT> </div><br/> <div class="boutons" align="right"> <%-- <html:submit styleClass="boutonForm" onclick="#{STRUTS_RETURN_ACTION}();return false;">#{struts_writeMsg("button.validate")}</html:submit> --%> <html:submit styleClass="boutonForm" onclick="#{STRUTS_PROCEED_ACTION}();return false;">#{struts_writeMsg("button.validate")}</html:submit> <%-- <html:submit onclick="sel('delete');" styleClass="boutonForm">#{struts_writeMsg("button.delete")}</html:submit> --%> <html:reset styleClass="boutonForm">#{struts_writeMsg("button.reset")}</html:reset> <%-- <html:cancel styleClass="boutonForm">#{struts_writeMsg("button.cancel")}</html:cancel> --%> </div> END end |
#struts_edit_writeHead(&block) ⇒ Object
258 259 260 261 262 |
# File 'lib/ontomde-uml2-struts/jsp_edit.rb', line 258 def struts_edit_writeHead(&block) write "<head>" yield write "</head>" end |
#struts_edit_writeHeader ⇒ Object
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/ontomde-uml2-struts/jsp_edit.rb', line 231 def struts_edit_writeHeader # encoding must be ISO8859-1 to avoid bug with forms and accentuated characters. write <<END <?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <%@ page contentType="text/html;charset=ISO8859-1" %> <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %> <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %> <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %> END if context[:jspUseXmdaTaglib] write <<END <%@ taglib uri="http://orange.fr/2007/xmda/struts-tags" prefix="xmda" %> <%@ taglib uri="http://displaytag.sf.net" prefix="display" %> <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%> END if context[:security] write <<END <%@ taglib uri="http://orange.fr/2007/xmda/struts-security-tags" prefix="xmdas" %> END end end end |
#struts_edit_writeHTML(&block) ⇒ Object
225 226 227 228 229 |
# File 'lib/ontomde-uml2-struts/jsp_edit.rb', line 225 def struts_edit_writeHTML(&block) write("<html:html><%-- T:1004 --%>") yield write("</html:html><%-- T:1004 --%>") end |
#struts_edit_writePage ⇒ Object
212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/ontomde-uml2-struts/jsp_edit.rb', line 212 def struts_edit_writePage struts_edit_writeHTML { struts_edit_writeHead { struts_jspEdit_generateJavascript struts_header_link_generate struts_jspEditwriteSelfJSInclude struts_edit_writeTitle } struts_edit_writeBody } end |
#struts_edit_writePageXML(f) ⇒ Object
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/ontomde-uml2-struts/jsp_edit.rb', line 191 def struts_edit_writePageXML(f) return unless context[:generateXMLStrutsForm] write( %{ <message> <meta> <html:link action="/#{java_Name}#{context[:struts_tab].java_Name}-submit"/> <timeout_ms><%= 3*60*60*1000 %></timeout_ms> <timezone><bean:write name="#{struts_actionForm_one.java_Name}" property="#{::Muml_Classifier::STRUTS_SETTIMEZONE_FIELD}"/></timezone> <sessionId><%=session.getId()%></sessionId> <view>#{STRUTS_XML_VIEW_PREFIX}#{java_qualifiedName}</view><logic:messagesPresent> <html:messages id="error"><errors> <error><bean:write name="error"/></error></html:messages> </errors> </logic:messagesPresent></meta> <form> <bean:write name="#{f.java_Name}" property="#{::Muml_Class::STRUTS_XML_FORM_PROPERTY}" filter="false" /> </form> </message> }) end |
#struts_edit_writeTitle ⇒ Object
264 265 266 |
# File 'lib/ontomde-uml2-struts/jsp_edit.rb', line 264 def struts_edit_writeTitle write %{<title>#{struts_writeMsg("#{self.java_qualifiedName}.title")}</title>} end |
#struts_editForwardName ⇒ Object
163 164 165 |
# File 'lib/ontomde-uml2-struts/struts-config.rb', line 163 def struts_editForwardName return "#{java_Name}#{STRUTS_EDIT_FWD_POSTFIX}" end |
#struts_footer_generate ⇒ Object
125 126 127 |
# File 'lib/ontomde-uml2-struts/footer.rb', line 125 def rdf_model. end |
#struts_formEncTypeAttribute ⇒ Object
form enctype attribute useful when form includes a field of type blob
307 308 309 310 |
# File 'lib/ontomde-uml2-struts/jsp_edit.rb', line 307 def struts_formEncTypeAttribute #TODO: add enctype *only* if form has a blob field return %{ enctype="multipart/form-data"} end |
#struts_formName ⇒ Object
3 4 5 |
# File 'lib/ontomde-uml2-struts/struts-config.rb', line 3 def struts_formName return "#{java_qualifiedName.tr('.','_')}" end |
#struts_get_struts_config_action_mapping_actionTypeClause ⇒ Object
176 177 178 179 180 181 182 |
# File 'lib/ontomde-uml2-struts/struts-config.rb', line 176 def struts_get_struts_config_action_mapping_actionTypeClause # if context[:struts_useSpring] # return %{type="defined in spring"} #else return %{type="#{struts_action_one.java_qualifiedName}"} #end end |
#struts_getXMLFormHelper! ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 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 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/ontomde-uml2-struts/xmlForm.rb', line 14 def struts_getXMLFormHelper! helper=umlx_getOrCreateClass(STRUTS_XMLFORM_HELPER) if(helper.java_customCode.empty?) helper.umlx_external=RDF_FALSE helper.java_import_add("org.apache.struts.util.LabelValueBean") helper.db_isTransient=RDF_TRUE helper.struts_isForm=RDF_FALSE helper.java_customCode= %{ public static void xmlForm_field(StringBuffer sb, String label, Object value) { //Default behavior is to call toString. //Customization should be coded in StrutsForm when using Struts. xmlForm_field(sb,label,value==null ? null : value.toString()); } //static java.text.SimpleDateFormat dfDate=new java.text.SimpleDateFormat("yyyy/MM/dd",java.util.Locale.ENGLISH); //static java.text.SimpleDateFormat dfTimestamp=new java.text.SimpleDateFormat("yyyy/MM/dd HH:mm:ss",java.util.Locale.ENGLISH); public static void xmlForm_field(StringBuffer sb, String label, java.util.Date value) { xmlForm_field(sb,label,value==null ? null : #{STRUTS_TIMESTAMP_FORMATER_INSTANCE}.format(value)); } public static void xmlForm_field(StringBuffer sb, String label, Enum<?> value) { xmlForm_field(sb,label,value==null ? null : value.getClass().getCanonicalName()+"."+value.toString()); } public static void xmlForm_field(StringBuffer sb, String label, int value) { xmlForm_field(sb,label,Integer.toString(value)); } public static void xmlForm_field(StringBuffer sb, String label, long value) { xmlForm_field(sb,label,Long.toString(value)); } public static void xmlForm_field(StringBuffer sb, String label, boolean value) { xmlForm_field(sb,label,Boolean.toString(value)); } public static void xmlForm_field(StringBuffer sb, String label, String value) { sb.append(" <v n=\\""); sb.append(label); sb.append("\\">"); sb.append(value==null ? "<nil/>" : value ); sb.append("</v>\\n"); } public static void xmlForm_field_type_Lit(StringBuffer sb, String label, byte[] currentValue) { //TODO } public static void xmlForm_field_type_Lit(StringBuffer sb, String label, String currentValue) { sb.append(" <f n=\\""); sb.append(label); sb.append("\\">"); sb.append(currentValue==null ? "<nil/>" :currentValue); sb.append("</f>\\n"); } public static void xmlForm_field_type_Lit(StringBuffer sb, String label, java.util.Date currentValue) { sb.append(" <f n=\\""); sb.append(label); sb.append("\\">"); sb.append(currentValue==null ? "<nil/>" : #{STRUTS_TIMESTAMP_FORMATER_INSTANCE}.format(currentValue)); sb.append("</f>\\n"); } public static void xmlForm_field_type_Lit(StringBuffer sb, String label, boolean currentValue) { sb.append(" <f n=\\""); sb.append(label); sb.append("\\">"); sb.append(currentValue ? "true" : "false"); sb.append("</f>\\n"); } public static void xmlForm_field_type_Lit(StringBuffer sb, String label, long currentValue) { sb.append(" <f n=\\""); sb.append(label); sb.append("\\">"); sb.append(currentValue); sb.append("</f>\\n"); } public static void xmlForm_field_type_Lit(StringBuffer sb, String label, int currentValue) { sb.append(" <f n=\\""); sb.append(label); sb.append("\\">"); sb.append(currentValue); sb.append("</f>\\n"); } public static boolean xmlForm_field_sug_ifNull(StringBuffer sb, Object item) { if (item == null) { sb.append(" <o k=\\"nill\\"/>\\n"); } return item != null; } public static void xmlForm_field_head(StringBuffer sb, String label, String currentValue) { sb.append(" <f n=\\""); sb.append(label); sb.append("\\" k=\\""); sb.append(currentValue); sb.append("\\">\\n"); } public static void xmlForm_field_head(StringBuffer sb, String label, String[] currentValueMany,String currentValueOne) { sb.append(" <f n=\\""); sb.append(label); sb.append("\\">\\n"); if (currentValueMany!=null) { for (int i = 0; i < currentValueMany.length; i++) { String s = currentValueMany[i]; sb.append(" <s>"); sb.append(s==null ? "<nil/>" : s); sb.append("</s>\\n"); } } if (currentValueOne!=null) { sb.append(" <s>"); sb.append(currentValueOne==null ? "<nil/>" : currentValueOne); sb.append("</s>\\n"); } } public static void xmlForm_field_tail(StringBuffer sb, String label) { sb.append(" </f>\\n"); } public static void xmlForm_field_type_Enum(StringBuffer sb, String label, String currentValue, java.util.List<LabelValueBean> suggestions) { xmlForm_field_head(sb, label, currentValue); for (LabelValueBean i : suggestions) { sb.append(" <o k=\\""); sb.append(i.getValue()); sb.append("\\">"); sb.append(i.getLabel()); sb.append("</o>\\n"); } xmlForm_field_tail(sb, label); } public static void xmlFormSugOpen(StringBuffer sb, String k) { sb.append(" <o k=\\""); sb.append(k); sb.append("\\">\\n"); } public static void xmlFormSugClose(StringBuffer sb) { sb.append(" </o>\\n"); } //generates list of valid types for createAndAdd operation public static void xmlForm_field_create(java.lang.StringBuffer sb,java.util.List<?> createSug){ if(createSug!=null) { for(Object itemObj : createSug) { #{::Muml_Classifier::JAVA_ENUM_INTERFACE_QNAME} item=(#{::Muml_Classifier::JAVA_ENUM_INTERFACE_QNAME})itemObj; int i=0; if(item!=null) { sb.append(" <c k=\\""); sb.append(item.name()); sb.append("\\">"); sb.append(item.getClass().getCanonicalName()); sb.append("."); sb.append(item.name()); sb.append("</c>\\n"); //} else { //i=i+1; //log.error("!!! null enum"+i); } } } } } end return helper end |
#struts_header_generate ⇒ Object
33 34 35 36 |
# File 'lib/ontomde-uml2-struts/header.rb', line 33 def struts_header_generate self.rdf_model.struts_header_generate; return end |
#struts_header_link_generate ⇒ Object
4 5 6 |
# File 'lib/ontomde-uml2-struts/header_link.rb', line 4 def struts_header_link_generate rdf_model.struts_header_link_generate(struts_jsp_edit_path.to_s) end |
#struts_jsp_edit_path ⇒ Object
Returns the internal where to generate file for this object.
129 130 131 132 |
# File 'lib/ontomde-uml2-struts/jsp_edit.rb', line 129 def struts_jsp_edit_path path="form" return "pages/#{java_InternalFilePath}/#{path}/#{java_Name}#{context[:struts_tab].java_Name}.jsp" end |
#struts_jsp_row_path ⇒ Object
Returns the internal where to generate file for this object.
134 135 136 137 |
# File 'lib/ontomde-uml2-struts/jsp_edit.rb', line 134 def struts_jsp_row_path path="form" return "pages/#{java_InternalFilePath}/#{path}/#{java_Name}-row.jsp" end |
#struts_jsp_writeTabBar ⇒ Object
write tabs in JSP NOTE: CSS is design in such a way that active tab is the last one and its id is menuOptDivId0
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 |
# File 'lib/ontomde-uml2-struts/jsp_edit.rb', line 272 def struts_jsp_writeTabBar return if struts_ownedTab.size <= 1 write %{<div class="menu" id="menuDivId">\n} cmpt =1; onglet_actif=context[:struts_tab] struts_ownedTab.each { |tab| id=tab.java_Name label="#{self.java_qualifiedName}.#{id}.tab" if tab==onglet_actif write %{\n<div class="menuOptnSelect" id="menuOptDivId0"> <div class="menuOptnSelectLink"><html:link onclick="#{STRUTS_REFRESH_ACTION}('#{id}');return false;" page="">#{struts_writeMsg(label)}</html:link></div> </div> \n} else if cmpt==1 write %{\n<div class="menuOptn" id="menuOptDivId#{id}" style="display:none;"> <div class="menuLink"><html:link onclick="#{STRUTS_REFRESH_ACTION}('#{id}');return false;" page="">#{struts_writeMsg(label)}</html:link></div> </div>} else write %{\n<div class="menuOptn" id="menuOptDivId#{id}"> <div class="menuLink"><html:link onclick="#{STRUTS_REFRESH_ACTION}('#{id}');return false;" page="">#{struts_writeMsg(label)}</html:link></div> </div>} end cmpt=cmpt+1; end } write %{</div>\n} end |
#struts_jspEdit_generateJavascript ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/ontomde-uml2-struts/jsp_edit_js.rb', line 7 def struts_jspEdit_generateJavascript js_include=context[:mtk_fileName].gsub(/\.[^\/]*$/,".js.jsp") mtk_writeSession("#{js_include}") { struts_jspEdit_generateJavascript_jspHeader #write("<SCRIPT>\n") struts_jspEdit_generateJavascript_commun struts_jspEdit_generateJavascript_operations struts_jspEdit_generateJavascript_edit_remove_add #write "</SCRIPT>\n" } end |
#struts_jspEdit_generateJavascript_commun ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/ontomde-uml2-struts/jsp_edit_js.rb', line 41 def struts_jspEdit_generateJavascript_commun write <<END_SCRIPT function #{STRUTS_REFRESH_ACTION}(tabid) { document.forms[0].#{Muml_Class::STRUTS_REQUESTED_TAB}.value=tabid; document.forms[0].#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}.value="#{STRUTS_REFRESH_ACTION}"; document.forms[0].submit(); } function #{STRUTS_RETURN_ACTION}() { document.forms[0].#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}.value="#{STRUTS_RETURN_ACTION}"; document.forms[0].submit(); } function #{STRUTS_PROCEED_ACTION}() { document.forms[0].#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}.value="#{STRUTS_PROCEED_ACTION}"; document.forms[0].submit(); } function transformToServerFormat(date, field, locale) { var time = date.getTime() var date2 = new Date(time); return date2.print("%Y/%m/%d %H:%M:%S", locale); } function hide_sel(id){ var s = document.getElementsByTagName('select'); var len = s.length; for (i = 0; i<len; i++){ s[i].style.visibility = 'hidden'; } document.getElementById(id).style.visibility = 'visible'; } function show_sel(id){ var s = document.getElementsByTagName('select'); var len = s.length; for (i = 0; i<len; i++){ s[i].style.visibility = 'visible'; } document.getElementById(id).style.visibility = 'hidden'; } END_SCRIPT end |
#struts_jspEdit_generateJavascript_edit_remove_add ⇒ Object
85 86 87 88 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 114 115 116 117 118 119 120 121 122 |
# File 'lib/ontomde-uml2-struts/jsp_edit_js.rb', line 85 def struts_jspEdit_generateJavascript_edit_remove_add context[:struts_tab].struts_ownedAttribute.each { |a| #next unless a.umlx_isComposite? #next unless a.umlx_isAssociation? #next if a.umlx_oneSide? ["edit","add"].each {|meth| f="#{meth}#{a.java_NameBean}" write <<END function #{f}(objid) { if("_"+objid != "_empty") { document.forms[0].#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}.value="#{f}"; document.forms[0].#{Muml_Class::STRUTS_REQUESTED_TAB}.value=objid; document.forms[0].submit(); } else { alert("no element selected for \\n#{struts_writeMsg("#{self.java_qualifiedName}.#{a.java_Name}")}"); } } END } write <<END function removeAndDelete#{a.java_NameBean}(objid) { if (window.confirm('<bean:message key="userMessage.deleteItem"/>')) { if("_"+objid != "_empty") { document.forms[0].#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}.value="removeAndDelete#{a.java_NameBean}"; document.forms[0].#{Muml_Class::STRUTS_REQUESTED_TAB}.value=objid; document.forms[0].submit(); } else { alert("no element selected for \\n#{struts_writeMsg("#{self.java_qualifiedName}.#{a.java_Name}")}"); } } } END } end |
#struts_jspEdit_generateJavascript_jspHeader ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/ontomde-uml2-struts/jsp_edit_js.rb', line 19 def struts_jspEdit_generateJavascript_jspHeader write <<END <%@ page contentType="text/javascript;charset=UTF-8" %> <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %> <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %> <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %> END end |
#struts_jspEdit_generateJavascript_operations ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ontomde-uml2-struts/jsp_edit_js.rb', line 28 def struts_jspEdit_generateJavascript_operations umlx_ownedAndInheritedOperation.each {|biz| next unless biz.umlx_businessMethod? f=biz.java_Name write(%{ function #{f}() { document.forms[0].#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}.value="#{f}"; document.forms[0].submit(); } }) } end |
#struts_jspEdit_write_Operation ⇒ Object
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 |
# File 'lib/ontomde-uml2-struts/jsp_edit.rb', line 426 def struts_jspEdit_write_Operation uml_ownedOperation.each {|biz| next unless biz.uml_visibility_one.isPublic? next unless biz.umlx_businessMethod? next if biz.struts_bizOperationReverse.empty? #TODO:recuperer le nom MPC par navigation! #<html:form action="/#{self.java_Name}#{biz.java_Name}MPC-new.do"> #<html:id> #<html:submit name="[#{biz.uml_name}]"/> #</html:form> # write %{ # <a href="" onclick="#{biz.java_Name}();return false;"> # [#{biz.java_Name}] # </a> # } write %{ <html:submit styleClass="boutonForm" onclick="#{biz.java_Name}();return false;">#{struts_writeMsg("#{biz.umlx_owner_one.java_qualifiedName}.#{biz.java_Name}")}</html:submit> } } end |
#struts_jspEditwriteSelfJSInclude ⇒ Object
3 4 5 6 |
# File 'lib/ontomde-uml2-struts/jsp_edit_js.rb', line 3 def struts_jspEditwriteSelfJSInclude js_include=struts_jsp_edit_path.gsub(/\.[^\/]*$/,".js.jsp") write(%{<script language="Javascript" src="#{js_include}" ></script>\n}) end |
#struts_row_generate ⇒ Object
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/ontomde-uml2-struts/jsp_edit.rb', line 139 def struts_row_generate mtk_writeSession( %{#{context[:webContentDir]}/#{struts_jsp_row_path}} ) { mtk_context( :struts_curClass => self) { struts_edit_writeHeader write("<%-- TPL:2 BEGIN --%>\n<tr>") struts_formAttribute.each { |a| next if a.uml_name_one=="id" write("<%-- UML PROPERTY: #{a.uml_name}--%>\n") write("<td>"); write("</td>"); } write("</tr>\n<%-- TPL:2 END --%>\n") } } end |
#struts_validation_writeField(field) ⇒ Object
108 109 110 |
# File 'lib/ontomde-uml2-struts/validation.rb', line 108 def struts_validation_writeField(field) write "<!-- TODO -->" end |
#struts_validation_writeFields ⇒ Object
51 52 53 54 55 |
# File 'lib/ontomde-uml2-struts/validation.rb', line 51 def struts_validation_writeFields struts_formAttribute.each { |a| a.struts_validation_writeField } end |
#struts_write_struts_config_action_mapping ⇒ Object
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
# File 'lib/ontomde-uml2-struts/struts-config.rb', line 186 def struts_write_struts_config_action_mapping return if struts_action.empty? fwd="" struts_ownedTab.each{ |tab| idOnglet=tab.java_Name_one fwd=fwd+%{\n <forward name="#{idOnglet}" path="/pages/#{java_InternalFilePath}form/#{java_Name}#{idOnglet}.jsp" />} } mtk_protected { write <<END <action path="/#{java_Name}-new" #{struts_get_struts_config_action_mapping_actionTypeClause} name="#{self.struts_actionForm_one.java_Name}" scope="session" validate="false" cancellable="true" parameter="#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}" input="/pages/#{java_InternalFilePath}form/#{java_Name}#{struts_defaultTabId}.jsp" >#{fwd} <forward name="cancel" path="/Welcome.do" /> <forward name="#{STRUTS_INPUT_FWD}" path="/pages/#{java_InternalFilePath}form/#{java_Name}#{struts_defaultTabId}.jsp"/> </action> END struts_ownedTab.each{ |tab| idOnglet=tab.java_Name_one #struts_tabs.each{|idOnglet| write <<END <action path="/#{java_Name}#{idOnglet}-submit" #{struts_get_struts_config_action_mapping_actionTypeClause} name="#{self.struts_actionForm_one.java_Name}" scope="session" validate="true" cancellable="true" parameter="#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}" input="/pages/#{java_InternalFilePath}form/#{java_Name}#{idOnglet}.jsp" >#{fwd} <forward name="cancel" path="/Welcome.do" /> <forward name="#{STRUTS_INPUT_FWD}" path="/pages/#{java_InternalFilePath}form/#{java_Name}#{idOnglet}.jsp"/> </action> END } } end |
#struts_write_struts_config_form_bean ⇒ Object
166 167 168 169 170 171 172 173 |
# File 'lib/ontomde-uml2-struts/struts-config.rb', line 166 def struts_write_struts_config_form_bean return if struts_actionForm.empty? write <<END <form-bean name="#{self.struts_actionForm_one.java_uniqueName}" type="#{struts_actionForm_one.java_qualifiedName}"/> END #<!-- set-property property="example" value="EXAMPLE"/ --> end |
#struts_write_validation_config_formset ⇒ Object
44 45 46 47 48 49 |
# File 'lib/ontomde-uml2-struts/validation.rb', line 44 def struts_write_validation_config_formset return if struts_actionForm.empty? write %{<form name="#{self.struts_actionForm_one.java_uniqueName}">\n} struts_validation_writeFields write %{</form>\n} end |