We are building a Struts 2 component. Yay!
We're going to use several programming languages for that. Yay! Wait, what?!
Here is a tiny snippet from a much larger (and cryptic looking code calendar component) we had to develop:
1 <td class="dateDMHM">
2 <@s.textfield id="${parameters.name}.hour"
3 name="${parameters.name}.hour"
4 onfocus="if(this.value=='hh')this.value=''"
5 onblur="if(this.value=='')this.value='hh'"
6 onchange="setChecked('true', '${parameters.id}_true')"/>
7 </td>
8 <td class="dateText">.</td>
9 <td class="dateDMHM">
10 <@s.textfield id="${parameters.name}.minute"
11 name="${parameters.name}.minute"
12 onfocus="if(this.value=='mm')this.value=''"
13 onblur="if(this.value=='')this.value='mm'"
14 onchange="setChecked('true', '${parameters.id}_true')"/>
15 </td>
2 <@s.textfield id="${parameters.name}.hour"
3 name="${parameters.name}.hour"
4 onfocus="if(this.value=='hh')this.value=''"
5 onblur="if(this.value=='')this.value='hh'"
6 onchange="setChecked('true', '${parameters.id}_true')"/>
7 </td>
8 <td class="dateText">.</td>
9 <td class="dateDMHM">
10 <@s.textfield id="${parameters.name}.minute"
11 name="${parameters.name}.minute"
12 onfocus="if(this.value=='mm')this.value=''"
13 onblur="if(this.value=='')this.value='mm'"
14 onchange="setChecked('true', '${parameters.id}_true')"/>
15 </td>
Can you tell how many languages are being used in this freemarker (1) from a Struts2 application snippet of code?
td - plain HTML (2)
class="dateDMHM" - with CSS (3)
@s.textfield - struts2 tags (4) available in the freemarker, offered transparently by struts2 engine
onfocus="..." - JavaScript (5)
even if it looks innocent, that id="${parameters.name}.minute" is actually an OGNL expression (6).
This component is being used as a result in a JSP file (7) from an action implemented in Java (8).
Even if we can say that we can ignore HTML, CSS and JavaScript since they are ubiquitous, we still have 5 languages to master in order to build one application.
Compare this with a normal JSF (+xhtml) stack that brings you 2 new languages: JSF and Java.
Don't get me wrong I do believe that struts2 is a decent framework, but in the languages area I think it's a bit too much.
Note: I could say 3 languages on JSF's part: JSF, Java and EL, but I would have to add EL as also being available in JSP, thus 9 languages for the Struts2.
Note 2: I know we can completely remove JSP from the picture, and use freemarker templates directly, but I doubt that would be a "normal" Struts2 application stack.
b.m
ciplogic
0 comentarii:
Post a Comment