tag:blogger.com,1999:blog-6224113160800598452024-02-06T21:21:14.848-08:00explore lifeSathishhttp://www.blogger.com/profile/13077114304120944836noreply@blogger.comBlogger16125tag:blogger.com,1999:blog-622411316080059845.post-5633107782853509462012-12-07T08:44:00.000-08:002012-12-07T08:44:39.913-08:00Cool Feature of Java 6- JSR 223 & JSR 199<br />
<div class="MsoNormal">
<b><span style="color: #1f497d; font-family: "Arial","sans-serif";">JSR
223- Scripting for the Java Platform<o:p></o:p></span></b></div>
<div class="MsoNormal">
<b><span style="color: #1f497d; font-family: "Arial","sans-serif";"><br /></span></b></div>
<div class="MsoNormal">
<span style="color: #1f497d; font-family: "Times New Roman","serif"; font-size: 12.0pt;">
</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">Java
introduced the support for scripting languages for java platform from Java- 6. <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><br /></span></div>
<div class="MsoListParagraph" style="mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-indent: -.25in;">
</div>
<ol>
<li><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%; text-indent: -0.25in;"><span style="font-family: 'Times New Roman'; font-size: 7pt; line-height: normal;"> </span></span><b style="text-indent: -0.25in;"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">JSR
223 - Scripting for the Java Platform</span></b><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%; text-indent: -0.25in;"> helps developers
integrate the standard java code with the scripting language by a standard
framework and API. </span><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%; text-indent: -0.25in;">With
this API we can</span></li>
</ol>
<ol start="2" type="1">
<ol start="1" type="a">
<li class="MsoNormal"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">Access
and control Java objects from a scripting environment<o:p></o:p></span></li>
<li class="MsoNormal"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">Create
web content with scripting languages<o:p></o:p></span></li>
<li class="MsoNormal"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">Embed
scripting environments within Java based applications</span></li>
</ol>
<li><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%; text-indent: -0.25in;">Java
6 by default ships Javascript Engine Implementation called Rhino provided by
the Mozilla</span></li>
<li><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%; text-indent: -0.25in;">New
scripting engines that compliance JSR 223 can be plugged in to avail the
feature. So now the Python, Ruby scripting advantages can also be availed.</span></li>
<li><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%; text-indent: -0.25in;"><span style="font-family: 'Times New Roman'; font-size: 7pt; line-height: normal;"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%; text-indent: -0.25in;">With
this new API, now the power of scripting can be availed from the java.</span></li>
</ol>
<div class="MsoListParagraph" style="mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-indent: -.25in;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"><br /></span></div>
<div class="MsoNormal">
<b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">Example: </span></b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">In the below
piece of code, a javascript function called printName(name) is evaluated from
java and the argument is passed is the java object.<o:p></o:p></span></div>
<div class="MsoNormal">
<b><span style="color: #7f0055; font-family: "Courier New"; font-size: 10.0pt;">public</span></b><span style="font-family: 'Courier New'; font-size: 10pt;"> </span><b><span style="color: #7f0055; font-family: "Courier New"; font-size: 10.0pt;">static</span></b><span style="font-family: 'Courier New'; font-size: 10pt;"> </span><b><span style="color: #7f0055; font-family: "Courier New"; font-size: 10.0pt;">void</span></b><span style="font-family: 'Courier New'; font-size: 10pt;"> main(String[]
args) {</span><span style="font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: 'Courier New'; font-size: 10pt;">
</span><span style="color: #3f7f5f; font-family: "Courier New"; font-size: 10.0pt;">//
create Script-Engine-Manager object</span><span style="font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: 'Courier New'; font-size: 10pt;">
ScriptEngineManager factory = </span><b><span style="color: #7f0055; font-family: "Courier New"; font-size: 10.0pt;">new</span></b><span style="font-family: 'Courier New'; font-size: 10pt;"> ScriptEngineManager();</span><span style="font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: 'Courier New'; font-size: 10pt;">
</span><span style="color: #3f7f5f; font-family: "Courier New"; font-size: 10.0pt;">//
Get Script Engine from factory</span><span style="font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: 'Courier New'; font-size: 10pt;">
ScriptEngine engine = factory.getEngineByName(</span><span style="color: #2a00ff; font-family: "Courier New"; font-size: 10.0pt;">"js"</span><span style="font-family: 'Courier New'; font-size: 10pt;">);</span><span style="font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: 'Courier New'; font-size: 10pt;">
</span><span style="color: #3f7f5f; font-family: "Courier New"; font-size: 10.0pt;">//
Create binding variable to pass value to script</span><span style="font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: 'Courier New'; font-size: 10pt;">
Bindings <span style="background: yellow; mso-highlight: yellow;">bindings</span> =
engine.createBindings();</span><span style="font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: 'Courier New'; font-size: 10pt;">
<span style="background: silver; mso-highlight: silver;">bindings</span>.put(</span><span style="color: #2a00ff; font-family: "Courier New"; font-size: 10.0pt;">"name"</span><span style="font-family: 'Courier New'; font-size: 10pt;">, </span><span style="color: #2a00ff; font-family: "Courier New"; font-size: 10.0pt;">"JAS Technologies"</span><span style="font-family: 'Courier New'; font-size: 10pt;">);</span><span style="font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: 'Courier New'; font-size: 10pt;">
</span><span style="color: #3f7f5f; font-family: "Courier New"; font-size: 10.0pt;">//
evaluate JavaScript code from String</span><span style="font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: 'Courier New'; font-size: 10pt;">
</span><b><span style="color: #7f0055; font-family: "Courier New"; font-size: 10.0pt;">try</span></b><span style="font-family: 'Courier New'; font-size: 10pt;"> {</span><span style="font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: 'Courier New'; font-size: 10pt;">
engine.eval(</span><span style="color: #2a00ff; font-family: "Courier New"; font-size: 10.0pt;">"printName(name);"</span><span style="font-family: 'Courier New'; font-size: 10pt;"> +</span><span style="font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: 'Courier New'; font-size: 10pt;">
</span><span style="color: #2a00ff; font-family: "Courier New"; font-size: 10.0pt;">"function printName(name){"</span><span style="font-family: 'Courier New'; font-size: 10pt;"> + </span><span style="font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: 'Courier New'; font-size: 10pt;">
</span><span style="color: #2a00ff; font-family: "Courier New"; font-size: 10.0pt;">"print(name+' company');"</span><span style="font-family: 'Courier New'; font-size: 10pt;"> +</span><span style="font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: 'Courier New'; font-size: 10pt;">
</span><span style="color: #2a00ff; font-family: "Courier New"; font-size: 10.0pt;">"};"</span><span style="font-family: 'Courier New'; font-size: 10pt;">, </span><span style="font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: 'Courier New'; font-size: 10pt;">
<span style="background: silver; mso-highlight: silver;">bindings</span>);</span><span style="font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: 'Courier New'; font-size: 10pt;">
} </span><b><span style="color: #7f0055; font-family: "Courier New"; font-size: 10.0pt;">catch</span></b><span style="font-family: 'Courier New'; font-size: 10pt;">
(ScriptException e) {</span><span style="font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: 'Courier New'; font-size: 10pt;">
e.printStackTrace();</span><span style="font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: 'Courier New'; font-size: 10pt;">
}</span><span style="font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: 'Courier New'; font-size: 10pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: 'Courier New'; font-size: 10pt;"><br /></span></div>
<div class="MsoNormal">
<span style="font-family: 'Courier New'; font-size: 10pt;"><br /></span></div>
<div class="MsoNormal">
</div>
<div class="MsoNormal">
<b><span style="color: #1f497d; font-family: "Arial","sans-serif";"><br /></span></b></div>
<div class="MsoNormal">
<b><span style="color: #1f497d; font-family: "Arial","sans-serif";">JSR
199 – java Compiler API<o:p></o:p></span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoListParagraphCxSpFirst" style="margin-bottom: 6.0pt; margin-left: .5in; margin-right: 0in; margin-top: 6.0pt; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]-->1.<span style="font-size: 7pt;"> </span><!--[endif]-->One
of the cool features introduced in java 6 is to compile the java source file
dynamically. </div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: 6.0pt; margin-left: .5in; margin-right: 0in; margin-top: 6.0pt; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]-->2.<span style="font-size: 7pt;"> </span><!--[endif]-->As
a part of JSR 199-Java<sup><span style="font-size: 7.5pt; line-height: 115%;">TM</span></sup>
Compiler API, there is a standard java Compiler API which defines the
interfaces for java compiler functions and a standard service provider
framework by which vendor can provide implementation for the interfaces.</div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: 6.0pt; margin-left: .5in; margin-right: 0in; margin-top: 6.0pt; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]-->3.<span style="font-size: 7pt;"> </span><!--[endif]-->The
API for compilation is now available part of <b>javax.tool</b> package and
ships with Java 6</div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: 6.0pt; margin-left: .5in; margin-right: 0in; margin-top: 6.0pt; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]-->4.<span style="font-size: 7pt;"> </span><!--[endif]-->So
having said above what a developer can do with this is</div>
<div class="MsoListParagraphCxSpMiddle" style="margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -.25in;">
<!--[if !supportLists]-->a.<span style="font-size: 7pt;">
</span><!--[endif]-->Dynamically compile java source file</div>
<div class="MsoListParagraphCxSpMiddle" style="margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -.25in;">
<!--[if !supportLists]-->b.<span style="font-size: 7pt;">
</span><!--[endif]-->Can compile multiple files</div>
<div class="MsoListParagraphCxSpMiddle" style="margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -.25in;">
<!--[if !supportLists]-->c.<span style="font-size: 7pt;">
</span><!--[endif]-->Can compile a java source from a string object</div>
<div class="MsoListParagraphCxSpLast" style="margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -.25in;">
<!--[if !supportLists]-->d.<span style="font-size: 7pt;">
</span><!--[endif]-->Also several advanced options are also available.
Check the API for complete details.</div>
<div class="MsoNormal">
Below is the small example for compiling the java
source file dynamically</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: 'Courier New'; font-size: 10pt;"> </span><b><span style="color: #7f0055; font-family: "Courier New"; font-size: 10.0pt;">public</span></b><span style="font-family: 'Courier New'; font-size: 10pt;"> </span><b><span style="color: #7f0055; font-family: "Courier New"; font-size: 10.0pt;">static</span></b><span style="font-family: 'Courier New'; font-size: 10pt;"> </span><b><span style="color: #7f0055; font-family: "Courier New"; font-size: 10.0pt;">void</span></b><span style="font-family: 'Courier New'; font-size: 10pt;"> main(String[]
args) {</span><span style="font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: 'Courier New'; font-size: 10pt;">
</span><span style="color: #3f7f5f; font-family: "Courier New"; font-size: 10.0pt;">//File
to be compiled</span><span style="font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: 'Courier New'; font-size: 10pt;">
String fileName = </span><span style="color: #2a00ff; font-family: "Courier New"; font-size: 10.0pt;">"D:/jas/workspace/com/test/compile/CompileMe.java"</span><span style="font-family: 'Courier New'; font-size: 10pt;">;</span><span style="font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: 'Courier New'; font-size: 10pt;">
</span><span style="color: #3f7f5f; font-family: "Courier New"; font-size: 10.0pt;">//Get
the java compiler</span><span style="font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: 'Courier New'; font-size: 10pt;">
JavaCompiler javaCompiler = ToolProvider.<i>getSystemJavaCompiler</i>();</span><span style="font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: 'Courier New'; font-size: 10pt;">
</span><span style="color: #3f7f5f; font-family: "Courier New"; font-size: 10.0pt;">//Compile
the java file. Look at the API to find more on options</span><span style="font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: 'Courier New'; font-size: 10pt;">
</span><b><span style="color: #7f0055; font-family: "Courier New"; font-size: 10.0pt;">int</span></b><span style="font-family: 'Courier New'; font-size: 10pt;"> returnVal =
javaCompiler.run(</span><b><span style="color: #7f0055; font-family: "Courier New"; font-size: 10.0pt;">null</span></b><span style="font-family: 'Courier New'; font-size: 10pt;">, </span><b><span style="color: #7f0055; font-family: "Courier New"; font-size: 10.0pt;">null</span></b><span style="font-family: 'Courier New'; font-size: 10pt;">, </span><b><span style="color: #7f0055; font-family: "Courier New"; font-size: 10.0pt;">null</span></b><span style="font-family: 'Courier New'; font-size: 10pt;">, fileName);</span><span style="font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: 'Courier New'; font-size: 10pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="font-family: 'Courier New'; font-size: 10pt;"> Content from CompileMe.java used in the above example<o:p></o:p></span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal" style="margin-left: .5in; text-autospace: none;">
<b><span style="color: #7f0055; font-family: "Courier New"; font-size: 10.0pt;">package</span></b><span style="font-family: 'Courier New'; font-size: 10pt;"> <u>com.test.compile</u>;</span><span style="font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: .5in; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="margin-left: .5in; text-autospace: none;">
<b><span style="color: #7f0055; font-family: "Courier New"; font-size: 10.0pt;">public</span></b><span style="font-family: 'Courier New'; font-size: 10pt;"> </span><b><span style="color: #7f0055; font-family: "Courier New"; font-size: 10.0pt;">class</span></b><span style="font-family: 'Courier New'; font-size: 10pt;"> CompileMe {</span><span style="font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: .5in; text-autospace: none;">
<span style="font-family: 'Courier New'; font-size: 10pt;">
</span><b><span style="color: #7f0055; font-family: "Courier New"; font-size: 10.0pt;">public</span></b><span style="font-family: 'Courier New'; font-size: 10pt;"> </span><b><span style="color: #7f0055; font-family: "Courier New"; font-size: 10.0pt;">static</span></b><span style="font-family: 'Courier New'; font-size: 10pt;"> </span><b><span style="color: #7f0055; font-family: "Courier New"; font-size: 10.0pt;">void</span></b><span style="font-family: 'Courier New'; font-size: 10pt;"> main(String[]
args) {</span><span style="font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: .5in; text-autospace: none;">
<span style="font-family: 'Courier New'; font-size: 10pt;">
System.</span><i><span style="color: #0000c0; font-family: "Courier New"; font-size: 10.0pt;">out</span></i><span style="font-family: 'Courier New'; font-size: 10pt;">.println(</span><span style="color: #2a00ff; font-family: "Courier New"; font-size: 10.0pt;">"The JAS Technologies"</span><span style="font-family: 'Courier New'; font-size: 10pt;">);</span><span style="font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: .5in; text-autospace: none;">
<span style="font-family: 'Courier New'; font-size: 10pt;">
}</span><span style="font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: .5in;">
<span style="font-family: 'Courier New'; font-size: 10pt;">}</span><b><span style="color: #1f497d;"><o:p></o:p></span></b></div>
<br />
Sathishhttp://www.blogger.com/profile/13077114304120944836noreply@blogger.com0tag:blogger.com,1999:blog-622411316080059845.post-11657569037788057842012-12-07T08:28:00.001-08:002012-12-07T08:29:41.525-08:00Brief on JVM Heap Memory<br />
<div class="MsoNormal" style="margin-left: .25in;">
let’s take a look at how the JVM
organizes memory into different areas. This has been helping several garbage
collection algorithms and memory management to work efficiently. These areas
are called Generations which are categorized based on the life of the objects.</div>
<div class="MsoNormal" style="margin-left: .25in;">
<br /></div>
<div class="MsoListParagraph" style="mso-list: l0 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]-->1.<span style="font-size: 7pt;">
</span><!--[endif]-->There are separate pools that hold objects of
different age. They are</div>
<div class="MsoListParagraphCxSpMiddle" style="margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -.25in;">
<!--[if !supportLists]-->a.<span style="font-size: 7pt;">
</span><!--[endif]-->Young Generation</div>
<div class="MsoListParagraphCxSpMiddle" style="margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -.25in;">
<!--[if !supportLists]-->b.<span style="font-size: 7pt;">
</span><!--[endif]-->Old Generation</div>
<div class="MsoListParagraphCxSpMiddle" style="margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -.25in;">
<!--[if !supportLists]-->c.<span style="font-size: 7pt;">
</span><!--[endif]-->Permanent Generation</div>
<div class="MsoListParagraphCxSpMiddle" style="margin-left: 1.0in; mso-add-space: auto;">
<br /></div>
<div class="MsoListParagraph" style="mso-list: l0 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]-->2.<span style="font-size: 7pt;"> <b>
</b></span><!--[endif]--><b>Young Generation: </b></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -.25in;">
<!--[if !supportLists]-->a.<span style="font-size: 7pt;">
</span><!--[endif]-->Most of the objects are initially placed in the
young generation space.</div>
<div class="MsoListParagraphCxSpMiddle" style="margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -.25in;">
<!--[if !supportLists]-->b.<span style="font-size: 7pt;">
</span><!--[endif]-->Young Generation Garbage collection occurs
frequently and operates at high speed since the young generation space contains
lots of objects that are less referenced.</div>
<div class="MsoListParagraphCxSpMiddle" style="margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -.25in;">
<!--[if !supportLists]-->c.<span style="font-size: 7pt;">
</span><!--[endif]-->In Java HotSpot VM, Young Generation again
categorized into</div>
<div class="MsoListParagraphCxSpMiddle" style="margin-left: 1.5in; mso-add-space: auto; mso-list: l0 level3 lfo1; mso-text-indent-alt: -9.0pt; text-indent: -1.5in;">
<!--[if !supportLists]--><span style="font-size: 7pt;">
</span>i.<span style="font-size: 7pt;">
</span><!--[endif]-->Eden Space : Most objects are initially
allocated in the Eden space</div>
<div class="MsoListParagraphCxSpMiddle" style="margin-left: 1.5in; mso-add-space: auto; mso-list: l0 level3 lfo1; mso-text-indent-alt: -9.0pt; text-indent: -1.5in;">
<!--[if !supportLists]--><span style="font-size: 7pt;">
</span>ii.<span style="font-size: 7pt;">
</span><!--[endif]-->Survivor Space: Objects that survive atleast one
young garbage collection is moved to survivor space. </div>
<div class="MsoListParagraphCxSpMiddle" style="margin-left: 1.5in; mso-add-space: auto;">
<br /></div>
<div class="MsoListParagraph" style="mso-list: l0 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]-->3.<span style="font-size: 7pt;">
</span><!--[endif]--><b>Old Generation:</b></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -.25in;">
<!--[if !supportLists]-->a.<span style="font-size: 7pt;">
</span><!--[endif]-->Objects that survived Garbage Collection (From
Survivor Space) are tenured or Promoted to the Old Generation</div>
<div class="MsoListParagraphCxSpMiddle" style="margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -.25in;">
<!--[if !supportLists]-->b.<span style="font-size: 7pt;">
</span><!--[endif]-->Garbage Collection algorithm that works on this
space is designed to be more space efficient since Old generation occupies most
of the heap.</div>
<div class="MsoListParagraphCxSpMiddle" style="margin-left: 1.0in; mso-add-space: auto;">
<br /></div>
<div class="MsoListParagraph" style="mso-list: l0 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]-->4.<span style="font-size: 7pt;"> <b>
</b></span><!--[endif]--><b>Permanent Generation (PermGen) :</b></div>
<div class="MsoListParagraphCxSpLast" style="margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -.25in;">
<!--[if !supportLists]-->a.<span style="font-size: 7pt;">
</span><!--[endif]-->Permanent Generation usually contains the
objects that describe classes & methods and also classes & methods.</div>
<div class="MsoListParagraphCxSpLast" style="margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -.25in;">
<br /></div>
<div class="MsoListParagraphCxSpLast" style="margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -.25in;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisJjwZP9gtk4PSX_OHJ7f7BRrEdcRfbeZqM9MF4J4oV44USm4rJdkHg0wGEUVDMMJHrpsP4ytP-m05nloafZnHDIeMyVRKtEABnSfCFtSvdv4m06pTuUYhdTHvGJqyclrcX2JjG-8SPtE/s1600/img3.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisJjwZP9gtk4PSX_OHJ7f7BRrEdcRfbeZqM9MF4J4oV44USm4rJdkHg0wGEUVDMMJHrpsP4ytP-m05nloafZnHDIeMyVRKtEABnSfCFtSvdv4m06pTuUYhdTHvGJqyclrcX2JjG-8SPtE/s1600/img3.bmp" height="411" width="640" /></a></div>
<div class="MsoListParagraphCxSpLast" style="margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -.25in;">
<br /></div>
<div class="MsoListParagraphCxSpLast" style="margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -.25in;">
<br /></div>
Sathishhttp://www.blogger.com/profile/13077114304120944836noreply@blogger.com0tag:blogger.com,1999:blog-622411316080059845.post-87237464788236237972012-12-07T07:46:00.000-08:002012-12-07T07:47:00.365-08:00Handling the comment block in Facelets/JSF2<br />
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Even if the block of code is commented using the HTML
comment (<b><!-- --></b>) the JSF lifecycle still
process the part of code and it is rendered in the HTML source although the
component is not rendered in the HTML page. This shall be viewed in the browser
source view option. This reveals the sensitive information to the third party
which is not intended to be known.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b>Example:<o:p></o:p></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
In the below piece of code, a part of the code is commented
using HTML based comment (<code><!-- --></code>)</div>
<div class="MsoNormal">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjttPpX9-ramcBDFHvNKGkr5PmxhMDpdhrll9HUPFZR4I0mUcTf8ejEWARr1PL7FzRfjUs2JWuG6PJSW7Hx3WislzctzJd4YH81rL5bMUmo5p81Y86HUK-plwVk9KaTy2ogckvhoC2eORc/s1600/img1.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjttPpX9-ramcBDFHvNKGkr5PmxhMDpdhrll9HUPFZR4I0mUcTf8ejEWARr1PL7FzRfjUs2JWuG6PJSW7Hx3WislzctzJd4YH81rL5bMUmo5p81Y86HUK-plwVk9KaTy2ogckvhoC2eORc/s1600/img1.bmp" /></a></div>
<br />
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Calibri","sans-serif"; font-size: 11.0pt; mso-ansi-language: EN-US; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"><!--[if gte vml 1]><v:shapetype id="_x0000_t75"
coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe"
filled="f" stroked="f">
<v:stroke joinstyle="miter"/>
<v:formulas>
<v:f eqn="if lineDrawn pixelLineWidth 0"/>
<v:f eqn="sum @0 1 0"/>
<v:f eqn="sum 0 0 @1"/>
<v:f eqn="prod @2 1 2"/>
<v:f eqn="prod @3 21600 pixelWidth"/>
<v:f eqn="prod @3 21600 pixelHeight"/>
<v:f eqn="sum @0 0 1"/>
<v:f eqn="prod @6 1 2"/>
<v:f eqn="prod @7 21600 pixelWidth"/>
<v:f eqn="sum @8 21600 0"/>
<v:f eqn="prod @7 21600 pixelHeight"/>
<v:f eqn="sum @10 21600 0"/>
</v:formulas>
<v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/>
<o:lock v:ext="edit" aspectratio="t"/>
</v:shapetype><v:shape id="_x0000_i1025" type="#_x0000_t75" alt="" style='width:469.5pt;
height:111.75pt'>
<v:imagedata src="file:///C:\DOCUME~1\sathish\LOCALS~1\Temp\msohtmlclip1\01\clip_image001.jpg"
o:href="cid:image003.jpg@01CD38EF.FE1EE830"/>
</v:shape><![endif]--><!--[if !vml]--><!--[endif]--></span></div>
<div class="MsoNormal">
<span style="font-family: "Calibri","sans-serif"; font-size: 11.0pt; mso-ansi-language: EN-US; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"><br /></span></div>
<div class="MsoNormal">
</div>
<div class="MsoNormal">
Even though the Browser doesn’t render the component in the
browser, still the code in the HTML contains this piece of information. And
also JSF processes this component.</div>
<div class="MsoNormal">
<br /></div>
<b><span style="font-family: "Calibri","sans-serif"; font-size: 11.0pt; mso-ansi-language: EN-US; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">HTML
Source viewed from the Browser.</span></b><br />
<div class="MsoNormal">
<b><span style="font-family: "Calibri","sans-serif"; font-size: 11.0pt; mso-ansi-language: EN-US; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"><br /></span></b></div>
<div class="MsoNormal">
</div>
<div class="MsoNormal">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhj0NPPZAA6nGzP_k8Nm1wS4PMF-Nj69po82Qmwoi1nd3d4RULgrgl9cmWEbQ_8hipmOQ5ey4zwlfm9fsbRneN7Y93DRSFyZX_TRk8VwOpAOXpHuwhBoIyZuLr_2fXDpL0hEOPDLDxIO1E/s1600/img2.bmp" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhj0NPPZAA6nGzP_k8Nm1wS4PMF-Nj69po82Qmwoi1nd3d4RULgrgl9cmWEbQ_8hipmOQ5ey4zwlfm9fsbRneN7Y93DRSFyZX_TRk8VwOpAOXpHuwhBoIyZuLr_2fXDpL0hEOPDLDxIO1E/s1600/img2.bmp" /></a><b><span style="font-family: "Calibri","sans-serif"; font-size: 11.0pt; mso-ansi-language: EN-US; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"><br /></span></b></div>
<div class="MsoNormal">
<b><br /></b></div>
<div class="MsoNormal">
<b><br /></b></div>
<div class="MsoNormal">
<b><br /></b></div>
<div class="MsoNormal">
<b><br /></b></div>
<div class="MsoNormal">
<b><br /></b></div>
<div class="MsoNormal">
<b><br /></b></div>
<div class="MsoNormal">
<b><br /></b></div>
<div class="MsoNormal">
<b><br /></b></div>
<div class="MsoNormal">
<b><br /></b></div>
<div class="MsoNormal">
<b><br /></b></div>
<div class="MsoNormal">
<b>Possible solutions:<o:p></o:p></b></div>
<div class="MsoListParagraph" style="mso-list: l0 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]-->1.<span style="font-size: 7pt;"> </span></div>
<div class="MsoListParagraph" style="mso-list: l0 level1 lfo1; text-indent: -.25in;">
<span style="font-size: 7pt;"></span><!--[endif]--> Configure web.xml to inform Facelets to skip
comment.</div>
<div class="MsoNormal" style="margin-left: .5in; text-autospace: none;">
<span style="color: teal; font-family: "Courier New"; font-size: 10.0pt;"><</span><span style="background: silver; color: #3f7f7f; font-family: "Courier New"; font-size: 10.0pt; mso-highlight: silver;">context-param</span><span style="color: teal; font-family: "Courier New"; font-size: 10.0pt;">></span><span style="font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: .5in; text-autospace: none;">
<span style="font-family: 'Courier New'; font-size: 10pt;">
</span><span style="color: teal; font-family: "Courier New"; font-size: 10.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 10.0pt;">param-name</span><span style="color: teal; font-family: "Courier New"; font-size: 10.0pt;">></span><span style="font-family: 'Courier New'; font-size: 10pt;">facelets.SKIP_COMMENTS</span><span style="color: teal; font-family: "Courier New"; font-size: 10.0pt;"></</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 10.0pt;">param-name</span><span style="color: teal; font-family: "Courier New"; font-size: 10.0pt;">></span><span style="font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: .5in; text-autospace: none;">
<span style="font-family: 'Courier New'; font-size: 10pt;">
</span><span style="color: teal; font-family: "Courier New"; font-size: 10.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 10.0pt;">param-value</span><span style="color: teal; font-family: "Courier New"; font-size: 10.0pt;">></span><span style="font-family: 'Courier New'; font-size: 10pt;">true</span><span style="color: teal; font-family: "Courier New"; font-size: 10.0pt;"></</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 10.0pt;">param-value</span><span style="color: teal; font-family: "Courier New"; font-size: 10.0pt;">></span><span style="font-family: "Courier New"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: .5in;">
<span style="color: teal; font-family: "Courier New"; font-size: 10.0pt;"></</span><span style="background: silver; color: #3f7f7f; font-family: "Courier New"; font-size: 10.0pt; mso-highlight: silver;">context-param</span><span style="color: teal; font-family: "Courier New"; font-size: 10.0pt;">><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-left: .5in;">
<br /></div>
<div class="MsoNormal">
<span style="text-indent: -0.25in;">2.</span><span style="font-size: 7pt; text-indent: -0.25in;">
</span><span style="text-indent: -0.25in;">Use Facelets </span><b style="text-indent: -0.25in;">ui:remove</b><span style="text-indent: -0.25in;"> tag to comment the
code block.</span><b><span style="font-family: "Calibri","sans-serif"; font-size: 11.0pt; mso-ansi-language: EN-US; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> </span></b></div>
Sathishhttp://www.blogger.com/profile/13077114304120944836noreply@blogger.com0tag:blogger.com,1999:blog-622411316080059845.post-4225284904392704332012-04-13T08:54:00.002-07:002023-10-18T09:13:18.606-07:00My Quotes<div dir="ltr" style="text-align: left;" trbidi="on">
<b><u><i><span style="color: #3d85c6;">Character:</span></i></u></b><br />
<br />
It might take years to build a character; but requires lots of character to keep up for ever<br />
<br />
Its Insane behavior of few people make me feel i am still sane<br />
<br />
Fear tolls my head; but confidence pulls it out;<br />
Anger thrashes my heart; but peace pushing it out;<br />
Violence tries to take over; but character fighting it out.<br />
<br />
Two things we can't teach people is Love and Friendship<br />
<br />
Just learnt we cannot be perfect to all,,,But that does not mean we are not perfect<br />
<br />
Why do my mirror always shows me slim. (always I justify what I feel even if its not)<br />
<br />
Forgive people who hurts u; but forgive not who misleads u<br />
<div>
<br /></div>
<div>
<b><u><i><span style="color: #3d85c6;">Trust:</span></i></u></b></div>
<div>
<b><u><i><span style="color: #3d85c6;"><br /></span></i></u></b></div>
<div>
if u build trust, it is stronger than Tajmahal;if u break trust it is worse than tsunami</div>
<div>
<br /></div>
<div>
<h4 style="text-align: left;">
<b><i><u><span style="color: #3d85c6;">Hope:</span></u></i></b></h4>
<div>
Miles to go before i go to sleep</div>
<div>
lost my smiles in travel to destiny</div>
<div>
searching for a while to rest in peace</div>
<div>
got hostile in this world of disharmony</div>
<div>
waiting for a shoulder to pass through turnstile</div>
<div>
<br /></div>
<div>
At times words doesnot turn to action</div>
<div>
At times action doesnot yield success</div>
<div>
At times success doesnot bring happiness</div>
<div>
At times happiness doesnot last long</div>
<div>
But all times we shouldnot loose hope</div>
<div>
<br /></div>
<div>
Millions of heart starts playing the band</div>
<div>
Thousands of prayers across the land</div>
<div>
Eleven crusaders touches the sand</div>
<div>
They Bat to win the battle</div>
<div>
And bowl to win the hearts</div>
<div>
----Hope India brings the cup</div>
<div>
<br /></div>
<div>
Its not the rising sun that made this day different;</div>
<div>
Neither its not the beauty of moon that made difference;</div>
<div>
But the hope of better tomorrow made it </div>
<div>
Wish u a very Happy New Year</div>
<div>
<br /></div>
<div>
The decisions in the life could be debated but not the life itself</div>
</div>
<div>
<br /></div>
<div>
<h4 style="text-align: left;">
<b><i><u><span style="color: #3d85c6;">Music</span></u></i></b></h4>
<div>
Music makes the mind listen to heart :)</div>
<div>
<br /></div>
<h4 style="text-align: left;">
<i><u><span style="color: #3d85c6;">Problems:</span></u></i></h4>
<div>
Few problems are like windows!!!!!the only solution is CTRL+ALT+DEL</div>
<div>
<br /></div>
<h4 style="text-align: left;">
<i><u><span style="color: #3d85c6;">Gift:</span></u></i></h4>
<div>
When we are kid, Parents are the best gift</div>
<div>
When we are teen, friends are the best gift</div>
<div>
When we grow up, partner is the best gift</div>
<div>
When we bcm old, kids are the best gift</div>
<div>
But do remember at any point,</div>
<div>
you are one of the best gift for someone and always spl!!!!</div><div><br /></div><div>Loneliness:</div><div><br /></div><div>Just realised loneliness is not caused by others but when my thoughts left wandering for others</div><div><br /></div><div>When you feel missing yourself is because you miss someone</div><div><br /></div><div>When you come to know the smile is not for you and tears are not on you, it's not all of you</div><div><br /></div><div>Time:</div><div><br /></div><div>People say time is a healer but you know what - time is in fact a hoax</div><div><br /></div><div>It's not the memory it's indeed the moments define life</div><div><br /></div><div>Even the unseen air can make you feel its presence and keeps you alive</div><div><br /></div><div>One can't live in two places, we either live in the present or live in thoughts</div><div><br /></div><div>When someone steals your time, it means someone has lost something</div><div><br /></div><div>Meaning:</div><div><br /></div><div>ஒவ்வொரு கண்ணீர் துளிக்கும் அர்தமுண்டு ஆனால்</div><div>சில ஆழுந்த அர்ததுக்கோ எந்த</div><div>சுவடும் இல்லை.</div><div><br /></div><div>தனிமையில், ஆழ் கடலிலும் மீன் பிடிக்கலாம்</div>
</div>
<div>
<br /></div>
<div>
<br /></div>
</div>Sathishhttp://www.blogger.com/profile/13077114304120944836noreply@blogger.com0tag:blogger.com,1999:blog-622411316080059845.post-26441456984100298802012-04-08T10:13:00.002-07:002012-04-08T10:13:24.727-07:00My First application of JSF2.0 with CDI<div dir="ltr" style="text-align: left;" trbidi="on">
<b><br /></b><br />
In this specific tutorial will list the steps of JSF2.0 that uses CDI. Used Jboss 6.1 application server which ships with the CDI implementation - Weld.<br />
<br />
<b>Step1:</b> We shall create a JSF page that shall have 3 input text and bind to a managed bean.<br />
<br />
<br />
<span style="color: blue;"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" </span><br />
<span style="color: blue;"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></span><br />
<span style="color: blue;"><html xmlns="http://www.w3.org/1999/xhtml"</span><br />
<span style="color: blue;"> xmlns:ui="http://java.sun.com/jsf/facelets"</span><br />
<span style="color: blue;"> xmlns:h="http://java.sun.com/jsf/html"></span><br />
<span style="color: blue;"><br /></span><br />
<span style="color: blue;"><ui:composition></span><br />
<span style="color: blue;"> <h:body></span><br />
<span style="color: blue;"> <h:form></span><br />
<span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span><h:inputText value="#{employeeBean.name}"></h:inputText></span><br />
<span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span><h:inputTextarea value="#{employeeBean.id}"></h:inputTextarea></span><br />
<span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span><h:inputTextarea value="#{employeeBean.departmentBean.department}"></h:inputTextarea></span><br />
<span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span><h:commandButton value="submit" action="#{employeeBean.submit}"></h:commandButton></span><br />
<span style="color: blue;"> </h:form></span><br />
<span style="color: blue;"> </h:body></span><br />
<span style="color: blue;"></ui:composition></span><br />
<span style="color: blue;"></html></span><br />
<span style="color: blue;"><br /></span><br />
<b>Step2: </b> Now lets create a managed bean “EmployeeBean” and “DepartmentBean” which shall be a CDI managed java bean. You could notice there are new annotations @javax.enterprise.context.RequestScoped, @Dependent, @Named, @inject<br />
<br />
<br />
<span style="color: blue;">package com.test;</span><br />
<span style="color: blue;"><br /></span><br />
<span style="color: blue;">import javax.enterprise.context.RequestScoped;</span><br />
<span style="color: blue;">import javax.inject.Inject;</span><br />
<span style="color: blue;">import javax.inject.Named;</span><br />
<span style="color: blue;"><br /></span><br />
<span style="color: blue;">@RequestScoped</span><br />
<span style="color: blue;">@Named<span class="Apple-tab-span" style="white-space: pre;"> </span></span><br />
<span style="color: blue;">public class EmployeeBean {</span><br />
<span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>private String name;</span><br />
<span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>private int id;</span><br />
<span class="Apple-tab-span" style="white-space: pre;"><span style="color: blue;"> </span></span><br />
<span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>@Inject</span><br />
<span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>private DepartmentBean departmentBean;</span><br />
<span style="color: blue;"><br /></span><br />
<span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>public String getName() {</span><br />
<span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>return name;</span><br />
<span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br />
<span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>public void setName(String name) {</span><br />
<span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>this.name = name;</span><br />
<span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br />
<span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>public int getId() {</span><br />
<span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>return id;</span><br />
<span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br />
<span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>public void setId(int id) {</span><br />
<span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>this.id = id;</span><br />
<span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br />
<span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>public String submit(){</span><br />
<span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("submit action called");</span><br />
<span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>return "welcome";</span><br />
<span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br />
<span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>public DepartmentBean getDepartmentBean() {</span><br />
<span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>return departmentBean;</span><br />
<span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br />
<span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>public void setDepartmentBean(DepartmentBean departmentBean) {</span><br />
<span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>this.departmentBean = departmentBean;</span><br />
<span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br />
<span style="color: blue;">}</span><br />
<div>
<br /></div>
<div>
Now lets take a look at the use of these new annotations:</div>
<div>
<br /></div>
<div>
<div>
<b>@ javax.enterprise.context.RequestScoped:</b> A typical web request scope. There are new scopes added apart from the typical (request, session, application) such as @conversationScoped, @Dependent. Shall cover the new scopes in a separate post.</div>
<div>
<br /></div>
<div>
<b>@Named:</b> This annotation lets the managed beans to be accessed through EL. If there is no value attribute been used then default value is been assigned according to the naming convention. In this case it is “employeeBean”</div>
<div>
<br /></div>
<div>
<b>@Dependent:</b> you could note yet another new scoped bean called @Dependent which is also a default scope if none specified and will serve exactly one client (bean) and has the same life cycle of the client (bean).</div>
<div>
<br /></div>
<div>
<b>@inject:</b> This annotation is used to inject one bean in to the other. In this example you could see the dependent scope departmentBean is injected to the request scoped employeeBean.</div>
</div>
<div>
<br /></div>
<br />
<br />
<div style="color: blue;">
package com.test;</div>
<div style="color: blue;">
<br /></div>
<div style="color: blue;">
import javax.enterprise.context.Dependent;</div>
<div style="color: blue;">
<br /></div>
<div style="color: blue;">
@Dependent</div>
<div style="color: blue;">
public class DepartmentBean {</div>
<div style="color: blue;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>private String department;</div>
<div style="color: blue;">
<br /></div>
<div style="color: blue;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>public String getDepartment() {</div>
<div style="color: blue;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>return department;</div>
<div style="color: blue;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style="color: blue;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>public void setDepartment(String department) {</div>
<div style="color: blue;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>this.department = department;</div>
<div style="color: blue;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style="color: blue;">
}</div>
<div style="color: blue;">
<br /></div>
<br />
<b>Step3:</b> Now lets create a simple new page where the values got from the user are being displayed.<br />
<div style="color: blue;">
<br /></div>
<div style="color: blue;">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" </div>
<div style="color: blue;">
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></div>
<div style="color: blue;">
<html xmlns="http://www.w3.org/1999/xhtml"</div>
<div style="color: blue;">
xmlns:ui="http://java.sun.com/jsf/facelets"</div>
<div style="color: blue;">
xmlns:h="http://java.sun.com/jsf/html"></div>
<div style="color: blue;">
<br /></div>
<div style="color: blue;">
<h:body></div>
<div style="color: blue;">
<h:form></div>
<div style="color: blue;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><h:outputText value="#{employeeBean.name}"/></div>
<div style="color: blue;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><h:outputText value="#{employeeBean.id}"/></div>
<div style="color: blue;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><h:outputText value="#{employeeBean.departmentBean.department}"/></div>
<div style="color: blue;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><h:commandButton value="back" action="Test?faces-redirect=true"></h:commandButton></div>
<div style="color: blue;">
</h:form></div>
<div style="color: blue;">
</h:body></div>
<div style="color: blue;">
</html></div>
<div style="color: blue;">
<br /></div>
<div>
<div>
<b>Step4:</b> Apart from annotations you could have noticed there is nothing much difference in this application for CDI. The last small step is the addition of beans.xml. This xml is must required even if there is no configurations to be made. This shall allow the app server (jboss here) to use the CDI implementation (weld) to scan through for CDI beans and provide services.</div>
<div>
<span style="color: blue;"><br /></span></div>
<div>
<b>This xml is to be placed in the web-inf folder.</b></div>
<div>
<span style="color: blue;"><br /></span></div>
<div>
<span style="color: blue;"><?xml version="1.0" encoding="UTF-8"?></span></div>
<div>
<span style="color: blue;"><beans xmlns="http://java.sun.com/xml/ns/javaee" </span></div>
<div>
<span style="color: blue;"> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" </span></div>
<div>
<span style="color: blue;"> xmlns:weld="http://jboss.org/schema/weld/beans" </span></div>
<div>
<span style="color: blue;"> xsi:schemaLocation="</span></div>
<div>
<span style="color: blue;"> http://java.sun.com/xml/ns/javaee http://docs.jboss.org/cdi/beans_1_0.xsd</span></div>
<div>
<span style="color: blue;"> http://jboss.org/schema/weld/beans http://jboss.org/schema/weld/beans_1_1.xsd"></span></div>
<div>
<span style="color: blue;"> </beans></span></div>
<div>
<span style="color: blue;"><br /></span></div>
<div>
Now deploy the application in App server(jboss)</div>
<div style="color: blue;">
<br /></div>
</div>
<br />
<div style="color: blue;">
<br /></div>
<br />
<span style="color: blue;"><br /></span><br />
<div>
<br /></div>
</div>Sathishhttp://www.blogger.com/profile/13077114304120944836noreply@blogger.com0tag:blogger.com,1999:blog-622411316080059845.post-71072934818557452502012-04-08T06:08:00.000-07:002012-04-08T06:08:57.212-07:00Troubleshoot – JSF 2 (Mojarro – JSF-2.0.3)<div dir="ltr" style="text-align: left;" trbidi="on">
<b>Troubleshoot – JSF 2 (Mojarro – JSF-2.0.3)</b><br />
<b><br /></b><br />
Next in the troubleshoot series is the dumb illegal argument exception on request of a jsf page. This specific problem seems to be a bug in the Mojarro implementation where it swallows the specific exception caused because of simple mistakes in the xhtml pages.<br />
<br />
<br />
<i><span style="color: blue;">1:30:17,375 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/TestJSF2].[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception: java.lang.IllegalArgumentException: null source</span></i><br />
<i><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>at java.util.EventObject.<init>(Unknown Source) [:1.6.0_23]</init></span></i><br />
<i><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>at javax.faces.event.SystemEvent.<init>(SystemEvent.java:67) [:2.0.3-]</init></span></i><br />
<i><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>at javax.faces.event.ComponentSystemEvent.<init>(ComponentSystemEvent.java:69) [:2.0.3-]</init></span></i><br />
<i><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>at javax.faces.event.PostRestoreStateEvent.<init>(PostRestoreStateEvent.java:69) [:2.0.3-]</init></span></i><br />
<i><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>at com.sun.faces.lifecycle.RestoreViewPhase.deliverPostRestoreStateEvent(RestoreViewPhase.java:256</span></i><br />
<br />
<br />
The problem that might caused this exception would be because of a simple error in the xhtml page like missing tag or xml not well formed etc., Facelets is expected to throw exception with detailed message but the exception is swallowed. The issue seems to be still in open<br />
<br />
<i><a href="http://java.net/jira/browse/JAVASERVERFACES-1758">http://java.net/jira/browse/JAVASERVERFACES-1758</a></i><br />
<div>
<br /></div>
<br />
<div>
<br /></div>
</div>Sathishhttp://www.blogger.com/profile/13077114304120944836noreply@blogger.com0tag:blogger.com,1999:blog-622411316080059845.post-67766496125009183812012-04-07T11:48:00.000-07:002012-04-07T11:48:45.255-07:00Troubleshoot-Jboss 6.1and Eclipse Indigo<div dir="ltr" style="text-align: left;" trbidi="on">
<b>Troubleshoot-Jboss 6.1and Eclipse Indigo</b><br />
<b><br /></b><br />
<b>Jboss 6.1 doesnot start without any error or log in Eclipse Helios</b><br />
<b><br /></b><br />
Server: jboss 6.1-Final<br />
Eclipse Version: Helios and Indigo<br />
<br />
When jboss 6.1 was started from Eclipse Helios or Indigo without jboss tools plug-in, the<span style="color: blue;"> server doesn’t start without any error or log</span>. The problem seems to be jboss 6.1 expects a vm argument on logging.properties.<br />
<br />
When the logging.properties is set in vm arguments, the server started without any problem.<br />
<br />
In Eclipse, go to server tab, Click on server and then Arguments, in VM arguments section provide the below entry<br />
<br />
<span style="color: blue;">-Dlogging.configuration=file:"<jboss 6.1-home="">\bin\logging.properties" </jboss></span><br />
<span style="color: blue;"><br /></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbqjhrVPCRi05oS65n6xtwd_KoVLKc4u5Io-h0nyy_03llddJdIZOwV1GYYrmFLAqf54GuIxfRbZCxpeyZWLvFqx5ceQDv4014haKrDA8nJiZ8wDhbmdZv0yugDgdir8dKSTA4TNeoBO0/s1600/pic2.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="576" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbqjhrVPCRi05oS65n6xtwd_KoVLKc4u5Io-h0nyy_03llddJdIZOwV1GYYrmFLAqf54GuIxfRbZCxpeyZWLvFqx5ceQDv4014haKrDA8nJiZ8wDhbmdZv0yugDgdir8dKSTA4TNeoBO0/s640/pic2.JPG" width="640" /></a></div>
<span style="color: blue;"><br /></span><br />
<br />
<br />
<br />
<br /></div>Sathishhttp://www.blogger.com/profile/13077114304120944836noreply@blogger.com1tag:blogger.com,1999:blog-622411316080059845.post-12700874615878423142012-04-07T11:44:00.000-07:002012-04-07T11:44:12.574-07:00Troubleshoot-Jboss 6.1and Eclipse Indigo<div dir="ltr" style="text-align: left;" trbidi="on">
<b>Troubleshoot-Jboss 6.1and Eclipse Indigo</b><br />
<b><br /></b><br />
Server: Jboss 6.1-Final<br />
Eclipse Version: Helios and Indigo<br />
<br />
When the jboss 6.1-Final is started in Eclipse Helios and above, the below error was thrown. There seems to be problem with plug-in.<br />
<br />
<span style="color: blue;">Deployment "PostEjbJarMetadataDeployer" is in error due to the following reason(s): java.lang.NoSuchMethodError: javax.annotation.Resource.lookup()Ljava/lang/String;</span><br />
<span style="color: blue;"><br /></span><br />
<span style="color: blue;"></span><br />
By providing the below configuration in the vm argument, the problem is resolved.<br />
In Eclipse, go to server tab, Click on server and then Arguments, in VM arguments section provide the below entry<br />
<div>
<span style="color: blue;"><br /></span></div>
<div>
<span style="color: blue;">-Djava.endorsed.dirs=<jboss home="">\lib\endorsed</jboss></span></div>
<div>
<span style="color: blue;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfBYsfzkyKfp9nDcIjrtAmNuottGRi04JcmIoUVKvO7tNrEnKaOzMJi3rw6D69oxDb9EJrXrQVW3mfHDfhSbahB-QkglYbtVP9GZY7106ZGPBrhyphenhyphenIhw9cFZw6lcPRlIThfYe1glZiGt0I/s1600/pic1.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="612" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfBYsfzkyKfp9nDcIjrtAmNuottGRi04JcmIoUVKvO7tNrEnKaOzMJi3rw6D69oxDb9EJrXrQVW3mfHDfhSbahB-QkglYbtVP9GZY7106ZGPBrhyphenhyphenIhw9cFZw6lcPRlIThfYe1glZiGt0I/s640/pic1.JPG" width="640" /></a></div>
<div>
<span style="color: blue;"><br /></span></div>
</div>Sathishhttp://www.blogger.com/profile/13077114304120944836noreply@blogger.com0tag:blogger.com,1999:blog-622411316080059845.post-67176388238504781082012-04-04T08:43:00.000-07:002012-04-07T11:54:23.889-07:00Injection in JSF<div dir="ltr" style="text-align: left;" trbidi="on">
<b><span style="color: #17365d;"><span style="font-family: Calibri;">Injection in JSF:</span></span></b><br />
<br />
The dependent managed bean can be injected in to the managed bean using the @ManagedBean property annotation in JSF2<br />
<br />
Say for example TestBean is holding a property of type DepartmentBean, the bean shall be injected to the TestBean as below.<br />
<br />
<em><span style="color: blue;">@ManagedBean</span></em><br />
<em><span style="color: blue;">@RequestScoped</span></em><br />
<em><span style="color: blue;">public class TestBean {</span></em> <br />
<br />
<em><span style="color: blue;"> @ManagedProperty(value="5")</span></em><br />
<em><span style="color: blue;"> private int id;</span></em><br />
<br />
<em><span style="color: blue;"> @NotNull(message="Name cannot be blank")</span></em><br />
<em><span style="color: blue;"> private String name;</span></em><br />
<br />
<em><span style="color: blue;"> @ManagedProperty(value="#{departmentBean}")</span></em><br />
<em><span style="color: blue;"> private DepartmentBean deptBean;</span></em><br />
<br />
<span style="color: blue;"> public DepartmentBean getDepartmentBean() {</span><br />
<br />
<span style="color: blue;"> return deptBean;</span><br />
<span style="color: blue;"> }</span><br />
<span style="color: blue;"><br /></span><br />
<span style="color: blue;"> public void setDepartmentBean(DepartmentBean deptBean) {</span><br />
<span style="color: blue;"> this.deptBean= deptBean;</span><br />
<span style="color: blue;"> }</span><br />
<br />
<em><span style="color: blue;"> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</span></em><br />
<em><span style="color: blue;"> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</span></em><br />
<br />
<em><span style="color: blue;"> }</span></em><br />
<em><br /><span style="color: blue;"></span></em><br />
<em><span style="color: blue;">@ManagedBean</span></em><br />
<em><span style="color: blue;">@RequestScoped</span></em><br />
<em><span style="color: blue;">public class DepartmentBean {</span></em><br />
<em><br /><span style="color: blue;"></span></em><br />
<em><span style="color: blue;"> @ManagedProperty(value="admin")</span></em><br />
<em><span style="color: blue;"> public String dept;</span></em><br />
<br />
<em><span style="color: blue;"> public String getDept() {</span></em><br />
<em><span style="color: blue;"> return dept;</span></em><br />
<em><span style="color: blue;"> }</span></em><br />
<br />
<em><span style="color: blue;"> public void setDept(String dept) {</span></em><br />
<em><span style="color: blue;"> this.dept = dept;</span></em><br />
<em><span style="color: blue;"> }</span></em><br />
<em><span style="color: blue;">}</span></em><br />
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-align: left; text-indent: 0.5in;">
<span style="color: #17365d;"><span style="font-family: Calibri;"><span style="color: black;">In the above example you could notice the managed bean injection performed using the @ManagedProperty annotation and also EL is been used to refer the dependent bean (#{departmentBean}. You could also notice there is no name attribute is been used in both the managed beans and hence the default value is been assigned with the naming conventions.</span></span></span></div>
<br />
<div style="text-align: left;">
<span style="color: #17365d; font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;"><span style="color: black;">The same can be done in JSF1.2 using the faces Config xml configuration</span></span></div>
<br />
<span style="color: #17365d; font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;"><em><span style="background-color: white; color: blue;"><managed-bean></span></em></span><br />
<em><span style="background-color: white; color: blue;"></span></em><br />
<em><span style="background-color: white; color: blue;"> <span style="color: #17365d; font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;"><</span>managed-bean-name>testBean<span style="color: #17365d; font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;"><</span>/managed-bean-name></span></em><br />
<em><span style="background-color: white; color: blue;"> <span style="color: #17365d; font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;"><</span>managed-bean-class>com.test.TestBean<span style="color: #17365d; font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;"><</span>/managed-bean-class></span></em><br />
<em><span style="background-color: white; color: blue;"> <span style="color: #17365d; font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;"><</span>managed-bean-scope>request<span style="color: #17365d; font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;"><</span>/managed-bean-scope></span></em><br />
<em><span style="background-color: white; color: blue;"> <span style="color: #17365d; font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;"><</span>managed-property></span></em><br />
<em><span style="background-color: white; color: blue;"> <span style="color: #17365d; font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;"><</span>property-name>deptBean<span style="color: #17365d; font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;"><</span>/property-name></span></em><br />
<em><span style="background-color: white; color: blue;"> <span style="color: #17365d; font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;"><</span>value>#{departmentBean}<span style="color: #17365d; font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;"><</span>/value></span></em><br />
<em><span style="background-color: white; color: blue;"> <span style="color: #17365d; font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;"><</span>/managed-property></span></em><br />
<em><span style="background-color: white;"><span style="color: blue;"><span style="color: #17365d; font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;"><</span>/managed-bean></span></span></em><br />
<em><br /><span style="background-color: white; color: blue;"></span></em><br />
<em><span style="background-color: white;"><span style="color: blue;"><span style="color: #17365d; font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;"><</span>managed-bean></span></span></em><br />
<em><span style="background-color: white; color: blue;"> <span style="color: #17365d; font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;"><</span>managed-bean-name>departmentBean<span style="color: #17365d; font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;"><</span>/managed-bean-name></span></em><br />
<em><span style="background-color: white; color: blue;"> <span style="color: #17365d; font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;"><</span>managed-bean-class>com.test.DepartmentBean<span style="color: #17365d; font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;"><</span>/managed-bean-class></span></em><br />
<em><span style="background-color: white; color: blue;"> <span style="color: #17365d; font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;"><</span>managed-bean-scope>request<span style="color: #17365d; font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;"><</span>/managed-bean-scope></span></em><br />
<em><span style="background-color: white;"><span style="color: blue;"><span style="color: #17365d; font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;"><</span>managed-bean></span></span></em><br />
<br />
<br />
<br /></div>Sathishhttp://www.blogger.com/profile/13077114304120944836noreply@blogger.com0tag:blogger.com,1999:blog-622411316080059845.post-12480070453751140502012-04-04T06:56:00.000-07:002012-04-04T06:56:17.316-07:00JSF Request Processing Lifecycle<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt;">
<b><span style="color: #17365d; mso-themecolor: text2; mso-themeshade: 191;"><span style="font-family: Calibri;">JSF Request Processing Lifecycle:</span></span></b></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt;">
<span style="color: #17365d; mso-themecolor: text2; mso-themeshade: 191;"><span style="font-family: Calibri;">JSF has six phases in its life cycle and below is the overview of each phase.</span></span></div>
<br />
<br />
1. Restore View: Restores or creates a server-side component tree to represent the UI information from a client<br />
2. Apply Request Value: Updates the server side components with request parameters from client<br />
3. Process Validation: Performs validation and data type conversion<br />
4. Update Model: Updates the model(bean) with the data<br />
5. Invoke Application: Invokes application logic and performs navigation processing<br />
6. Render response: Renders the response to the client.<br />
<br />
<strong>Restore View</strong><br />
<br />
<br />
1. Restores the existing view from previous transaction or creates a new view.<br />
2. Created view is placed in the container object known as FacesContext<br />
3. FacesContext contains all the data pertaining to the current request that runs through the request processing life cycle.<br />
<br />
<strong>Apply Request Value</strong><br />
<br />
1. Updates the server side components with request parameters from client<br />
2. JSF runtime calls the processDecodes() on View<br />
3. Subsequently all the processDecodes() on all components are called<br />
4. This decodes the incoming name-value pairs and apply the value to the component.<br />
<br />
<strong>Process Validation</strong><br />
<br />
1. Conversion and validation is performed on the components.<br />
2. JSF Runtime calls processValidators() method on the View Root.<br />
3. Propagation to processValidators() method is called on each components.<br />
4. Data conversion happens before the validation in the same phase.<br />
5. Any component failing conversion or validation<br />
<br />
<strong>Update Model Values</strong><br />
<br />
1. Once the validation and conversion is performed with out any errors, values are now updated to the model bean.<br />
2. JSF Runtime calls processUpdates() method on the View Root.<br />
3. Propagation to processUpdates() method is called on each components.<br />
<br />
<strong>Invoke Application</strong><br />
<br />
1. Invokes application logic and performs navigation processing<br />
2. Any action method or action listener method is invoked.<br />
<br />
<strong>Render Response</strong><br />
<br />
1. As in other phases, components encodeXX() methods are called on each component.<br />
<div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;">
2. The rendered mark up language can be anything, such as HTML, WML, XML etc.,</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeYljnk8H0bRYSkysVQ3sTAB-nRPUCi9PnfRfvHNI5Q5S5xyfZ77vZRI4BjRDW2U1LVhA-lvQNHFniaespVU-FTo-4tJKpK22L0mXORmNaxUY2BHnxpbQ7Z1d-tjpgIM-gCpxcaFoNKMg/s1600/JSFLifeCycle.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="299" nda="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeYljnk8H0bRYSkysVQ3sTAB-nRPUCi9PnfRfvHNI5Q5S5xyfZ77vZRI4BjRDW2U1LVhA-lvQNHFniaespVU-FTo-4tJKpK22L0mXORmNaxUY2BHnxpbQ7Z1d-tjpgIM-gCpxcaFoNKMg/s640/JSFLifeCycle.jpg" width="640" /></a></div>
<div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;">
-------------------------------------------------------------------------------------------------------------</div>
<div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;">
<br /></div>
<div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;">
Below are the example on request processing for few scenarios</div>
<div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;">
<br /></div>
<div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;">
<strong>Scenario -1: Initial Request to view register.jsf</strong></div>
<div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;">
</div>
<br />
<div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;">
1. User submits a request to the URL of the register page</div>
<div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;">
2. The request is processes by the Faces Controller Servlet, which creates a FacesContext instance for this request and initiates a call to the lifecycle.</div>
3. Since it’s a first request, the restore view phase will create an empty view and stores it to the FacesContext instance.<br />
4. After view is created, since it is not a post back request , after the restore view phase, render response phase will be called for.<br />
5. The state of the view will be stored for the future request.<br />
<br />
<strong>Scenario-2: User Enters invalid data (Assume user does not enter data for the mandatory field)</strong><br />
<br />
<br />
1. User doesn’t enter the mandatory data and enters submit<br />
2. The request is processes by the Faces Controller Servlet, which creates a FacesContext instance for this request and initiates a call to the lifecycle.<br />
3. Since it’s a post back request, the restore view phase will retrieve the earlier created view and stores it to the FacesContext instance.<br />
4. In the Apply Request value phase, the request parameters are processed and stored in the component tree<br />
5. In the process Validation phase, a validation error occurs as the value was not entered for the mandatory field and the error message is added to the FacesContext.<br />
6. Now other phase is skipped as the validation error occurred and directly goes to the last Render Response phase where the components are rendered as HTML.<br />
<br />
<strong>Scenario-3: User Enters data valid data and submits again</strong><br />
<br />
<br />
1. The request is processes by the Faces Controller Servlet, which creates a FacesContext instance for this request and initiates a call to the lifecycle.<br />
2. Since it’s a post back request, the restore view phase will retrieve the earlier created view and stores it to the FacesContext instance.<br />
3. In the Apply Request value phase, the request parameters are processed and stored in the component tree<br />
4. In the transition to Process Validation phase, conversion happens and since no validation occurs, the transition happens to the next phase<br />
5. In the Update Model phase, now the values are updated to the model bean and then the action method is called in the Invoke Application phase.<br />
6. The return string of the action method is being used by Navigation processor for deciding the next page to be rendered and the view root of the page is rendered in the Render Response phase.<br />
<br />
<br /><br />
<br />
<br />
</div>Sathishhttp://www.blogger.com/profile/13077114304120944836noreply@blogger.com0tag:blogger.com,1999:blog-622411316080059845.post-22796338845721342862012-04-04T02:01:00.001-07:002012-04-04T02:01:10.273-07:00Initializing Managed Bean Property<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: Calibri;">Initializing the MangedBean property: </span></b></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt; text-indent: 0.5in;">
<span style="font-family: Calibri;">Managed beans shall be initialized on the object creation and this shall be performed using configuration in Faces Config xml in JSF1.2 and using annotations in JSF2.0</span></div>
<span style="font-family: Calibri;"><div class="MsoNormal" style="margin: 0in 0in 10pt; text-indent: 0.5in;">
<b style="mso-bidi-font-weight: normal;">Initializing a property in JSF1.2:</b></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt; text-indent: 0.5in;">
<br /></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt; text-indent: 0.5in;">
<span style="color: blue;"><em><managed-bean></em></span></div>
<span style="color: blue;"><em></em></span><br />
<span style="color: blue;"><em> <managed-bean-name>testBean</managed-bean-name> </em></span><br />
<span style="color: blue;"><em> <managed-bean-class>com.test.TestBean</managed-bean-class></em></span><br />
<span style="color: blue;"><em> <managed-bean-scope>session</managed-bean-scope></em></span><br />
<span style="color: blue;"><em> <managed-property></em></span><br />
<span style="color: blue;"><em> <property-name>name</property-name></em></span><br />
<span style="color: blue;"><em> <property-class>java.lang.String</property-class></em></span><br />
<span style="color: blue;"><em> <value>Enter the Name</value></em></span><br />
<span style="color: blue;"><em> </managed-property></em></span><br />
<br />
<span style="color: blue;"><em> </managed-bean></em></span><br />
<br />
<strong>Initializing the same in JSF2.0:</strong> Take a look at the annotation @ManagedProperty introduced in JSF2.0 and the value attribute holds the default value to be initialized.<br />
<br />
<span style="color: blue;"><em>@ManagedBean</em></span><br />
<span style="color: blue;"><em></em></span><br />
<span style="color: blue;"><em>@RequestScoped</em></span><br />
<span style="color: blue;"><em>public class TestBean {</em></span><br />
<br />
<span style="color: blue;"><em> @ManagedProperty(value="Enter the Name")</em></span><br />
<span style="color: blue;"><em> private String name;</em></span><br />
<span style="color: blue;"><em> /**</em></span><br />
<span style="color: blue;"><em> * @param name the name to set</em></span><br />
<span style="color: blue;"><em> */</em></span><br />
<span style="color: blue;"><em> public void setName(String name) {</em></span><br />
<span style="color: blue;"><em> this.name = name;</em></span><br />
<span style="color: blue;"><em> }</em></span><br />
<span style="color: blue;"><em> </em></span><br />
<span style="color: blue;"><em> /**</em></span><br />
<span style="color: blue;"><em> * @return the name</em></span><br />
<span style="color: blue;"><em> */</em></span><br />
<span style="color: blue;"><em> public String getName() {</em></span><br />
<span style="color: blue;"><em> return name;</em></span><br />
<span style="color: blue;"><em> }</em></span><br />
<br />
-----------------------------------------------<br />
<br />
<br />
<br />
</span></div>Sathishhttp://www.blogger.com/profile/13077114304120944836noreply@blogger.com0tag:blogger.com,1999:blog-622411316080059845.post-32365892759025937042012-04-04T01:44:00.000-07:002012-04-04T01:44:10.452-07:00JSF Managed Bean<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-indent: 0.5in;">
<b style="mso-bidi-font-weight: normal;"><span style="color: #17365d; mso-themecolor: text2; mso-themeshade: 191;"><span style="font-family: Calibri;">MangedBean in JSF:</span></span></b></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-indent: 0.5in;">
<br /></div>
<span style="color: #17365d; mso-themecolor: text2; mso-themeshade: 191;"><span style="font-family: Calibri;"><div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-indent: 0.5in;">
<span style="color: #17365d; mso-themecolor: text2; mso-themeshade: 191;">Managed Beans are the mere POJO that represents model of the JSF application and are managed by the JSF container. Managed Beans are to be registered in the JSF container through Faces Config xml in JSF1.2 and via annotations in JSF2.0 onwards. By registering it in annotation entry in the faces Config can be avoided. But still one can register managed bean in Faces Config without using annotations in JSF2.0. The criteria for managed bean are same as java bean conventions.</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-indent: 0.5in;">
<br /></div>
<span style="color: #17365d; mso-themecolor: text2; mso-themeshade: 191;"><div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-indent: 0.5in;">
<span style="color: #17365d; mso-themecolor: text2; mso-themeshade: 191;"><strong>Registering a managed bean in Faces Config (JSF 1.2) :</strong></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-indent: 0.5in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-indent: 0.5in;">
<span style="color: #17365d; mso-themecolor: text2; mso-themeshade: 191;"><managed-bean></span></div>
<span style="color: #17365d; mso-themecolor: text2; mso-themeshade: 191;"><</span>managed-bean-name>testBean<span style="color: #17365d; mso-themecolor: text2; mso-themeshade: 191;"><</span>/managed-bean-name><br />
<span style="color: #17365d; mso-themecolor: text2; mso-themeshade: 191;"><</span>managed-bean-class>com.test.TestBean<span style="color: #17365d; mso-themecolor: text2; mso-themeshade: 191;"><</span>/managed-bean-class><br />
<span style="color: #17365d; mso-themecolor: text2; mso-themeshade: 191;"><</span>managed-bean-scope>session<span style="color: #17365d; mso-themecolor: text2; mso-themeshade: 191;"><</span>/managed-bean-scope><br />
<span style="color: #17365d; mso-themecolor: text2; mso-themeshade: 191;"><</span>/managed-bean><br />
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-indent: 0.5in;">
<span style="color: #17365d; mso-themecolor: text2; mso-themeshade: 191;"><strong>Sample Managed Bean:</strong></span></div>
<br />
<em><span style="font-family: Arial, Helvetica, sans-serif;">public class TestBean {</span></em><br />
<br />
<em><span style="font-family: Arial, Helvetica, sans-serif;"> private int id;</span></em><br />
<em><span style="font-family: Arial, Helvetica, sans-serif;"> Private String name;</span></em><br />
<br />
<em><span style="font-family: Arial;"> /** Getters and setters for Properties **/</span></em><br />
<em><span style="font-family: Arial, Helvetica, sans-serif;"> </span></em><br />
<em><span style="font-family: Arial, Helvetica, sans-serif;"> </span></em><em><span style="font-family: Arial, Helvetica, sans-serif;"> }</span></em><br />
<em><br /><span style="font-family: Arial, Helvetica, sans-serif;"></span></em><br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-indent: 0.5in;">
<span style="color: #17365d; mso-themecolor: text2; mso-themeshade: 191;"><strong>Registering in JSF2.0 :</strong></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-indent: 0.5in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; text-indent: 0.5in;">
<span style="color: #17365d; mso-themecolor: text2; mso-themeshade: 191;">@ManagedBean</span></div>
<br />
@RequestScoped<br />
public class TestBean {<br />
-------------------<br />
---------------------------<br />
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 10pt; text-indent: 0.5in;">
<span style="color: #17365d; mso-themecolor: text2; mso-themeshade: 191;"><strong>Binding Managed Bean in XHTML: </strong></span></div>
<h:inputText value="#{testBean.name}"></h:inputText><br />
<br />
<br />
</span></span></span></div>Sathishhttp://www.blogger.com/profile/13077114304120944836noreply@blogger.com0tag:blogger.com,1999:blog-622411316080059845.post-54189369112007306312012-04-03T08:06:00.000-07:002012-04-03T08:10:19.187-07:00Features in JSF2.0<div dir="ltr" style="text-align: left;" trbidi="on">
<strong><u>New Features in JSF2.0</u></strong><br />
<br />
<div>
</div>
<br />
<div>
</div>
<span style="font-family: Arial, Helvetica, sans-serif;">JSF2.0 has introduced many new features in align with its design goals. Few of the major new features are listed below.</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"> </span><span style="font-family: Arial, Helvetica, sans-serif;">1. Avoid entries to Faces-Config.xml with annotations. There are new annotations added in JSF2 for declaring managed beans, scopes for managed bean. Few annotations are listed below</span><br />
<div style="text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;"></span></div>
<ul style="text-align: left;"><ul>
<li><div style="text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;">@javax.faces.bean.ManagedBean</span></div>
</li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">@javax.faces.bean.RequestScoped</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">@javax.faces.bean.SessionScoped</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">@javax.faces.bean.ApplicationScoped</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">@javax.faces.bean.ViewScoped</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">@javax.faces.bean.NoneScoped</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">@javax.faces.validator.FacesValidator</span></li>
<li><span style="font-family: Arial, Helvetica, sans-serif;">@javax.faces.convert.FacesConverter </span></li>
</ul>
</ul>
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="font-size: 11pt; line-height: 115%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;">2. Bean names are assigned with default if not explicitly stated in the @ManagedBean annotation with name attribute. In the below code, the ManagedBean annotation is not explicitly named and hence the managedbean name shall be defaulted with testBean (javaBean naming convention)</span><span style="font-size: 11pt; line-height: 115%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"> </span></span><br />
<div style="text-align: left;">
<span style="font-size: 11pt; line-height: 115%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"><em><span style="color: blue; font-family: Arial, Helvetica, sans-serif;"> @ManagedBean </span></em></span></div>
<div style="text-align: left;">
<span style="font-size: 11pt; line-height: 115%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"><em><span style="color: blue; font-family: Arial, Helvetica, sans-serif;"> @RequestScoped</span></em></span></div>
<div style="text-align: left;">
<span style="font-size: 11pt; line-height: 115%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"><em><span style="color: blue; font-family: Arial, Helvetica, sans-serif;"> public class TestBean {--------</span></em></span></div>
<div style="text-align: left;">
<span style="font-size: 11pt; line-height: 115%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"><em><span style="color: blue; font-family: Arial, Helvetica, sans-serif;"> -------------------------------------- </span></em></span><br />
<span style="font-size: 11pt; line-height: 115%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"><span style="font-family: Arial, Helvetica, sans-serif; font-size: 11pt; line-height: 115%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;">3. Facelets are the default view technology for the JSF from JSF2.0 and JSP view technology for JSF is deprecated from JSF2.0. Facelets provides a powerful Templating for the application</span></span></div>
<ul style="text-align: left;"><span style="font-family: Arial, Helvetica, sans-serif;"></span></ul>
<commandbutton action="#{testBean.save}" value="submit"></commandbutton><span style="font-size: 11pt; line-height: 115%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"><span style="font-size: 11pt; line-height: 115%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"><span style="font-size: 11pt; line-height: 115%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"><span style="font-size: 11pt; line-height: 115%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"><span style="font-size: 11pt; line-height: 115%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"><span style="font-size: 11pt; line-height: 115%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"><span style="font-size: 11pt; line-height: 115%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"><span style="font-size: 11pt; line-height: 115%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"><span style="font-size: 11pt; line-height: 115%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"><span style="font-family: Arial, Helvetica, sans-serif; font-size: 11pt; line-height: 115%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;">4. Creating a custom component is made much easier in JSF2.0 compared to its earlier version and JSF2 brings in an enhanced resource handling</span></span></span></span></span></span></span></span></span></span><br />
<br />
<span style="font-size: 11pt; line-height: 115%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"><span style="font-size: 11pt; line-height: 115%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"><span style="font-size: 11pt; line-height: 115%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"><span style="font-size: 11pt; line-height: 115%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"><span style="font-family: Arial, Helvetica, sans-serif; font-size: 11pt; line-height: 115%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;">5. JSF has support to Groovy and hence all the managed bean, validators, converters, renderers shall be a based on groovy</span></span></span></span></span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="font-size: 11pt; line-height: 115%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"><span style="font-size: 11pt; line-height: 115%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"><span style="font-size: 11pt; line-height: 115%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;">6. Default Navigation mappings using the result of the action method. The page navigation shall be defaulted using the result of the action method. In the below piece of action method, the next page is defaulted to welcome.xhtml. By this way the navigation configuration in the Faces xml shall be avoided</span></span></span> </span><br />
<br />
<em><span style="color: blue; font-family: Arial, Helvetica, sans-serif;"> /* * on the call of this action method, the user name is placed in the flash scope</span></em><br />
<em><span style="color: blue; font-family: Arial, Helvetica, sans-serif;"> * and redirected to the new page.</span></em><br />
<em><span style="color: blue; font-family: Arial, Helvetica, sans-serif;"> * @return welcome page string</span></em><br />
<em><span style="color: blue; font-family: Arial, Helvetica, sans-serif;"> */</span></em><br />
<em><span style="color: blue; font-family: Arial, Helvetica, sans-serif;"> public String save() {</span></em><br />
<em><span style="color: blue; font-family: Arial, Helvetica, sans-serif;"> Flash flash=FacesContext.getCurrentInstance().getExternalContext().getFlash();</span></em><br />
<em><span style="color: blue; font-family: Arial, Helvetica, sans-serif;"> flash.put("name",this.name);</span></em><br />
<em><span style="color: blue; font-family: Arial, Helvetica, sans-serif;"> return "welcome";</span></em><br />
<em><span style="color: blue; font-family: Arial, Helvetica, sans-serif;"> }</span></em><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">7. Ajax is enabled in JSF2.0 architecture and thus it is not necessary to depend on third party API for ajax features. Ajax shall be used using the f:ajax tag.</span><br />
<br />
<span style="color: blue; font-family: Arial, Helvetica, sans-serif;"><em> <h:commandButton action="#{testBean.save}" value="submit"></em></span><br />
<em><span style="color: blue; font-family: Arial, Helvetica, sans-serif;"> <f:ajax execute="@form" render="@displayPanel" event="click"/></span></em><br />
<span style="color: blue; font-family: Arial, Helvetica, sans-serif;"><em> </h:commandButton></em></span><br />
<br />
<div style="text-align: left;">
<span style="font-family: "Calibri", "sans-serif"; font-size: 11pt; line-height: 115%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"><span style="font-family: Arial, Helvetica, sans-serif;">8. Creating a custom component is made much easier in JSF2.0 compared to its earlier version and JSF2 brings in an enhanced resource handling.</span></span></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="font-family: "Calibri", "sans-serif"; font-size: 11pt; line-height: 115%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"><span style="font-family: "Calibri", "sans-serif"; font-size: 11pt; line-height: 115%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;">9. JSF has support to Groovy and hence all the managed bean, validators, converters, renderers shall be a based on groovy</span></span></span></div>
<br />
<em><span style="color: blue;"> </span></em></div>Sathishhttp://www.blogger.com/profile/13077114304120944836noreply@blogger.com0tag:blogger.com,1999:blog-622411316080059845.post-15066721149427254482012-04-02T04:34:00.019-07:002012-04-03T08:07:22.926-07:00New Scopes in JSF2.x<div dir="ltr" style="text-align: left;" trbidi="on">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi86Q6EWjPcXvVvmwyNk0X0B-AEYfDJNEApcJPzuLv1e5E0eUFSB376C0DT1b_irezC17aymseoMDA83K1ogCcv6yeHbuurxaGVhF8fEx5eivmLYAVRvZASA79Szs51aJqjPpW3rqP64RY/s1600/Pic3.JPG"></a><br />
<div>
<div>
<b>New Scopes in JSF2.x</b><br />
<div style="font-weight: normal;">
<br />
In JSF2, beans can defined in two additional scopes apart from the existing scopes (request, session and application scope). Those are View Scope and Flash Scope</div>
<br />
<div style="font-weight: normal;">
ViewScope:</div>
<ol style="font-weight: normal;">
<li>Defining a bean in view scope: Bean can be defined in view scope using the annotation @ViewScoped (javax.faces.bean.ViewScoped). Beans can be defined through annotations from JSF2 and is not required to define in the faces-config.xml file. </li>
<br />
<li>Beans of viewscope shall be alive till the current view (page) is active. That is the bean shall be alive till the user interacts with the same page and doesn’t navigate to new view (page). <img alt="" border="0" id="BLOGGER_PHOTO_ID_5726766686608869986" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHKX8inHXRsH3b0epAlLTY7ABoDD8ZRbOcZCuL9zchz7nhs7R28Km-GoC1MSN1eaYascKE5Yd3FIV-bGLgmGo_jCGfwJb_XFnUHrQSfQVbT95aDQr5d9mIdTPahuNQpYa21rXRBUFBZ6U/s320/pic1.png" style="cursor: hand; display: block; height: 125px; margin: 0px auto 10px; text-align: center; width: 314px;" /></li>
<br />
<li>The scope of viewscope is higher than the request and less to session scope.</li>
<br />
<li>If the same page is returned in the action method, the bean shall be dead and shall not be retained in view scope, since the same view is recreated again. </li>
</ol>
<br />
<div style="font-weight: normal; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">
FlashScope:</div>
<ol style="font-weight: normal;">
<li>The object placed in the flash scope shall be retained till the next request cycle. Thereafter it is destroyed. It is handy and most commonly used for post-redirect-get cycle where the messages need to be transferred to the request on a redirect</li>
<br />
<li>Placing object in a FlashScope: (in the below example also note the redirection done using the the attribute “faces-redirect=true”</li>
<em><span style="font-size: 85%;"></span></em><em><span style="font-size: 85%;">public String save() {<br />Flash flash=FacesContext.getCurrentInstance().getExternalContext().getFlash();<br />flash.put("name",this.name);<br />return "welcome?faces-redirect=true";<br />}</span></em><br />
<li>The flash scoped objects shall accessed using the EL object flash.<br /><span style="font-size: 85%;"><em><h:outputLabel value="Hi #{flash.name}"</h:outputLabel></em></span></li>
</ol>
<br />
<div style="font-weight: normal;">
<br /></div>
</div>
</div>
</div>Sathishhttp://www.blogger.com/profile/13077114304120944836noreply@blogger.com0tag:blogger.com,1999:blog-622411316080059845.post-90808736975380435622011-02-27T06:31:00.000-08:002012-04-03T08:10:59.424-07:00Robin Sharma speech at chennai<div dir="ltr" style="text-align: left;" trbidi="on">
Recently I had an opportunity to listen the Robin Sharma’s speech. I had read couple of his book and the way he portrays the leadership value through story has made me to get through his work. Below are few notes from his speech,<br />
<br />
Leadership is all about<br />
<br />
1. Impact, Influence and Inspiration<br />
2. What do we do when no one is watching<br />
3. Way I do one thing is way I do everything<br />
4. Double the income, triple the learning<br />
5. Behavior broadcast the values<br />
6. Become a rock star at work<br />
7. Lead yourself first<br />
8. Take care of relationship and money takes care of itself<br />
<br />
The points seem to be more of the one that we would have heard through all the time from different people. But when it was put through with strong examples, by a proven person it really gets into our mind. Is this what he was referring to creation of impact and influence? In that case he seems to be leader for himself for keeping his words through his work.<br />
<br />
He then spoke about few key points which the successive people have been following<br />
<br />
1. Get Up Early and do some workouts and readings<br />
2. No excuses.<br />
3. Don’t check email in the morning<br />
4. Learn to say “No” with respect<br />
5. No gossips, No critcs, No Negative<br />
6. Understand clarity provides mastery<br />
7. Eat less<br />
8. Super hydrate<br />
9. Take an hour nap<br />
10. Aware of environments<br />
11. Understand you become your association<br />
<br />
<br />
I felt the above words were really useful as I failed in most of them. Atleast I knew these were important. There were few tactics that he put across which seems to be useful<br />
<br />
1. Avoid radio star syndrome and be authentic<br />
2. You are in show business, Practice before stage<br />
3. Win is the motivation + momentum<br />
4. Distraction is enemy of production<br />
5. Technology free period and solitude work<br />
6. Leave your ego at the door and give what you can<br />
7. Develop leadership language<br />
8. Launce a beta and then iterate daily<br />
9. Be inspirational.<br />
<br />
Hmmm above were few of what I took notes. It was like cyclone of thoughts and words that were put across the mind. Sure it will have impact only if those words were categorically put in to actions. Finally got an opportunity to take a snap and autograph with him. Seems to be little childish when self and friend were eager to get a snap and autograph. But everyone present there were professionals and everyone were crazy.</div>Sathishhttp://www.blogger.com/profile/13077114304120944836noreply@blogger.com1tag:blogger.com,1999:blog-622411316080059845.post-65035957467364041242010-05-22T22:47:00.000-07:002012-04-03T08:11:23.832-07:00A disaster travel<div dir="ltr" style="text-align: left;" trbidi="on">
It was Saturday morning and when i switched on the TV, it was a shocking news once again on the flight crash. Its the Mangalore air tragedy. There were all speculation on whether it was pilot error on overshoot landing, critical airport, table top airport, expat pilot, etc etc., There were all lots of different sequences coming up.<br />
<br />
But it was all about 150 plus dreams, goals, aspirations that have come to an end. They would have traveled to see their loved ones, few returning homes and all would have been at joy till the final moment until the aircraft made its touch down for this end. Nobody would ever thought its going to be the end of travel of their life.<br />
<br />
A person of age 27 who was traveling to attend his father funeral, his life has come to an end, but the watch he forgot to take and left at his residence is still ticking and now it became a remembrance one. An entire family of 15 were traveling and all lost their life. One person has identified their loved one body with a wedding ring.<br />
<br />
The relatives were awaiting outside the airport to have a look at their loved ones, but when they did hear this news, we can imagine how much pain they would have undergone. The pain the travelers would have felt at that last moment of their life. What would have run in their mind during this moment. Its definitely unimaginable. There were many awaiting outside the mortuary to collect their loved ones bodies. But few would not know that it would take at least a week to complete the DNA test to identify the body.<br />
<br />
This incident is not the first, there were many air disasters earlier in our country, and the other incidents such as Mumbai 26/11 attack, Kolkata fire incident etc., etc., puts lots of questions on security elapse, negligence, human error etc., Is our public organization is growing in par with our economy and countries growth? Do we have adequate infrastructure in accommodate our countries growth? And lots more questions that the citizens has and definitely we doesn't know who is responsible and who would answer these?<br />
<br />
But what ever may be the reason, lets hope that this is the last incident and never would happen again and let the souls rest in peace.</div>Sathishhttp://www.blogger.com/profile/13077114304120944836noreply@blogger.com0