Wednesday, December 21, 2011

Dynamically load header message in column

In backing bean I have List vrsteAktivnosti and based on kratica property in my object I want to build header so it can easily be internationalized. Plus add sufix '_kratica' to property.
If for example kratica resolves to KR in my resource bundle I have key KR_kratica.

<ui:param name="kratica_3" value="#{aktivnostBean.vrsteAktivnosti.get(3).kratica}_kratica" />
<p:column headerText="#{msg[kratica_3]}">
...

Some expression language basics:
  • msg.someKey will look at message bundle for someKey
  • msg['someKey'] will look at message bundle for someKey
  • msg[someKey] will look at params to resolve property someKey
  • msg[aktivnostBean.vrsteAktivnosti.get(3).kratica] will look at objects property kratica and then look at msg bundle
  • msg[aktivnostBean.vrsteAktivnosti.get(3).kratica_kratica] will look at objects property kratica_kratica which does not exist, so use ui:param

Tuesday, December 13, 2011

Eclipse preferences

  1. Hot deploy on Tomcat - when you make changes to class it should be asap visible in Tomcat (JRebel would like that :)
    • Create Launch Configuration under Tomcat - Launch (Preferences), Debug is checked
    • This is working only on web project, not projects included in it
  2. General - check Show heap status
  3. General - Workspace - set Text file encoding
  4. General - Editors- Text Editors - Show line nubers
  5. Run/Debug - Console - uncheck Limit console output
  6. modify start shortcut: 
    • "C:\MyEclipse\myeclipseforspring.exe" -data D:\Workspace\Play -vmargs -Xmx768m -XX:MaxPermSize=384m -XX:ReservedCodeCacheSize=64m
  7. add latest Subclipse
  8. add bin and target folders to global svn ignore list
    • Windows - Preferences - Team - Ignored Resources - Add Pattern
    • enter bin then target then m2-target
  9. remove antivirus scan from workspace and eclipse installation directory
  10. add -showlocation as first line in eclipse.ini to show workspace location in title bar
Find resource in specific folder?
Open resource (Ctrl + Shift + R) - find start.jsp in msgbox subfolder:
*/msgbox/start.jsp

How to tell eclipse where is my java located?
Edit eclipse.ini file add line before -vmargs:
-vm (new line needed :)
C:\Java\jdk1.6.0\jre\bin\javaw.exe

How to change @author default field in Javadoc?
Edit eclipse.ini file, add line
-Duser.name=My name

Missing deployment assembly even if Dynamic Web Module is added as project facet
Add
 <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
to your .project file.

Quick Search
CTRL+SHIFT+L
https://marketplace.eclipse.org/content/quick-search-eclipse
https://spring.io/blog/2013/07/11/eclipse-quick-search/

Add decompiler
http://jadclipse.sourceforge.net/wiki/index.php/Main_Page
http://www.mkyong.com/java/java-decompiler-plugin-for-eclipse/

Ref:
http://wiki.eclipse.org/Eclipse.ini
What are the best JVM settings for Eclipse?
https://dzone.com/articles/show-workspace-location-title


TOMCAT - JVM parameters:
-Xms256m -Xmx1024m 
-XX:PermSize=64m -XX:MaxPermSize=512m
-Dorg.apache.el.parser.COERCE_TO_ZERO=false
-Dsun.jnu.encoding=UTF-8 
-Dfile.encoding=UTF-8


JVM params explained

-Xms<size>              set initial Java heap size
-Xmx<size>              set maximum Java heap size
-XX:PermSize<size>  set initial PermGen Size
-XX:MaxPermSize<size>  set the maximum PermGen Size
https://www.mkyong.com/java/find-out-your-java-heap-memory-size/