QeelwaEtech / omnifaces

Automatically exported from code.google.com/p/omnifaces
0 stars 1 forks source link

A small addition to ImportConstants #175

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Because of some design decisions in a project we are working on, some of the 
constant fields are not final. So these fields could not be accessed via 
ImportConstants. If you can add an option to include non-final string fields 
etc. then it would be great i think. 

some thing like this should work:

<o:ImportConstants type="some.class.Name" isIncludeNonFinalFields="true" />

Original issue reported on code.google.com by fma...@gmail.com on 12 May 2013 at 1:15

GoogleCodeExporter commented 9 years ago
I'm not sure. We do not want to encourage poor designs. 

What exactly is the reason they aren't final?

Original comment by balusc on 15 May 2013 at 1:56

GoogleCodeExporter commented 9 years ago
I can think of 3 different use cases for such a change:

1) Some of the constants are initialized at servlet context listener. (to some 
value read from DB at that time.) but after then it is used just like any other 
constant. 

2) final constants are replaced when compiled, but sometimes you need to change 
a constant and expect referencing classes/JARs see the update without a full 
compile.

3) I may just need to reference a static field in a class. not necessarily a 
constant. maybe a logger or smt like that?

(ps: i already altered my copy of the source and did this change. But I feel 
like this may be useful to others as well, that is why I opened this issue)

Original comment by fma...@gmail.com on 15 May 2013 at 6:23

GoogleCodeExporter commented 9 years ago
1) such a listener gives you already the opportunity to set a Map<K,V> of those 
values in application scope by event.getServletContext().setAttribute("data", 
data)

2) makes maybe sense, I'd however have used a mutable reference

3) wouldn't recommend this, it tight-couples controller with view

Original comment by balusc on 26 Jun 2013 at 2:41

GoogleCodeExporter commented 9 years ago
Closing off as "WontFix". Introducing this would enable potential abuse and 
tight-couple model/controller too much with view (like as Scriptlets ever 
somewhat unintentionally did). There are better ways.

Original comment by balusc on 9 Aug 2013 at 3:41