<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3087911079930449829</id><updated>2011-04-21T20:03:08.979-07:00</updated><title type='text'>Woodstock Components</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://ashlesha-woodstock.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3087911079930449829/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://ashlesha-woodstock.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Ashlesha Patil</name><uri>http://www.blogger.com/profile/09759848899787194878</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3087911079930449829.post-1592847642989666363</id><published>2008-05-02T11:57:00.000-07:00</published><updated>2008-05-03T10:06:06.255-07:00</updated><title type='text'></title><content type='html'>In my previous blog at '&lt;a href="http://ashleshapatil.blogspot.com/"&gt;http://ashleshapatil.blogspot.com/&lt;/a&gt;' , I have discussed Woodstock components and  have explained how to use these components in 'numberquiz' example from  'Core JSF' book. Proceeding  to  the  next example  from  'Core JSF'  , let's see how to use the javascript with Woodstock components. I have converted the JSF tags used in  'javascript' example from chapter number four of ' Core JSF'  to Woodstock tags. Let's have a look at the application snapshots:&lt;br /&gt;&lt;pre&gt;   with JSF tags:              with woodstock tags:&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_NkqHbLi3sx4/SBt_v2re5qI/AAAAAAAAAFU/okVmavJiG1I/s1600-h/application_jsf.bmp"&gt;&lt;img style="cursor: pointer;" src="http://3.bp.blogspot.com/_NkqHbLi3sx4/SBt_v2re5qI/AAAAAAAAAFU/okVmavJiG1I/s400/application_jsf.bmp" alt="" id="BLOGGER_PHOTO_ID_5195887055210473122" border="0" /&gt;&lt;/a&gt;   &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_NkqHbLi3sx4/SBt_zmre5rI/AAAAAAAAAFc/mQqj72qskHY/s1600-h/application_woodstock.bmp"&gt;&lt;img style="cursor: pointer;" src="http://2.bp.blogspot.com/_NkqHbLi3sx4/SBt_zmre5rI/AAAAAAAAAFc/mQqj72qskHY/s400/application_woodstock.bmp" alt="" id="BLOGGER_PHOTO_ID_5195887119634982578" border="0" /&gt;&lt;/a&gt;&lt;/pre&gt;In this example, a javascript function is used to confirm that password field matches with password confirm field. Here is the 'index.jsp' page with the Woodstock components and the javascript function.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt  jsp:root version="2.1" xmlns:f="http://java.sun.com/jsf/core"&lt;br /&gt;                          xmlns:h="http://java.sun.com/jsf/html" &lt;br /&gt;                          xmlns:jsp="http://java.sun.com/JSP/Page" &lt;br /&gt;                          xmlns:w="http://www.sun.com/webui/webuijsf" &amp;gt &lt;br /&gt;    &amp;lt jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/      &lt;br /&gt;    &lt;br /&gt;    &amp;lt w:html &amp;gt &lt;br /&gt;        &amp;lt w:head &amp;gt  &lt;br /&gt;            &amp;lt title &amp;gt &amp;lt w:staticText text="#{msgs.windowTitle}"/ &amp;gt &amp;lt /title &amp;gt &lt;br /&gt;        &amp;lt /w:head &amp;gt &lt;br /&gt;        &amp;lt w:body &amp;gt &lt;br /&gt;            &amp;lt w:form id="registerForm" &amp;gt &lt;br /&gt;                &amp;lt table &amp;gt &lt;br /&gt;                    &amp;lt tr &amp;gt &lt;br /&gt;                        &amp;lt td &amp;gt &lt;br /&gt;                            &amp;lt w:staticText text="#{msgs.namePrompt}"/ &amp;gt &lt;br /&gt;                        &amp;lt /td &amp;gt &lt;br /&gt;                        &amp;lt td &amp;gt &lt;br /&gt;                            &amp;lt w:textField/ &amp;gt &lt;br /&gt;                        &amp;lt /td &amp;gt &lt;br /&gt;                    &amp;lt /tr &amp;gt &lt;br /&gt;                    &amp;lt tr &amp;gt &lt;br /&gt;                        &amp;lt td &amp;gt &lt;br /&gt;                            &amp;lt w:staticText text="#{msgs.passwordPrompt}"/ &amp;gt &lt;br /&gt;                        &amp;lt /td &amp;gt &lt;br /&gt;                        &amp;lt td &amp;gt &lt;br /&gt;                            &amp;lt w:passwordField id="password"/ &amp;gt &lt;br /&gt;                        &amp;lt /td &amp;gt &lt;br /&gt;                    &amp;lt /tr &amp;gt &lt;br /&gt;                    &amp;lt tr &amp;gt &lt;br /&gt;                        &amp;lt td &amp;gt &lt;br /&gt;                            &amp;lt w:staticText text="#{msgs.confirmPasswordPrompt}"/ &amp;gt &lt;br /&gt;                        &amp;lt /td &amp;gt &lt;br /&gt;                        &amp;lt td &amp;gt &lt;br /&gt;                            &amp;lt w:passwordField id="passwordConfirm"/ &amp;gt &lt;br /&gt;                        &amp;lt /td &amp;gt &lt;br /&gt;                    &amp;lt /tr &amp;gt &lt;br /&gt;                &amp;lt /table &amp;gt &lt;br /&gt;                &amp;lt w:button text="Submit Form" primary="true"&lt;br /&gt;                          onClick="checkPassword()"  / &amp;gt &lt;br /&gt;            &amp;lt /w:form &amp;gt &lt;br /&gt;            &lt;br /&gt;            &amp;lt w:script &amp;gt &lt;br /&gt;                function checkPassword() {&lt;br /&gt;                var password = document.getElementById("registerForm:password").&lt;br /&gt;getProps().value;&lt;br /&gt;                var passwordConfirm = document.getElementById&lt;br /&gt;("registerForm:passwordConfirm").getProps().value;&lt;br /&gt;                if(password == passwordConfirm)&lt;br /&gt;                form.submit();&lt;br /&gt;                else&lt;br /&gt;                alert("Password and password confirm fields don't match");&lt;br /&gt;                }&lt;br /&gt;                &lt;br /&gt;            &amp;lt /w:script &amp;gt &lt;br /&gt;            &lt;br /&gt;        &amp;lt /w:body &amp;gt &lt;br /&gt;    &amp;lt /w:html &amp;gt &lt;br /&gt;    &amp;lt /jsp:root &amp;gt &lt;br /&gt;&lt;/pre&gt;    &lt;br /&gt;&lt;br /&gt;And here are the steps:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Include the 'webuijsf' tag library in the JSP page. You do not have to use this long‭ '‬webuijsf‭' ‬prefix.‭ ‬Instead‭ ‬you can‭ ‬just‭ ‬change it to something simpler‭ –‬ for eg.‭ ‬using‭ ‬ 'w:‭' ‬would‭ ‬work‭ ‬just‭ ‬fine‭ ‬-‭ &lt;‬jsp:root version‭="‬2.1‭" ‬xmlns:w‭="‬http://www.sun.com/webui/webuijsf‭"&gt;&lt;/li&gt;&lt;li&gt;Start the page with the&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;w:page&lt;/span&gt; tag to indicate the beginning of the Web UI Components. After opening the &lt;span style="font-family:courier new;"&gt;w:page&lt;/span&gt; tag, you must first use the &lt;span style="font-family:courier new;"&gt;w:html&lt;/span&gt; and the &lt;span style="font-family:courier new;"&gt;w:head&lt;/span&gt; tags. Then you must use either the &lt;span style="font-family:courier new;"&gt;w:body&lt;/span&gt; tag or the &lt;span style="font-family:courier new;"&gt;w:frameset&lt;/span&gt; tag.&lt;/li&gt;&lt;li&gt;Change the &lt;span style="font-family:courier new;"&gt;h:form&lt;/span&gt; tag to the Woodstock form tag - &lt;span style="font-family:courier new;"&gt;w:form.&lt;span style=";font-family:georgia;font-size:100%;"  &gt;Specify the 'id' attribute,  so that it can be referenced from the scrip function.  For eg. &lt; id="registerForm"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;Replace the remaining JSF tags with the corresponding Woodstock tags. As you can see in the above code snippet, &lt;span style="font-family:courier new;"&gt;h:outputText, h:inputText, h:inputSecret &lt;/span&gt;and &lt;span style="font-family:courier new;"&gt;h:commandButton&lt;/span&gt; have been replaced with the &lt;span style="font-family:courier new;"&gt;w:staticText, w:textField, w:passwordField&lt;/span&gt;    and &lt;span style="font-family:courier new;"&gt;w:button&lt;/span&gt; tags respectively. (The attribute specifications of Woodstock tags are well explained in the TLD documentation at &lt;a href="http://webdev2.sun.com/woodstock-tlddocs"&gt;http://webdev2.sun.com/woodstock-tlddocs&lt;/a&gt;).&lt;/li&gt;&lt;li&gt;Embed the javascript code inside &lt;span style="font-family:courier new;"&gt;w:script tag.&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;The &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;w:script&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; tag must be used within  the &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;w:head&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; tag, or within the &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;w:body&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; tag.&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;To get the component's value in the javascript function, invoke &lt;span style="font-family:courier new;"&gt;document.getElementById(id).getProps().value&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;Add the required libraries. For the above example you will need to add 'Web UI Components', 'JSF 1.1/1.2 Support' and 'Web UI Default Theme' libraries.&lt;/li&gt;&lt;/ul&gt;The complete source code of the above example can be found at &lt;a href="http://patils.ashlesha.googlepages.com/woodstock"&gt;http://patils.ashlesha.googlepages.com/woodstock&lt;/a&gt; as 'ch04_javascript' .&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3087911079930449829-1592847642989666363?l=ashlesha-woodstock.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ashlesha-woodstock.blogspot.com/feeds/1592847642989666363/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3087911079930449829&amp;postID=1592847642989666363' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3087911079930449829/posts/default/1592847642989666363'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3087911079930449829/posts/default/1592847642989666363'/><link rel='alternate' type='text/html' href='http://ashlesha-woodstock.blogspot.com/2008/05/in-my-previous-blog-at.html' title=''/><author><name>Ashlesha Patil</name><uri>http://www.blogger.com/profile/09759848899787194878</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_NkqHbLi3sx4/SBt_v2re5qI/AAAAAAAAAFU/okVmavJiG1I/s72-c/application_jsf.bmp' height='72' width='72'/><thr:total>2</thr:total></entry></feed>
