<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>richfaces &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/richfaces/</link>
	<description>Feed of posts on WordPress.com tagged "richfaces"</description>
	<pubDate>Fri, 04 Dec 2009 21:17:48 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[What Java EE Server do you use?]]></title>
<link>http://technicalbrainwave.wordpress.com/2009/11/30/what-java-ee-server-do-you-use/</link>
<pubDate>Mon, 30 Nov 2009 14:59:59 +0000</pubDate>
<dc:creator>Gift Sam</dc:creator>
<guid>http://technicalbrainwave.wordpress.com/2009/11/30/what-java-ee-server-do-you-use/</guid>
<description><![CDATA[Java EE servers are based on the Java™ 2 Platform, Enterprise Edition (J2EE™) and is used widely to ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Java EE servers are based on the Java™ 2 Platform, Enterprise Edition (J2EE™) and is used widely to provide code portability, reuse across tiers, platform support, scalability and for EJB strengths. Instead these supports are provided by the most of the java EE servers, this article is the place where you can share the Java EE servers used during your project development. I have assessed most of the Java EE servers used by the developers in the below. <em><strong>Kindly choose the Java EE server which you use, besides if you have time share the reason why you choose the particular Java EE server for your project development.</strong></em> Also if your option is others remark your Java EE server in the comments.</p>
<a name="pd_a_2320814"></a><div class="PDS_Poll" id="PDI_container2320814" style="display:inline-block;"></div><script type="text/javascript" language="javascript" charset="utf-8" src="http://static.polldaddy.com/p/2320814.js"></script>
		<noscript>
		<a href="http://answers.polldaddy.com/poll/2320814/">View This Poll</a><br/><span style="font-size:10px;"><a href="http://www.polldaddy.com">surveys</a></span>
		</noscript>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Resizable JSF Components Using PrimeFaces]]></title>
<link>http://shunmugakrishna.wordpress.com/2009/11/28/resizable-jsf-components-using-primefaces-2/</link>
<pubDate>Sat, 28 Nov 2009 14:35:13 +0000</pubDate>
<dc:creator>shunmugakrishna</dc:creator>
<guid>http://shunmugakrishna.wordpress.com/2009/11/28/resizable-jsf-components-using-primefaces-2/</guid>
<description><![CDATA[Introduction Whenever I surf the net, I used to ponder whether there is any options that allows the ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><strong>Introduction</strong></p>
<p>Whenever I surf the net, I used to ponder whether there is any options that allows the end user to resize the components of  a web application developed in JSF. But in all this failed to discover a component like that. But now Primefaces has got the option to resize any components in JSF. Once again I was impressed at the peculiar features of Primefaces which has a resizable component that has the ability to resize all the components of JSF. Even I tried this out in Richfaces Panel, this worked without any conflicts. In this article I am going to explain how to implement a resizable option for the Richfaces panel and data table columns. This would be helpful to see the long data((ie)Wrapped data) in the column of a data table.</p>
<p><strong>Prerequisites</strong></p>
<ul>
<li> IDE – Your favourite IDE</li>
<li> Tomcat 6.x/Glassfish/Jboss</li>
<li> JDK 1.5 and above</li>
</ul>
<p>I assume that you had configured the Primefaces in your favourite IDE and now in this article let us see a sample , how to implement the resizable tag for the Richfaces panel  and the data table column. <!--more-->Fisrt let us create a backing bean class named ResizableBean.</p>
<p><em><strong>ResizableBean.java</strong></em></p>
<p>This class contains the actual data for the data table.</p>
<pre class="brush: css;">

package com.shunmuga.primefaces;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author shunmuga
 */
public class ResizableBean
{

 private List dataTableBeanList = new ArrayList();

 /**
 * Create new Instance of the class
 */
 public ResizableBean()
 {
 initialzeComponents();
 }

 /**
 * This method is used to populate the required data table
 * data when the constructor is initialized.
 */
 private void initialzeComponents()
 {
  dataTableBeanList.clear();

 DataTableBean dataTableBean = new DataTableBean();
 dataTableBean.setWonders(&#34;Machu Picchu&#34;);
 dataTableBean.setCountry(&#34;Peru&#34;);
 dataTableBean.setDateOfConstruction(&#34;1460-1470&#34;);
 dataTableBean.setImagePath(&#34;./image/Machu_Picchu.jpg&#34;);
 dataTableBeanList.add(dataTableBean);

 dataTableBean = new DataTableBean();
 dataTableBean.setWonders(&#34;Giza Pyramid Complex&#34;);
 dataTableBean.setCountry(&#34;Egypt&#34;);
 dataTableBean.setDateOfConstruction(&#34;2584-2561 BC&#34;);
 dataTableBean.setImagePath(&#34;./image/pyramid.jpg&#34;);
 dataTableBeanList.add(dataTableBean);

 dataTableBean = new DataTableBean();
 dataTableBean.setWonders(&#34;Taj Mahal&#34;);
 dataTableBean.setCountry(&#34;Agra,India&#34;);
 dataTableBean.setDateOfConstruction(&#34;1630 A.D.&#34;);
 dataTableBean.setImagePath(&#34;./image/Taj_Mahal.jpg&#34;);
 dataTableBeanList.add(dataTableBean);

 dataTableBean = new DataTableBean();
 dataTableBean.setWonders(&#34;Petra&#34;);
 dataTableBean.setCountry(&#34;Jordan&#34;);
 dataTableBean.setDateOfConstruction(&#34;9 B.C. – 40 A.D.&#34;);
 dataTableBean.setImagePath(&#34;./image/PetraMonastery.jpg&#34;);
 dataTableBeanList.add(dataTableBean);

 dataTableBean = new DataTableBean();
 dataTableBean.setWonders(&#34;Great Wall of China&#34;);
 dataTableBean.setCountry(&#34;China&#34;);
 dataTableBean.setDateOfConstruction(&#34;220 B.C and 1368 – 1644 A.D.&#34;);
 dataTableBean.setImagePath(&#34;./image/GreatWallNearBeijingWinter.jpg&#34;);
 dataTableBeanList.add(dataTableBean);

 dataTableBean = new DataTableBean();
 dataTableBean.setWonders(&#34;Christ the Redeemer&#34;);
 dataTableBean.setCountry(&#34;Brazil&#34;);
 dataTableBean.setDateOfConstruction(&#34;1931&#34;);
 dataTableBean.setImagePath(&#34;./image/CorcovadofotoRJ.jpg&#34;);
 dataTableBeanList.add(dataTableBean);

 dataTableBean = new DataTableBean();
 dataTableBean.setWonders(&#34;Colosseum&#34;);
 dataTableBean.setCountry(&#34;Rom Italy&#34;);
 dataTableBean.setDateOfConstruction(&#34;70 – 82 A.D&#34;);
 dataTableBean.setImagePath(&#34;./image/Colosseum.jpg&#34;);
 dataTableBeanList.add(dataTableBean); }

 /**
 * @return the dataTableBeanList
 */
 public List getDataTableBeanList()
 {
 return dataTableBeanList;
 }

 /**
 * @param dataTableBeanList the dataTableBeanList to set
 */
 public void setDataTableBeanList(List dataTableBeanList)
 {
 this.dataTableBeanList = dataTableBeanList;
 }
}
</pre>
<p>DataTableBean.java class contains the required data to populate the data table which has four columns they are wonder, country, date of construction and the image of the seven wonders.</p>
<pre class="brush: css;">

package com.shunmuga.primefaces;

/**
 *
 * @author shunmuga
 */
public class DataTableBean
{

 public DataTableBean()
 {
 }
 private String wonders;
 private String country;
 private String dateOfConstruction;
 private String imagePath;

 /**
 * @return the country
 */
 public String getCountry()
 {
 return country;
 }

 /**
 * @param country the country to set
 */
 public void setCountry(String country)
 {
 this.country = country;
 }

 /**
 * @return the wonders
 */
 public String getWonders()
 {
 return wonders;
 }

 /**
 * @param wonders the wonders to set
 */
 public void setWonders(String wonders)
 {
 this.wonders = wonders;
 }

 /**
 * @return the dateOfConstruction
 */
 public String getDateOfConstruction()
 {
 return dateOfConstruction;
 }

 /**
 * @param dateOfConstruction the dateOfConstruction to set
 */
 public void setDateOfConstruction(String dateOfConstruction)
 {
 this.dateOfConstruction = dateOfConstruction;
 }

 /**
 * @return the imagePath
 */
 public String getImagePath()
 {
 return imagePath;
 }

 /**
 * @param imagePath the imagePath to set
 */
 public void setImagePath(String imagePath)
 {
 this.imagePath = imagePath;
 }
}
</pre>
<p>Now the datas are populated in the data table and now let us construct a managed bean for the ResizableBean class in the faces-config.xml</p>
<pre class="brush: css;">

&#60;faces-config version=&#34;1.2&#34;
 xmlns=&#34;http://java.sun.com/xml/ns/javaee&#34;
 xmlns:xsi=&#34;http://www.w3.org/2001/XMLSchema-instance&#34;
 xsi:schemaLocation=&#34;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd&#34;&#62;
&#60;managed-bean&#62;
 &#60;description&#62;Managed bean for Resizable jsf components&#60;/description&#62;
 &#60;managed-bean-name&#62;ResizableBean&#60;/managed-bean-name&#62;
 &#60;managed-bean-class&#62;com.shunmuga.primefaces.ResizableBean&#60;/managed-bean-class&#62;
 &#60;managed-bean-scope&#62;request&#60;/managed-bean-scope&#62;
&#60;/managed-bean&#62;

&#60;/faces-config&#62;
</pre>
<p>And finally we need create a JSP page. Let us name the JSP document as resize.jsp and it contains the following code</p>
<pre class="brush: css;">

&#60;%--
 Document   : resize
 Created on : Nov 28, 2009, 6:29:55 PM
 Author     : shunmuga
--%&#62;

&#60;%@page contentType=&#34;text/html&#34; pageEncoding=&#34;UTF-8&#34;%&#62;

&#60;%@taglib prefix=&#34;f&#34; uri=&#34;http://java.sun.com/jsf/core&#34;%&#62;
&#60;%@taglib prefix=&#34;h&#34; uri=&#34;http://java.sun.com/jsf/html&#34;%&#62;
&#60;%@ taglib uri=&#34;http://richfaces.org/a4j&#34; prefix=&#34;a4j&#34;%&#62;
&#60;%@ taglib uri=&#34;http://richfaces.org/rich&#34; prefix=&#34;rich&#34;%&#62;
&#60;%@taglib uri=&#34;http://primefaces.prime.com.tr/ui&#34; prefix=&#34;p&#34; %&#62;
&#60;!DOCTYPE HTML PUBLIC &#34;-//W3C//DTD HTML 4.01 Transitional//EN&#34;
 &#34;http://www.w3.org/TR/html4/loose.dtd&#34;&#62;

&#60;f:view&#62;
 &#60;html&#62;
 &#60;head&#62;
 &#60;meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=UTF-8&#34;/&#62;
 &#60;title&#62;Resize JSF Components&#60;/title&#62;
 &#60;p:resources/&#62;
 &#60;/head&#62;
 &#60;body&#62;
 &#60;h:form id=&#34;resizeComponentPageForm&#34;&#62;

 &#60;rich:panel header=&#34;New Seven Wonders of the World&#34; style=&#34;position:relative; width: 500px;&#34;&#62;

 &#60;%-- Resize the panel using following tag --%&#62;

 &#60;p:resizable animate=&#34;true&#34; effect=&#34;bounceOut&#34;/&#62;

 &#60;%--DataTable contains seven wonders details --%&#62;

 &#60;p:dataTable value=&#34;#{DataExporterBean.dataTableBeanList}&#34;
 id=&#34;Wonders&#34;
 rows=&#34;7&#34;
 var=&#34;dataTableBean&#34;&#62;

 &#60;%-- wonders column --%&#62;

 &#60;p:column&#62;
 &#60;f:facet name=&#34;header&#34;&#62;
 &#60;h:outputText value=&#34;Wonders&#34; /&#62;
 &#60;/f:facet&#62;
 &#60;h:outputText value=&#34;#{dataTableBean.wonders}&#34; /&#62;
 &#60;/p:column&#62;

 &#60;%-- country name column --%&#62;

 &#60;p:column&#62;
 &#60;f:facet name=&#34;header&#34;&#62;
 &#60;h:outputText value=&#34;Country&#34; /&#62;
 &#60;/f:facet&#62;
 &#60;h:outputText value=&#34;#{dataTableBean.country}&#34; /&#62;
 &#60;/p:column&#62;

 &#60;%-- Resize option enable dateOfConstruction column --%&#62;

 &#60;p:column resizable=&#34;true&#34;&#62;
 &#60;f:facet name=&#34;header&#34;&#62;
 &#60;h:outputText value=&#34;Date OF Construction&#34; /&#62;
 &#60;/f:facet&#62;
 &#60;h:outputText value=&#34;#{dataTableBean.dateOfConstruction}&#34;/&#62;
 &#60;/p:column&#62;

 &#60;%-- Resize option enable Wonders image column --%&#62;

 &#60;p:column resizable=&#34;true&#34;&#62;
 &#60;f:facet name=&#34;header&#34;&#62;
 &#60;h:outputText value=&#34;Image&#34; /&#62;
 &#60;/f:facet&#62;
 &#60;p:graphicImage value=&#34;#{dataTableBean.imagePath}&#34;/&#62;
 &#60;/p:column&#62;
 &#60;/p:dataTable&#62;

 &#60;/rich:panel&#62;
 &#60;/h:form&#62;
 &#60;/body&#62;
 &#60;/html&#62;
&#60;/f:view&#62;
</pre>
<p>By now we had completed the coding part and now let us have a look on the snap shot of our sample resizable application.</p>
<p><em><strong>First Snap Shot<br />
</strong></em></p>
<p>This is the actual snap of our sample resizable application. If you look the below snap with fixed eyes, you can see an option to resize the richfaces component represented in the right side of the panel margin.</p>
<p><a href="http://shunmugakrishna.wordpress.com/files/2009/11/resize.jpg"><img title="resize" src="http://shunmugakrishna.wordpress.com/files/2009/11/resize.jpg" alt="" width="600" height="484" /></a></p>
<p><em><strong>Second Snap shot</strong></em></p>
<p>This snap shot shows the resized Richfaces panel of our sample application.</p>
<p><a href="http://shunmugakrishna.wordpress.com/files/2009/11/resizepanel1.jpg"><img title="resizePanel1" src="http://shunmugakrishna.wordpress.com/files/2009/11/resizepanel1.jpg" alt="" width="600" height="387" /></a></p>
<p><em><strong> Third Snap shot</strong></em></p>
<p>This snap shows, how the column(the column with the header named &#8220;Image&#8221;) of the data table can be resized in our application.</p>
<p><a href="http://shunmugakrishna.wordpress.com/files/2009/11/optionalcolumnresize.jpg"><img title="OptionalColumnResize" src="http://shunmugakrishna.wordpress.com/files/2009/11/optionalcolumnresize.jpg" alt="" width="600" height="388" /></a></p>
<p>I believe this article clearly explains, re sizable functionality of a JSF component. If you find this article is useful to you, Dont forget to leave your valuable comments. Have a joyous day.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[JSF and Richfaces configuration in Netbeans 6.x]]></title>
<link>http://shunmugakrishna.wordpress.com/2009/11/22/jsf-and-richfaces-configurations-in-netbeans6-x/</link>
<pubDate>Sun, 22 Nov 2009 02:13:45 +0000</pubDate>
<dc:creator>shunmugakrishna</dc:creator>
<guid>http://shunmugakrishna.wordpress.com/2009/11/22/jsf-and-richfaces-configurations-in-netbeans6-x/</guid>
<description><![CDATA[Introduction: JSF (Java Server Faces) is an java based  framework  for developing web application . ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><strong>Introduction:</strong></p>
<p>JSF (Java Server Faces) is an java based  framework  for developing web application . Also component library can be easily incorporated in to the JSF Application. I have listed the most used components libraries by the developers in the below.</p>
<ul>
<li><a href="http://livedemo.exadel.com/richfaces-demo/index.jsp" target="_blank">JBoss Richfaces</a></li>
<li><a href="https://woodstock.dev.java.net/Documentation.htm" target="_blank">Woodstock</a></li>
<li><a href="http://www.icefaces.org/main/demos/" target="_blank">Icefaces</a></li>
<li><a href="http://myfaces.apache.org/tomahawk/index.html" target="_blank">MyFaces Tomahawk</a></li>
<li><a href="http://myfaces.apache.org/tobago/index.html" target="_blank">MyFaces Tobaco</a></li>
<li><a href="http://primefaces.prime.com.tr/en/" target="_blank">Prime Faces</a></li>
<li><a href="http://www.jscape.com/webgalileofaces/" target="_blank">WebGalileo Faces</a></li>
<li><a href="http://openfaces.org/" target="_blank">Open Faces</a></li>
<li><a href="http://vaadin.com/home">Vaadin</a></li>
</ul>
<p>But this articles explains the Installation guidelines of Richfaces with JSF in Netbeans 6.x. Additionally learn how to create a hello world application in JSF using Richfaces. I assume that you have the requirements which I had mentioned below</p>
<p><strong>Requirements:</strong></p>
<ul>
<li>IDE – Netbeans 6.x</li>
<li>Tomcat 6.x/Glassfish/Jboss</li>
<li>JDK 1.5 and above</li>
</ul>
<p><strong>Configuration Steps:</strong></p>
<p>Configuring Richfaces with JSF application in Netbeans6.x can be accomplished by 4 easy steps <!--more-->they are,</p>
<ol>
<li>Create the web application project</li>
<li>Required jars(Library)</li>
<li>Deployment descriptor configuration(web.xml)</li>
<li>Hello world JSP page</li>
</ol>
<p><strong>Create the web application project:</strong></p>
<p>First Let us create the web application project in JSF, by clicking the File in the menu and select New Project in the Netbeans6.x, I have stated an image for your clear understandings,</p>
<p><a href="http://shunmugakrishna.files.wordpress.com/2009/11/untitled1.jpg"><img title="Project Creation First Image" src="http://shunmugakrishna.files.wordpress.com/2009/11/untitled1.jpg?w=500&#038;h=342#38;h=342" alt="" width="500" height="342" /></a></p>
<p>Once this window appears choose web application and click next. Now you will have the window which I had mentioned below</p>
<p><a href="http://shunmugakrishna.files.wordpress.com/2009/11/projectname4.jpg"><img title="Project Creation Second Image" src="http://shunmugakrishna.files.wordpress.com/2009/11/projectname4.jpg?w=500&#038;h=342#38;h=342" alt="" width="500" height="342" /></a></p>
<p>In the preceding window, Let us name and location of the project. Since my article explains the creation of  Hello world Application I have given the Name as HelloWorld and then click next. Now you will have the window which I had mentioned below</p>
<p><a href="http://shunmugakrishna.files.wordpress.com/2009/11/chooseserver4.jpg"><img title="Project Creation Third Image" src="http://shunmugakrishna.files.wordpress.com/2009/11/chooseserver4.jpg?w=500&#038;h=342#38;h=342" alt="" width="500" height="342" /></a></p>
<p>In the preceding window, Let us select the server(Your favorite Server) and click next</p>
<p><a href="http://shunmugakrishna.files.wordpress.com/2009/11/framework-choosen1.jpg"><img title="Project Creation Fourth Image" src="http://shunmugakrishna.files.wordpress.com/2009/11/framework-choosen1.jpg?w=500&#038;h=342#38;h=342" alt="" width="500" height="342" /></a></p>
<p>In the preceding window, Let us select the JavaServerFaces framework from the check box and click finish. So far we had created a JSF web application project in Netbeans6.x and next let us configure the Jar files for our web application.</p>
<p><strong>Required jars(Library)</strong></p>
<p><a href="http://www.jboss.org/richfaces/download/archive.html" target="_blank">Click here</a> to download the following required latest richfaces jars</p>
<ul>
<li>richfaces-api-3.3.1.GA.jar</li>
<li>richfaces-impl-3.3.1.GA.jar</li>
<li>richfaces-ui-3.3.1.GA.jar</li>
</ul>
<p><strong>Deployment descriptor(DD) configuration(web.xml):</strong></p>
<pre class="brush: css;">

&#60;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&#62;
&#60;web-app version=&#34;2.5&#34; xmlns=&#34;http://java.sun.com/xml/ns/javaee&#34; xmlns:xsi=&#34;http://www.w3.org/2001/XMLSchema-instance&#34; xsi:schemaLocation=&#34;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&#34;&#62;
 &#60;context-param&#62;
 &#60;param-name&#62;com.sun.faces.verifyObjects&#60;/param-name&#62;
 &#60;param-value&#62;false&#60;/param-value&#62;
 &#60;/context-param&#62;
 &#60;context-param&#62;
 &#60;param-name&#62;com.sun.faces.validateXml&#60;/param-name&#62;
 &#60;param-value&#62;true&#60;/param-value&#62;
 &#60;/context-param&#62;
 &#60;context-param&#62;
 &#60;param-name&#62;javax.faces.STATE_SAVING_METHOD&#60;/param-name&#62;
 &#60;param-value&#62;client&#60;/param-value&#62;
 &#60;/context-param&#62;
 &#60;servlet&#62;
 &#60;servlet-name&#62;Faces Servlet&#60;/servlet-name&#62;
 &#60;servlet-class&#62;javax.faces.webapp.FacesServlet&#60;/servlet-class&#62;
 &#60;load-on-startup&#62;1&#60;/load-on-startup&#62;
 &#60;/servlet&#62;
 &#60;servlet-mapping&#62;
 &#60;servlet-name&#62;Faces Servlet&#60;/servlet-name&#62;
 &#60;url-pattern&#62;/faces/*&#60;/url-pattern&#62;
 &#60;/servlet-mapping&#62;
 &#60;session-config&#62;
 &#60;session-timeout&#62;
 30
 &#60;/session-timeout&#62;
 &#60;/session-config&#62;
 &#60;welcome-file-list&#62;
 &#60;welcome-file&#62;index.jsp&#60;/welcome-file&#62;
 &#60;/welcome-file-list&#62;

 &#60;!-- Rich Faces configuration --&#62;

 &#60;!-- Specify the skin name --&#62;
 &#60;context-param&#62;
 &#60;param-name&#62;org.ajax4jsf.SKIN&#60;/param-name&#62;
 &#60;param-value&#62;laguna&#60;/param-value&#62;
 &#60;/context-param&#62;

 &#60;!--Rich faces skin apply for the standard jsf component also--&#62;
 &#60;context-param&#62;
 &#60;param-name&#62;org.richfaces.CONTROL_SKINNING&#60;/param-name&#62;
 &#60;param-value&#62;enable&#60;/param-value&#62;
 &#60;/context-param&#62;

 &#60;filter&#62;
 &#60;display-name&#62;RichFaces Filter&#60;/display-name&#62;
 &#60;filter-name&#62;Ajax4jsf&#60;/filter-name&#62;
 &#60;filter-class&#62;org.ajax4jsf.Filter&#60;/filter-class&#62;
 &#60;/filter&#62;

 &#60;filter-mapping&#62;
 &#60;filter-name&#62;Ajax4jsf&#60;/filter-name&#62;
 &#60;servlet-name&#62;Faces Servlet&#60;/servlet-name&#62;
 &#60;dispatcher&#62;REQUEST&#60;/dispatcher&#62;
 &#60;dispatcher&#62;FORWARD&#60;/dispatcher&#62;
 &#60;dispatcher&#62;INCLUDE&#60;/dispatcher&#62;
 &#60;/filter-mapping&#62;

 &#60;!--End of rich Faces configuration --&#62;

&#60;/web-app&#62;
</pre>
<p>Setup process of Primefaces in Netbeans6.x has been completed and now let us create a hello world page using Richfaces UI components. The following code should be conjured to do so,</p>
<p><strong>Hello world JSP page:</strong></p>
<pre class="brush: css;">

&#60;%--
 Document   : helloWorld
 Created on : Nov 22, 2009, 4:07:09 PM
 Author     : shunmuga
--%&#62;

&#60;%@page contentType=&#34;text/html&#34; pageEncoding=&#34;UTF-8&#34;%&#62;
&#60;!DOCTYPE HTML PUBLIC &#34;-//W3C//DTD HTML 4.01 Transitional//EN&#34;
 &#34;http://www.w3.org/TR/html4/loose.dtd&#34;&#62;

&#60;%@taglib uri=&#34;http://java.sun.com/jsf/html&#34; prefix=&#34;h&#34; %&#62;
&#60;%@taglib uri=&#34;http://java.sun.com/jsf/core&#34; prefix=&#34;f&#34; %&#62;
&#60;%@taglib uri=&#34;http://richfaces.org/a4j&#34; prefix=&#34;a4j&#34; %&#62;
&#60;%@taglib uri=&#34;http://richfaces.org/rich&#34; prefix=&#34;rich&#34;%&#62;

&#60;f:view&#62;
&#60;html&#62;
 &#60;head&#62;
 &#60;meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=UTF-8&#34;&#62;
 &#60;title&#62;JSP Page&#60;/title&#62;
 &#60;/head&#62;
 &#60;body&#62;
 &#60;h:form&#62;
 &#60;rich:panel style=&#34;position: relative; width: 400px;height: 150px;&#34;&#62;
 &#60;f:facet name=&#34;header&#34;&#62;
 &#60;h:outputText value=&#34;Hello world &#34;/&#62;

 &#60;/f:facet&#62;
 &#60;h:outputText value=&#34;Welcome to rich faces ...&#34;/&#62;
 &#60;/rich:panel&#62;
 &#60;/h:form&#62;

 &#60;/body&#62;
&#60;/html&#62;
&#60;/f:view&#62;
</pre>
<p>By invoking the above code, we had created a Hello World demo application which contains a Richfaces panel, Now let us have a look on the snap of our Hello World application.</p>
<p><strong>Screen Shot:</strong></p>
<p><a href="http://shunmugakrishna.wordpress.com/files/2009/11/sample2.jpg"><img class="alignnone size-full wp-image-70" title="sample" src="http://shunmugakrishna.wordpress.com/files/2009/11/sample2.jpg" alt="" width="417" height="168" /></a></p>
<p style="text-align:left;">If you find this article is useful to you dont forget to give your valuable comments. Have a joyous day.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Richfaces modal panel default formular action]]></title>
<link>http://ahoehma.wordpress.com/2009/11/16/richfaces-modal-panel-default-formular-action/</link>
<pubDate>Mon, 16 Nov 2009 14:35:01 +0000</pubDate>
<dc:creator>Andreas Höhmann</dc:creator>
<guid>http://ahoehma.wordpress.com/2009/11/16/richfaces-modal-panel-default-formular-action/</guid>
<description><![CDATA[Each input dialog should have a default action for good useability. If the user hit &#8216;Enter]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Each input dialog should have a default action for good useability.</p>
<p>If the user hit &#8216;Enter&#8217; then the default action should execute.</p>
<p>Here is my example of a richfaces modal edit dialog for such a requirement &#8230;</p>
<p>The dialog have input fields and 3 actions:</p>
<ul>
<li>save &#8211; is the default action if the user hit &#8216;<strong>Enter</strong>&#8216; anywhere in the formular</li>
<li>cancel &#8211; is  the default action if the user hit &#8216;<strong>Esc</strong>&#8216; anywhere in the formular</li>
<li>reset</li>
</ul>
<pre class="brush: xml;">
&#60;rich:modalPanel id=&#34;edit_dialog&#34;&#62;

   &#60;a4j:form id=&#34;edit_form&#34; ajaxSubmit=&#34;true&#34;&#62;

     &#60;h:outputLabel value=&#34;What's your title:&#34; for=&#34;title&#34;/&#62;
     &#60;h:inputText  id=&#34;title&#34; value=&#34;#{bean.title}&#34;/&#62;
     &#60;h:outputLabel value=&#34;What's your name:&#34; for=&#34;name&#34;/&#62;
     &#60;h:inputText  id=&#34;name&#34; value=&#34;#{bean.name}&#34;/&#62;

       ...

     &#60;a4j:commandButton id=&#34;save&#34;
          value=&#34;Save&#34;
          action=&#34;#{save}&#34;
          type=&#34;submit&#34;
          oncomplete=&#34;if(#{facesContext.maximumSeverity==null})Richfaces.hideModalPanel('edit_dialog')&#34;/&#62;

     &#60;a4j:commandButton id=&#34;reset&#34;
          value=&#34;Reset&#34;
          action=&#34;#{bean.reset}&#34;
          limitToList=&#34;true&#34;
          reRender=&#34;edit_form&#34;
          ajaxSingle=&#34;true&#34;
          type=&#34;reset&#34;/&#62;

     &#60;a4j:commandButton id=&#34;cancel&#34;
          value=&#34;Cancel&#34;
          action=&#34;#{bean.cancel}&#34;
          ajaxSingle=&#34;true&#34;
          oncomplete=&#34;Richfaces.hideModalPanel('edit_dialog')&#34;/&#62;

     &#60;rich:hotKey key=&#34;return&#34;
         selector=&#34;#edit_form&#34;
         handler=&#34;${rich:element('edit_form:save')}.click();event.stopPropagation();event.preventDefault(); return false;&#34;
         disableInInput=&#34;false&#34;/&#62;

      &#60;rich:hotKey key=&#34;esc&#34;
         selector=&#34;#edit_form&#34;
         handler=&#34;${rich:element('edit_form:cancel')}.click();event.stopPropagation();event.preventDefault(); return false;&#34;
         disableInInput=&#34;false&#34;/&#62;

   &#60;/a4j:form&#62;

&#60;/rich:modalPanel&#62;
</pre>
<p>It&#8217;s important to define <strong>ajaxSubmit=&#8221;true&#8221;</strong> for the form! This avoid &#8220;none ajax submit of html formulars&#8221;. I will explain this in a later blog <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>With <a href="http://docs.jboss.org/richfaces/latest_3_3_X/en/devguide/html/rich_hotKey.html" target="_blank">rich:hotKey</a> I bind 2 key events to the edit formular:</p>
<ul>
<li>on &#8216;enter&#8217; &#8211; the handler click the save button</li>
<li>on &#8216;esc&#8217; &#8211; the handler click the cancel button</li>
</ul>
<p>Try it <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Richfaces modal panel autofocus first input element]]></title>
<link>http://ahoehma.wordpress.com/2009/11/16/richfaces-modal-panel-autofocus-first-input-element/</link>
<pubDate>Mon, 16 Nov 2009 13:57:28 +0000</pubDate>
<dc:creator>Andreas Höhmann</dc:creator>
<guid>http://ahoehma.wordpress.com/2009/11/16/richfaces-modal-panel-autofocus-first-input-element/</guid>
<description><![CDATA[With jQuery it&#8217;s easy to focus the first visible input element (textfield, textarea or selectb]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>With <a href="http://docs.jquery.com/Selectors" target="_blank">jQuery</a> it&#8217;s easy to focus the first visible input element (textfield, textarea or selectbox) for a <a href="http://docs.jboss.org/richfaces/latest_3_3_X/en/devguide/html/rich_modalPanel.html" target="_blank">rich:modalPanel</a>:</p>
<pre class="brush: xml;">
&#60;rich:modalPanel onshow=&#34;autofocus('dialog_content')&#34;&#62;
  &#60;h:panelGrid id=&#34;dialog_content&#34; columns=&#34;1&#34; width=&#34;100%&#34; cellpadding=&#34;0&#34; cellspacing=&#34;0&#34;&#62;
     &#60;a4j:form ajaxSubmit=&#34;true&#34;&#62;
       &#60;h:outputLabel value=&#34;What's your name:&#34; for=&#34;name&#34;/&#62;
       &#60;h:inputText  id=&#34;name&#34; value=&#34;#{bean.name}&#34;/&#62;
       ...
       &#60;a4j:commandButton id=&#34;save&#34; value=&#34;Save my name&#34; action=&#34;save&#34;/&#62;
     &#60;/a4j:form&#62;
  &#60;/h:panelGrid&#62;
&#60;/rich:modalPanel&#62;
</pre>
<pre class="brush: jscript;">
function autofocus(containerId) {
  var element = jQuery(&#34;:input:not(:button):visible:enabled:first&#34;, '#'+containerId);
  if (element != null) {
    element.focus().select();
  }
}
</pre>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Step by step tutorial to setup Primefaces in Netbeans6.x]]></title>
<link>http://technicalbrainwave.wordpress.com/2009/11/07/step-by-step-tutorial-to-setup-primefaces-in-netbeans6-x/</link>
<pubDate>Fri, 06 Nov 2009 16:37:21 +0000</pubDate>
<dc:creator>Gift Sam</dc:creator>
<guid>http://technicalbrainwave.wordpress.com/2009/11/07/step-by-step-tutorial-to-setup-primefaces-in-netbeans6-x/</guid>
<description><![CDATA[Introduction This tutorial shows how to setup Primefaces component suite for a JSF or a Facelets pro]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p style="text-align:left;"><strong>Introduction</strong></p>
<p style="text-align:left;">This tutorial shows how to setup Primefaces component suite for a JSF or a Facelets project along with Richfaces in Netbeans6.x. Furthermore, you can learn how to make a hello world application using Primefaces in JSF. First let me give a small intro about Primefaces, which is an open source component suite for Java Server Faces and contains so many obliging features. At first Primefaces is a light weight component that contains more than <a href="http://97.107.138.40:8080/prime-showcase/ui/home.jsf">seventy ajax powered JSF components</a> with rich look and feel. In addition it has TouchFaces module features which is a UI kit used for developing mobile web applications. Also the most important thing is Primefaces is compatable with other components libraries like Richfaces, even the ajax integration part can be attained without any conflicts. Thats ok!! Now let us come to the point this article explains the configuration features of Primefaces with Netbeans6.x.</p>
<p style="text-align:left;"><strong>Prerequisites</strong></p>
<ul style="text-align:left;">
<li>IDE – Netbeans 6.x</li>
<li>Tomcat 6.x/Glassfish/Jboss</li>
<li>JDK 1.5 and above</li>
</ul>
<p style="text-align:left;">I assume you have all the prerequisites which I had mention above. Now let us move to the <!--more-->Configuration part of primefaces with Netbeans6.x which can be accomplished by five easy steps,</p>
<p style="text-align:left;"><strong>Step1(Setup the project)</strong></p>
<p style="text-align:left;">In Step1, let us see how to set up a JSF web project in Netbeans6.x. Select File <strong><em>&#8212;&#62; </em></strong>Newproject &#8212;&#62; Choose category as Java Web and select Web Application in Projects and click next &#8212;&#62; Give your desired name for the project and click next &#8212;&#62; Choose your server and the JavaEE Version and click next &#8212;&#62; Select Java ServerFaces check box for the JSF project or Facelets checkbox for the Facelets project in the Framework. Now we had created a web project and next we can move to the second step.</p>
<p style="text-align:left;"><strong>Step2(Library Configurations)</strong></p>
<p style="text-align:left;">In step two, Let us see how to configure the required libraries for the Primefaces, Downloading Primefaces binaries can be done by two options. <em><strong>Manual Download</strong><strong>(<em><strong>Option</strong></em>1)</strong></em>, we need to manually download all the required libraries of Primefaces. Alternatively, you may use Maven if you are a Maven user<em><strong>(Option2)</strong></em>, Good news for you because maven itself automatically download the required binaries of Primefaces.</p>
<p style="text-align:left;"><em><strong>Manual Download(Option1)</strong></em></p>
<p style="text-align:left;">Download and ensure that your projects WEB-INF/lib directory contains the below jar files inorder to use Primefaces  library together with Richfaces in a JSF project and for Facelets projects add necessary jar files, the link <a href="http://technicalbrainwave.wordpress.com/2009/10/16/jsffaceletsrichfaces-installation-guide/">JSF+Facelets+Richfaces Installation Guide</a> would be helpful to do so. You can also download the latest Primefaces jar files from the <a href="http://code.google.com/p/primefaces/downloads/list">PrimeFaces google code project site</a>.</p>
<ul style="text-align:left;">
<li>primefaces-ui-0.9.3.jar</li>
<li>optimus0.8.0.jar</li>
<li>facestrace1.1.0.jar</li>
<li>commons-beanutils.jar</li>
<li>commons-collections.jar</li>
<li>commons-digester.jar</li>
<li>commons-logging.jar</li>
<li>jsf-api.jar</li>
<li>jsf-impl.jar</li>
<li>jstl.jar</li>
<li>commons-discovery-0.4.jar</li>
<li>commons-codec-1.4.jar</li>
<li>slf4j-api-1.5.8.jar</li>
<li>slf4j-simple-1.5.8.jar</li>
<li>guice-2.0.jar</li>
<li>richfaces-api-3.3.1.GA.jar</li>
<li>richfaces-impl-3.3.1.GA.jar</li>
<li>richfaces-ui-3.3.1.GA.jar</li>
</ul>
<blockquote>
<p style="text-align:left;"><em><strong>Note:</strong></em> optimus0.8.0.jar and facestrace1.1.0.jar is requirement optional and it doest not required to make the UI components work.</p>
</blockquote>
<p style="text-align:left;"><em><strong>Maven</strong></em><em><strong>(Option2)</strong></em></p>
<p style="text-align:left;">I am not aware of using maven practically, but theoretically I have passed through maven. I like it because it contains good features for managing the         libraries. I got this resource from the <a href="http://primefaces.prime.com.tr/en/downloads.html">download section of Primefaces</a>. The following repository definition should be added in repositories section of pom.xml file .</p>
<pre class="brush: css;">
&#60;repository&#62;
&#60;id&#62;prime-repository&#60;/id&#62;
&#60;name&#62;Prime Technology Maven Repository&#60;/name&#62;
&#60;url&#62;http://repository.prime.com.tr/&#60;/url&#62;
&#60;layout&#62;default&#60;/layout&#62;
&#60;/repository&#62;
</pre>
<p>Add the dependency configuration for the user interface components like the below example</p>
<pre class="brush: css;">
&#60;dependency&#62;
&#60;groupId&#62;org.primefaces&#60;/groupId&#62;
&#60;artifactId&#62;primefaces-ui&#60;/artifactId&#62;
&#60;version&#62;0.9.3&#60;/version&#62;
&#60;/dependency&#62;
</pre>
<p>I hope you had configured the libraries either by following option1 or option2. If so stay tuned, now let us move to the next step.</p>
<p><strong>Step3(web.xml configuration)</strong><em><strong><br />
</strong></em></p>
<p>In step3, let us configure the web.xml for the Primefaces.</p>
<pre class="brush: css;">
&#60;web-app version=&#34;2.5&#34; xmlns=&#34;http://java.sun.com/xml/ns/javaee&#34; xmlns:xsi=&#34;http://www.w3.org/2001/XMLSchema-instance&#34; xsi:schemaLocation=&#34;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&#34;&#62;&#60;/pre&#62;
&#60;context-param&#62;
 &#60;param-name&#62;com.sun.faces.verifyObjects&#60;/param-name&#62;
 &#60;param-value&#62;false&#60;/param-value&#62;
 &#60;/context-param&#62;
 &#60;context-param&#62;
 &#60;param-name&#62;com.sun.faces.validateXml&#60;/param-name&#62;
 &#60;param-value&#62;true&#60;/param-value&#62;
 &#60;/context-param&#62;
 &#60;context-param&#62;
 &#60;param-name&#62;javax.faces.STATE_SAVING_METHOD&#60;/param-name&#62;
 &#60;param-value&#62;client&#60;/param-value&#62;
 &#60;/context-param&#62;

&#60;!--Configuration for Richfaces--&#62;

&#60;filter&#62;
 &#60;display-name&#62;RichFaces Filter&#60;/display-name&#62;
 &#60;filter-name&#62;richfaces&#60;/filter-name&#62;
 &#60;filter-class&#62;org.ajax4jsf.Filter&#60;/filter-class&#62;
 &#60;/filter&#62;
 &#60;filter-mapping&#62;
 &#60;filter-name&#62;richfaces&#60;/filter-name&#62;
 &#60;servlet-name&#62;Faces Servlet&#60;/servlet-name&#62;
 &#60;dispatcher&#62;REQUEST&#60;/dispatcher&#62;
 &#60;dispatcher&#62;FORWARD&#60;/dispatcher&#62;
 &#60;dispatcher&#62;INCLUDE&#60;/dispatcher&#62;
 &#60;/filter-mapping&#62;

&#60;!--End of the configuration part for Richfaces--&#62;

servlet&#62;
 &#60;servlet-name&#62;Faces Servlet&#60;/servlet-name&#62;
 &#60;servlet-class&#62;javax.faces.webapp.FacesServlet&#60;/servlet-class&#62;
 &#60;load-on-startup&#62;1&#60;/load-on-startup&#62;
 &#60;/servlet&#62;
 &#60;servlet-mapping&#62;
 &#60;servlet-name&#62;Faces Servlet&#60;/servlet-name&#62;
 &#60;url-pattern&#62;/faces/*&#60;/url-pattern&#62;
 &#60;/servlet-mapping&#62;
 &#60;context-param&#62;
 &#60;param-name&#62;org.richfaces.SKIN&#60;/param-name&#62;
 &#60;param-value&#62;classic&#60;/param-value&#62;
 &#60;/context-param&#62;

 &#60;!-- Configuration part for the Primefaces--&#62;

 &#60;servlet&#62;
 &#60;servlet-name&#62;Resource Servlet&#60;/servlet-name&#62;
 &#60;servlet-class&#62;
 org.primefaces.ui.resource.ResourceServlet
 &#60;/servlet-class&#62;
 &#60;load-on-startup&#62;2&#60;/load-on-startup&#62;
 &#60;/servlet&#62;
 &#60;servlet-mapping&#62;
 &#60;servlet-name&#62;Resource Servlet&#60;/servlet-name&#62;
 &#60;url-pattern&#62;/primefaces_resources/*&#60;/url-pattern&#62;
 &#60;/servlet-mapping&#62;

 &#60;!-- End of the configuration part for the Primefaces--&#62;

&#60;session-config&#62;
 &#60;session-timeout&#62;
 30
 &#60;/session-timeout&#62;
 &#60;/session-config&#62;
 &#60;welcome-file-list&#62;
 &#60;welcome-file&#62;faces/welcomeJSF.jsp&#60;/welcome-file&#62;
 &#60;/welcome-file-list&#62;
&#60;/web-app&#62;</pre>
<p>In the above configuration, Primefaces configuration for the JSF project is specified. If you want to configure Primefaces for the Facelets projects add the Facelets neccesary configuration in the web.xml and also you can see the loading order of servlets is specified. Servlets with lower values are loaded before servlets with higher values. So the servlet<em><strong>(Faces Servlet) </strong></em>that manages the request  processing lifecycle for web applications<em><strong> </strong></em>which utilize the JavaServer  Faces to construct the user interface is loaded first and the PrimeFaces UI module&#8217;s servlet<em><strong>(Resource Servlet)</strong></em> loaded second. Now the web.xml configuration part gets over and let us move to the next step.</p>
<p><strong>Step4(Taglib specifications)</strong></p>
<p>In step4, Let us learn how to specify the taglibs for the Facelets or JSF projects. For <strong><em>Facelets projects</em></strong>, though the Facelets web page are created in the xhtml documents, the taglibs should be specified like the below</p>
<pre class="brush: css;">
&#60;html xmlns:p=&#34;http://primefaces.prime.com.tr/ui&#34; /&#62;
</pre>
<p>As you all know for <em><strong>JSF project</strong></em>, the JSF web page are created in the JSP documents, the taglibs should be specified like the below</p>
<pre class="brush: css;">
&#60;%@ taglib uri=&#34;http://primefaces.prime.com.tr/ui&#34; prefix=&#34;p&#34; %&#62;
</pre>
<p>So far we had completed most of the configurations and only one more step is there to finish the set up process of Primefaces in Netbeans6.x.</p>
<p><strong>Step5(Resources Components)</strong></p>
<p>The resource components should be added between the head tag of the page, inorder to include the css and script resources.</p>
<pre class="brush: css;">
&#60;head&#62;
&#60;meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=UTF-8&#34;/&#62;
&#60;p:resources/&#62;
&#60;/head&#62;
</pre>
<p>Setup process of Primefaces in Netbeans6.x has been completed and now let us create a hello world page using Primefaces UI components. The following code should be conjured to do so,</p>
<pre class="brush: css;">

&#60;%@page contentType=&#34;text/html&#34; pageEncoding=&#34;UTF-8&#34;%&#62;

 &#60;%@ taglib uri=&#34;http://java.sun.com/jsf/html&#34; prefix=&#34;h&#34;%&#62;
 &#60;%@ taglib uri=&#34;http://java.sun.com/jsf/core&#34; prefix=&#34;f&#34;%&#62;
 &#60;%@ taglib uri=&#34;http://richfaces.org/a4j&#34; prefix=&#34;a4j&#34;%&#62;
 &#60;%@ taglib uri=&#34;http://richfaces.org/rich&#34; prefix=&#34;rich&#34;%&#62;
 &#60;%@ taglib uri=&#34;http://primefaces.prime.com.tr/ui&#34; prefix=&#34;p&#34; %&#62;

 &#60;!DOCTYPE HTML PUBLIC &#34;-//W3C//DTD HTML 4.01 Transitional//EN&#34;
 &#34;http://www.w3.org/TR/html4/loose.dtd&#34;&#62;

 &#60;f:view&#62;
 &#60;html&#62;
 &#60;head&#62;
 &#60;meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=UTF-8&#34;/&#62;
 &#60;title&#62;Hello World&#60;/title&#62;
 &#60;p:resources/&#62;
 &#60;/head&#62;
 &#60;body&#62;
 &#60;h:form id=&#34;helloWorldPageForm&#34;&#62;
 &#60;p:panel id=&#34;primefacesPanel&#34; header=&#34;Hello World&#34;
 footer=&#34;Footer&#34;
 style=&#34;position: relative; width: 500px; &#34; &#62;
 &#60;h:outputText value=&#34;Primefaces is great. My first application using Primefaces&#34;/&#62;
 &#60;/p:panel&#62;
 &#60;/h:form&#62;
 &#60;/body&#62;
 &#60;/html&#62;
 &#60;/f:view&#62;</pre>
<p>By invoking the above code, we had created a Hello World demo application which contains a Primefaces panel, You can also use Richfaces components together with the Primefaces components. I am sure you dont believe, Even the ajax integration part between these libraries works well have a try on it. Now let us have a look on the snap of our Hello World application.</p>
<p><strong>Hello World Application&#8217;s Demo Snap</strong></p>
<p><strong><img title="Hello World" src="http://technicalbrainwave.wordpress.com/files/2009/11/c92906.jpg" alt="Hello World" width="507" height="105" /></strong></p>
<p>Thatsall folks. I hope this article clearly explains the Setup of Primefaces in a JSF or Facelets projects along with Richfaces library in Netbeans6.x. <em><strong>If you find this article is quite useful, Dont forget to share with me by your valuable comments</strong></em>. Have a joyous code day.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Disable backspace key in a Richfaces application]]></title>
<link>http://ahoehma.wordpress.com/2009/11/06/disable-backspace-key-in-a-richfaces-application/</link>
<pubDate>Fri, 06 Nov 2009 13:50:12 +0000</pubDate>
<dc:creator>Andreas Höhmann</dc:creator>
<guid>http://ahoehma.wordpress.com/2009/11/06/disable-backspace-key-in-a-richfaces-application/</guid>
<description><![CDATA[If you want disable the Backspace key in your JSF Richfaces application put this in your view: &lt;r]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>If you want disable the Backspace key in your JSF Richfaces application put this in your view:</p>
<pre class="brush: xml;">
&#60;rich:hotKey key=&#34;backspace&#34; handler=&#34;return false;&#34; disableInInput=&#34;true&#34;/&#62;
</pre>
<p>This will register a <a href="http://code.google.com/p/js-hotkeys/wiki/about" target="_blank">jQuery Hotkey</a> handler for the document. The handler is not reqistered for input elements because in input fields you need the backspace <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> . Tested for FF3 and IE6.</p>
<p>Then I found out that the following snippet doesn&#8217;t work:</p>
<pre class="brush: xml;">
&#60;rich:hotKey key=&#34;backspace&#34;
             disableInInput=&#34;true&#34;
             handler=&#34;alert('Backspace is disabled'); return false;&#34; /&#62;
</pre>
<p>The Browser open the alert box and go to the previous page (in background?!). But there is a fix for that:</p>
<pre class="brush: xml;">
&#60;rich:hotKey key=&#34;backspace&#34;
             disableInInput=&#34;true&#34;
             handler=&#34;alert('Backspace is disabled'); event.stopPropagation(); event.preventDefault(); return false;&#34; /&#62;
</pre>
<p>The <strong>event</strong> variable is available in the handler function (see org.richfaces.renderkit.html.HotKeyRenderer method doEncodeEnd).</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Layouting and Dynamic Includes in Facelets]]></title>
<link>http://technicalbrainwave.wordpress.com/2009/10/18/layouting-and-dynamic-includes-in-facelets/</link>
<pubDate>Sun, 18 Oct 2009 10:14:01 +0000</pubDate>
<dc:creator>Gift Sam</dc:creator>
<guid>http://technicalbrainwave.wordpress.com/2009/10/18/layouting-and-dynamic-includes-in-facelets/</guid>
<description><![CDATA[Introduction A classified web applications necessitate the use of Cascading Style Sheets(CSS), JavaS]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><strong>Introduction</strong></p>
<p>A classified web applications necessitate the use of Cascading Style Sheets(CSS), JavaScript, together with a server-side framework, such as JavaServer Faces(JSF). This article is consecrated for the peoples who wants to use facelets as an alternative view technology for building JSF applications. This article is splitted in to two-part series, Here you will find out how to make a complete Layout in JSF using facelets. In addition, learn how to include the pages dynamically, so that you can make use of serveral JSF forms more dynamic. Before starting this tutorial, first you need to create and configure facelets for your a web application project, the following link <a href="http://technicalbrainwave.wordpress.com/2009/10/16/jsffaceletsrichfaces-installation-guide/">Facelet installation</a> would be helpful to configure the facelets for your project.</p>
<p><strong><span style="color:#333399;"><span style="color:#000000;">Part1</span> </span>- How to make Layouts in Facelets</strong></p>
<p>After creating and installing facelets prerequisite for your project. Lets move to the part1 where you will learn to make template in facelets. As you all know, you can create a web page template for facelets in xhtml documents. This demo application<!--more--> is constructed by the following templates.</p>
<ol>
<li>layout.xhtml</li>
<li>layout-Client.xhtml</li>
<li>header.xhtml</li>
<li>sideBar.xhtml</li>
<li>footer.xhtml</li>
<li>sample pages like(samplePageOne.xhtml, samplePageTwo.xhtml, samplePage3.xhtml..)</li>
</ol>
<p><em><strong>1.Construct layout.xhtml template<br />
</strong></em></p>
<p>First let us construct a <em><strong>layout.xhtml </strong></em>which is the main layout that holds the template styles for the entire application. This mainLayout.xhtml web page contains header, leftColumn, rightColumn, content and footers in a 3 column elastic layout, <em><strong>You can define your own layout</strong></em>, the reason why I have used 3 column elastic layout here is, since the layout widths are defined in ems, elastic layouts allow your page containers to expand depending on the site visitor&#8217;s text size preference.</p>
<p><em><strong>layout.xhtml</strong></em></p>
<p><em><strong> </strong></em></p>
<pre class="brush: css;">
&#60;?xml version='1.0' encoding='UTF-8' ?&#62;
&#60;?xml version='1.0' encoding='UTF-8' ?&#62;
&#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&#62;
&#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;
 xmlns:ui=&#34;http://java.sun.com/jsf/facelets&#34;
 xmlns:h=&#34;http://java.sun.com/jsf/html&#34;&#62;
 &#60;head&#62;
 &#60;meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=UTF-8&#34; /&#62;
 &#60;link href=&#34;./css/default.css&#34; rel=&#34;stylesheet&#34; type=&#34;text/css&#34; /&#62;
 &#60;link href=&#34;./css/cssLayout.css&#34; rel=&#34;stylesheet&#34; type=&#34;text/css&#34; /&#62;
 &#60;title&#62;Facelets Template&#60;/title&#62;
 &#60;style type=&#34;text/css&#34; media=&#34;all&#34;&#62;
 body
{
 background-color: #2b3a3c;
 color: #2d2e2e;
 font-family: Arial, Helvetica, sans-serif;
 font-size: .8em;
 line-height: 1.2em;
 margin: 0 0 0 0; /* Sets the margin properties for an element using shorthand notation (top, right, bottom, left) */
 padding: 0 0 0 0; /* Sets the padding properties for an element using shorthand notation (top, right, bottom, left) */
 text-align: center; /* Centers the page content container in IE 5 browsers. */
 }
 #outerWrapper
{
 background-color: #fff;
 margin: 0 auto 0 auto; /* Sets the margin properties for an element using shorthand notation (top, right, bottom, left) */
 text-align: left; /* Redefines the text alignment defined by the body element. */
 width: 80em;
 }
 #outerWrapper #header
{
 background-color: #8ab573;
 border-bottom: solid 1px #628152; /* Sets the bottom border properties for an element using shorthand notation */
 font-size: 1.5em;
 font-weight: bold;
 line-height: 1.7em;
 padding: 10px 10px 10px 10px; /* Sets the padding properties for an element using shorthand notation (top, right, bottom, left) */
 }
 #outerWrapper #contentWrapper #rightColumn
{
 background-color: #eef6ed;
 border-left: solid 1px #8ab573; /* Sets the left border properties for an element using shorthand notation */
 float: right;
 padding: 10px; /* Sets the padding properties for an element using shorthand notation (top, right, bottom, left) */
 width: 14em;
 height: 200px;
 }
 #outerWrapper #contentWrapper #leftColumn
{
 background-color: #eef6ed;
 border-right: solid 1px #8ab573; /* Sets the right border properties for an element using shorthand notation */
 float: left;
 padding: 10px; /* Sets the padding properties for an element using shorthand notation (top, right, bottom, left) */
 width: 14em;
 height: 200px;
 }
 #outerWrapper #contentWrapper #content
{
 margin: 0 16em 0 16em; /* Sets the margin properties for an element using shorthand notation (top, right, bottom, left) */
 padding: 10px 10px 10px 10px; /* Sets the padding properties for an element using shorthand notation (top, right, bottom, left) */
 }
 #outerWrapper #contentWrapper .clearFloat
{
 clear: both;
 display: block;
 }
 #outerWrapper #footer
{
 background-color: #8ab573;
 border-bottom: solid 1px #628152; /* Sets the bottom border properties for an element using shorthand notation */
 font-size: 1.5em;
 font-weight: bold;
 line-height: 1.7em;
 padding: 10px 10px 10px 10px; /* Sets the padding properties for an element using shorthand notation (top, right, bottom, left) */
 }
 &#60;/style&#62;
 &#60;/head&#62;
 &#60;body&#62;
 &#60;div id=&#34;outerWrapper&#34;&#62;
     &#60;div id=&#34;header&#34;&#62;
         &#60;ui:insert name=&#34;header&#34;/&#62;
     &#60;/div&#62;
     &#60;div id=&#34;contentWrapper&#34;&#62;
         &#60;div id=&#34;rightColumn&#34;&#62;
             &#60;ui:insert name=&#34;rightColumn&#34;/&#62;
         &#60;/div&#62;
         &#60;div id=&#34;leftColumn&#34;&#62;
             &#60;ui:insert name=&#34;leftColumn&#34;/&#62;
         &#60;/div&#62;
         &#60;div id=&#34;content&#34;&#62;
             &#60;ui:insert name=&#34;content&#34;/&#62;
         &#60;/div&#62;
     &#60;br /&#62;
     &#60;/div&#62;
         &#60;div id=&#34;footer&#34;&#62;
             &#60;ui:insert name=&#34;footer&#34;/&#62;
         &#60;/div&#62;
 &#60;/div&#62;
 &#60;/body&#62;
&#60;/html&#62;</pre>
<p>&#60;ui:insertag&#62;- this is a templating tag which is used to declare a named                content element to be defined by another Facelet. ui:insert tag can be used                effectively with the ui:define tag.</p>
<p>Now the main layout has been constructed, next let us construct a <em><strong>layout-Client.xhml</strong></em>.</p>
<p><em><strong>2.Construct</strong></em> <em><strong>layout-Client.xhml template</strong></em></p>
<p>This layout-client.xhml template uses three tags,</p>
<p>&#60;ui:composition&#62; tag &#8211; a templating tag that                wraps the content of layout.xhml template. Facelets                view handler will ignore any content                outside the composition tag.</p>
<p>&#60;ui:define&#62; tag -  defines the named content of ui:insert tag in layout.xhtml template</p>
<p>&#60;ui:include&#62; tag &#8211; constructed inside the ui:define tag to include the other templates.</p>
<p><em><strong>layout-Client.xhtml</strong></em></p>
<pre class="brush: css;">
&#60;?xml version='1.0' encoding='UTF-8' ?&#62;
&#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&#62;
&#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;
 xmlns:ui=&#34;http://java.sun.com/jsf/facelets&#34;
 xmlns:f=&#34;http://java.sun.com/jsf/core&#34;
 xmlns:h=&#34;http://java.sun.com/jsf/html&#34;
 xmlns:a4j=&#34;http://richfaces.org/a4j&#34;
 xmlns:rich=&#34;http://richfaces.org/rich&#34;&#62;
 &#60;body&#62;
 &#60;ui:composition template=&#34;./layout.xhtml&#34;&#62;
     &#60;ui:define name=&#34;header&#34;&#62;
         &#60;ui:include src=&#34;./header.xhtml&#34;/&#62;
     &#60;/ui:define&#62;
     &#60;ui:define name=&#34;rightColumn&#34;&#62;
         Ads here
     &#60;/ui:define&#62;
     &#60;ui:define name=&#34;leftColumn&#34;&#62;
        &#60;ui:include src=&#34;./sideBar.xhtml&#34;/&#62;
     &#60;/ui:define&#62;
     &#60;ui:define name=&#34;content&#34;&#62;
         &#60;rich:panel id=&#34;contentRichPanel&#34; style=&#34;position: relative;&#34;&#62;
             &#60;ui:include src=&#34;#{PageViewIdGenerator.includedPage}&#34;/&#62;
         &#60;/rich:panel&#62;
     &#60;/ui:define&#62;
     &#60;ui:define name=&#34;footer&#34;&#62;
         &#60;ui:include src=&#34;./footer.xhtml&#34;/&#62;
     &#60;/ui:define&#62;
 &#60;/ui:composition&#62;
 &#60;/body&#62;
&#60;/html&#62;</pre>
<p><em><strong>3.construct header.xhtml</strong></em></p>
<p>The template header.xhml should be wrapped inside the ui:define tag of layout-Client.xhml template.</p>
<p><em><strong>header.xhtml</strong></em></p>
<pre class="brush: css;">

&#60;?xml version='1.0' encoding='UTF-8' ?&#62;
&#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&#62;
&#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;
 xmlns:ui=&#34;http://java.sun.com/jsf/facelets&#34;
 xmlns:f=&#34;http://java.sun.com/jsf/core&#34;
 xmlns:h=&#34;http://java.sun.com/jsf/html&#34;
 xmlns:a4j=&#34;http://richfaces.org/a4j&#34;
 xmlns:rich=&#34;http://richfaces.org/rich&#34;&#62;
 &#60;body&#62;
 &#60;h:form method=&#34;post&#34;&#62;
     &#60;rich:panel style=&#34;position: relative;width: auto&#34;&#62;
         &#60;h:outputText value=&#34;Sample Demo Page&#34;&#62;&#60;/h:outputText&#62;
     &#60;/rich:panel&#62;
 &#60;/h:form&#62;
 &#60;/body&#62;
&#60;/html&#62;</pre>
<p><em><strong>4.Construct sideBar.xhtml</strong></em></p>
<p>Richfaces component <em><strong>Panel Menu</strong></em> which holds the content page links is used as the side bar. This should be wrapped inside the ui:define tag of  left column or right column(Its up to you) of layout-client.xhtml.</p>
<p><em><strong>sideBar.xhtml</strong></em></p>
<pre class="brush: css;">&#60;?xml version='1.0' encoding='UTF-8' ?&#62;
&#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&#62;
&#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;
 xmlns:ui=&#34;http://java.sun.com/jsf/facelets&#34;
 xmlns:f=&#34;http://java.sun.com/jsf/core&#34;
 xmlns:h=&#34;http://java.sun.com/jsf/html&#34;
 xmlns:a4j=&#34;http://richfaces.org/a4j&#34;
 xmlns:rich=&#34;http://richfaces.org/rich&#34;&#62;
 &#60;body&#62;
 &#60;h:form id=&#34;sideBarId&#34;&#62;
 &#60;!-- Richfaces panel menu --&#62;
     &#60;rich:panelMenu styleClass=&#34;panelMenu&#34; mode=&#34;none&#34; iconExpandedGroup=&#34;disc&#34; iconCollapsedGroup=&#34;disc&#34;
      iconExpandedTopGroup=&#34;chevronUp&#34; iconGroupTopPosition=&#34;right&#34;
      iconCollapsedTopGroup=&#34;chevronDown&#34; expandSingle=&#34;true&#34;&#62;
     &#60;!-- Group1 --&#62;
     &#60;rich:panelMenuGroup id=&#34;group1Id&#34; label=&#34;Group1&#34;&#62;
     &#60;!-- Page1 --&#62;
         &#60;rich:panelMenuItem&#62;
             &#60;h:commandLink id=&#34;page1LinkId&#34; value=&#34;Page1&#34;
                            action=&#34;#{PageViewIdGenerator.sideBarAction}&#34;&#62;
             &#60;f:param id=&#34;page1ParamId&#34; name=&#34;pageViewId&#34; value=&#34;Page1&#34;/&#62;
             &#60;/h:commandLink&#62;
         &#60;/rich:panelMenuItem&#62;
     &#60;!-- Page1 Ends --&#62;
     &#60;!-- Page2 --&#62;
         &#60;rich:panelMenuItem&#62;
              &#60;h:commandLink id=&#34;page2LinkId&#34; value=&#34;Page2&#34;
                             action=&#34;#{PageViewIdGenerator.sideBarAction}&#34;&#62;
              &#60;f:param id=&#34;page2ParamId&#34; name=&#34;pageViewId&#34; value=&#34;Page2&#34;/&#62;
              &#60;/h:commandLink&#62;
         &#60;/rich:panelMenuItem&#62;
     &#60;!-- Page2 Ends --&#62;
     &#60;!-- Page3 --&#62;
         &#60;rich:panelMenuItem&#62;
             &#60;h:commandLink id=&#34;page3LinkId&#34; value=&#34;Page3&#34;
                            action=&#34;#{PageViewIdGenerator.sideBarAction}&#34;&#62;
             &#60;f:param id=&#34;page3ParamId&#34; name=&#34;pageViewId&#34; value=&#34;Page3&#34;/&#62;
             &#60;/h:commandLink&#62;
         &#60;/rich:panelMenuItem&#62;
     &#60;!-- Page3 Ends --&#62;
     &#60;!-- Page4 --&#62;
         &#60;rich:panelMenuItem&#62;
             &#60;h:commandLink id=&#34;page4LinkId&#34; value=&#34;Page4&#34;
                            action=&#34;#{PageViewIdGenerator.sideBarAction}&#34;&#62;
             &#60;f:param id=&#34;page4ParamId&#34; name=&#34;pageViewId&#34; value=&#34;Page4&#34;/&#62;
             &#60;/h:commandLink&#62;
         &#60;/rich:panelMenuItem&#62;
         &#60;!-- Page4 Ends --&#62;
         &#60;!-- Page5 --&#62;
         &#60;rich:panelMenuItem&#62;
             &#60;a4j:commandLink id=&#34;page5Linkid&#34; value=&#34;Page5&#34;
                              action=&#34;#{PageViewIdGenerator.sideBarAction}&#34;&#62;
             &#60;f:param id=&#34;page5Param&#34; name=&#34;pageViewId&#34; value=&#34;Page5&#34;/&#62;
             &#60;/a4j:commandLink&#62;
         &#60;/rich:panelMenuItem&#62;
         &#60;!-- Page5 Ends --&#62;
     &#60;/rich:panelMenuGroup&#62;
     &#60;!-- End of Group1 --&#62;
     &#60;!-- Group2 --&#62;
     &#60;rich:panelMenuGroup id=&#34;group2Id&#34; label=&#34;Group2&#34;&#62;
         &#60;!-- define group2 codes here--&#62;
     &#60;/rich:panelMenuGroup&#62;
     &#60;!-- End of Group2 --&#62;
     &#60;!-- Group3 --&#62;
     &#60;rich:panelMenuGroup id=&#34;group3Id&#34; label=&#34;Group3&#34;&#62;
         &#60;!-- define group2 codes here--&#62;
     &#60;/rich:panelMenuGroup&#62;
     &#60;!-- End of Group3 --&#62;
     &#60;/rich:panelMenu&#62;
 &#60;/h:form&#62;
 &#60;/body&#62;
&#60;/html&#62;</pre>
<p><em><strong>5.Construct footer.xhtml</strong></em></p>
<p>The template footer.xhml should be wrapped inside the ui:define tag of layout-Client.xhml template.</p>
<p><em><strong>footer.xhml</strong></em></p>
<pre class="brush: css;">&#60;?xml version='1.0' encoding='UTF-8' ?&#62;
&#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&#62;
&#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;
 xmlns:ui=&#34;http://java.sun.com/jsf/facelets&#34;
 xmlns:f=&#34;http://java.sun.com/jsf/core&#34;
 xmlns:h=&#34;http://java.sun.com/jsf/html&#34;
 xmlns:a4j=&#34;http://richfaces.org/a4j&#34;
 xmlns:rich=&#34;http://richfaces.org/rich&#34;&#62;
 &#60;body&#62;
 &#60;h:form method=&#34;post&#34;&#62;
     &#60;rich:panel&#62;
         &#60;h:outputText value=&#34;Footer text&#34;/&#62;
     &#60;/rich:panel&#62;
 &#60;/h:form&#62;
 &#60;/body&#62;
&#60;/html&#62;</pre>
<p><em><strong>6. Construct sample pages</strong></em></p>
<p>Create your own required templates which is to be dynamically included in the content of the layout-Client.xhtml template. But now, I have mentioned some sample pages for the reference.</p>
<p><em><strong>samplePageOne.xhml</strong></em></p>
<pre class="brush: css;">

&#60;?xml version='1.0' encoding='UTF-8' ?&#62;
&#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&#62;
&#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;
 xmlns:ui=&#34;http://java.sun.com/jsf/facelets&#34;
 xmlns:f=&#34;http://java.sun.com/jsf/core&#34;
 xmlns:h=&#34;http://java.sun.com/jsf/html&#34;
 xmlns:a4j=&#34;http://richfaces.org/a4j&#34;
 xmlns:rich=&#34;http://richfaces.org/rich&#34;&#62;
 &#60;body&#62;
 &#60;h:form&#62;
     &#60;h:outputLabel value=&#34;Hello this is Page One&#34;/&#62;
 &#60;/h:form&#62;
 &#60;/body&#62;
&#60;/html&#62;</pre>
<p><em><strong>samplePageTwo.xhml</strong></em></p>
<pre class="brush: css;">

&#60;?xml version='1.0' encoding='UTF-8' ?&#62;
 &#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&#62;
 &#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;
 xmlns:ui=&#34;http://java.sun.com/jsf/facelets&#34;
 xmlns:f=&#34;http://java.sun.com/jsf/core&#34;
 xmlns:h=&#34;http://java.sun.com/jsf/html&#34;
 xmlns:a4j=&#34;http://richfaces.org/a4j&#34;
 xmlns:rich=&#34;http://richfaces.org/rich&#34;&#62;
 &#60;body&#62;
 &#60;h:form&#62;
     &#60;h:outputLabel value=&#34;Hello this is Page Two&#34;/&#62;
 &#60;/h:form&#62;
 &#60;/body&#62;
 &#60;/html&#62;</pre>
<p>So far we have created xhtml documents like header, sideBar, rightColumn and the footer which is to be included statically in the layout.xhml web page. Now let us see how the samplePageOne.xhml(Page1) and samplePageTwo.xhtml(Page2) links of sideBar are dynamically included in the content of layout-Client.xhtml.</p>
<p><strong><span style="color:#000000;">Part2</span>-Dynamic Include</strong></p>
<p>Dynamic include can be accomplished with use of the <em><strong>f:param tag defined in the </strong><strong>sideBar</strong></em><em><strong>.xhtml</strong></em>, where we can easily find the clicked link of sideBar. So that the page will be dynamically included in the content of layout.xhtml. we need to construct a backing bean and to configure the managed bean in the faces-config.xml to invoke this.</p>
<p><em><strong>faces-config.xml Configuration</strong></em></p>
<pre class="brush: css;">
&#60;managed-bean&#62;
 &#60;managed-bean-name&#62;PageViewIdGenerator&#60;/managed-bean-name&#62;
 &#60;managed-bean-class&#62;com.layout.PageViewIdGenerator&#60;/managed-bean-class&#62;
 &#60;managed-bean-scope&#62;session&#60;/managed-bean-scope&#62;
&#60;/managed-bean&#62;</pre>
<p>The pertinent backing bean code look like,</p>
<p><em><strong>PageViewIdGenerator.java</strong></em></p>
<pre class="brush: css;">

package com.layout;

import javax.faces.context.FacesContext;
/**
 * @author giftsam
 */
public class PageViewIdGenerator
{
private String includedPage = &#34;/samplePageTwo.xhtml&#34;;

public String sideBarAction()
{
           /**
           * Get the request parameter map from the context, so that we can find which link of the side is clicked
           */
           FacesContext context = FacesContext.getCurrentInstance();
           String selectedPageViewId =
                  context.getExternalContext().getRequestParameterMap().get(&#34;pageViewId&#34;);

           if (selectedPageViewId.equalsIgnoreCase(&#34;page1&#34;))
           {
               includedPage = &#34;/samplePageOne.xhtml&#34;;
           }
           else if (selectedPageViewId.equalsIgnoreCase(&#34;page2&#34;))
           {
               includedPage = &#34;/samplePageTwo.xhtml&#34;;
           }
           else if (selectedPageViewId.equalsIgnoreCase(&#34;page3&#34;))
           {
               includedPage = &#34;/samplePageThree.xhtml&#34;;
           }
           else if (selectedPageViewId.equalsIgnoreCase(&#34;page4&#34;))
           {
               includedPage = &#34;/samplePageFour.xhtml&#34;;
           }
     return &#34;&#34;;
 }

 /**
 * @return the includedPage
 */
 public String getIncludedPage()
 {
 return includedPage;
 }

 /**
 * @param includedPage the includedPage to set
 */
 public void setIncludedPage(String includedPage)
 {
 this.includedPage = includedPage;
 }
}</pre>
<p>Thatsall folks, now we have created a complete demo application, where samplePageOne.xhml and samplePageTwo.xhtml are included dynamically where as xhtml documents like header, leftColumn, rightColumn and the footer are included statically. Here is the snaps of our sample demo application.</p>
<p><strong>Sample Demo Snaps</strong></p>
<p>Snap1 specifies the dynamic include of samplePageOne when the page1 of sideBar is clicked.</p>
<p><img title="Layout DemoSnap1" src="http://technicalbrainwave.wordpress.com/files/2009/10/layoutdemosnap1.png" alt="Layout DemoSnap1" width="600" height="270" /></p>
<p>Snap2 specifies the dynamic include of samplePageOne when the page2 of sideBar is clicked.</p>
<p><img title="Layout Sample Demo2" src="http://technicalbrainwave.wordpress.com/files/2009/10/layoutsampledemo2.jpg" alt="Layout Sample Demo2" width="600" height="270" /></p>
<p><strong>Conclusion</strong></p>
<p>In this article, we have learned how to constuct a complete layout using facelets as a view technology and also we have learned how to include the pages dynamically, so that you can make use of serveral JSF forms more dynamic. If you find this article is useful to you dont forget to share with me by your valuable comments. Have a joyous code day.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[JSF+Facelets+Richfaces Installation-Guide]]></title>
<link>http://technicalbrainwave.wordpress.com/2009/10/16/jsffaceletsrichfaces-installation-guide/</link>
<pubDate>Fri, 16 Oct 2009 12:07:53 +0000</pubDate>
<dc:creator>Gift Sam</dc:creator>
<guid>http://technicalbrainwave.wordpress.com/2009/10/16/jsffaceletsrichfaces-installation-guide/</guid>
<description><![CDATA[Introduction Installing facelets together with richfaces is very simple. I used to develope web appl]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><strong>Introduction</strong></p>
<p>Installing facelets together with richfaces is very simple. I used to develope web applications with JSF and its libraries like richfaces, Icefaces and so on. But I felt, my application have achieved a greater landmark only after implementing facelets. The reason is, facelets contains obliging features like templating(Similarly like struts), Composition components(Reuse can be achieved), also resolves the mismatch between JSF and JSP technologies(Eg: &#60;jsp:param&#62; tag cannot be used in JSF while using &#60;jsp:include&#62; tag) and so on. This article explains the installation of Richfaces and facelets with JSF.</p>
<p><strong>Prerequisites</strong></p>
<ul>
<li>IDE &#8211; Netbeans 6.x or Eclipse(Now Netbeans 6.7 provides the feature for creating facelets projects)</li>
<li>Tomcat 6.x or Glassfish</li>
<li>JDK 1.5 and above</li>
</ul>
<p>Installing facelets can be accomplished by four steps in a web application project. If you are the one who use Netbeans 6.7 IDE which provides the features for creating facelet projects kindly skip the below <!--more-->step1 and step3 and just add the richfaces jars specified in the libraries and configure richfaces in web.xml. Others kindly follow the below steps,</p>
<p><strong>Step1</strong></p>
<p>In step1, download and ensure that your projects WEB-INF/lib directory contains the below jar files.</p>
<p><em><strong>Libraries</strong></em></p>
<ul>
<li>commons-beanutils.jar</li>
<li>commons-collections.jar</li>
<li>commons-digester.jar</li>
<li>commons-logging.jar</li>
<li>el-ri.jar</li>
<li>jhighlight-1.0.jar</li>
<li>jsf-api.jar</li>
<li>jsf-facelets.jar</li>
<li>jsf-impl.jar</li>
<li>jstl.jar</li>
<li>richfaces-api-3.3.1.GA.jar</li>
<li>richfaces-impl-3.3.1.GA.jar</li>
<li>richfaces-ui-3.3.1.GA.jar</li>
</ul>
<p><strong>Step2</strong></p>
<p>Step2 clearly explains how to configure the web.xml for the facelet projects. Your web.xml file should contains the following configurations for the JSF+Facelets+Richfaces Installations.</p>
<p><em><strong>web.xml configuration</strong></em></p>
<pre class="brush: css;">

&#60;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&#62;

&#60;web-app version=&#34;2.5&#34; xmlns=&#34;http://java.sun.com/xml/ns/javaee&#34; xmlns:xsi=&#34;http://www.w3.org/2001/XMLSchema-instance&#34; xsi:schemaLocation=&#34;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&#34;&#62;

&#60;context-param&#62;
&#60;param-name&#62;com.sun.faces.verifyObjects&#60;/param-name&#62;
&#60;param-value&#62;true&#60;/param-value&#62;
&#60;/context-param&#62;
&#60;context-param&#62;
&#60;param-name&#62;com.sun.faces.validateXml&#60;/param-name&#62;
&#60;param-value&#62;true&#60;/param-value&#62;
&#60;/context-param&#62;
&#60;context-param&#62;
&#60;param-name&#62;javax.faces.DEFAULT_SUFFIX&#60;/param-name&#62;
&#60;param-value&#62;.xhtml&#60;/param-value&#62;
&#60;/context-param&#62;
&#60;context-param&#62;
&#60;param-name&#62;facelets.DEVELOPMENT&#60;/param-name&#62;
&#60;param-value&#62;false&#60;/param-value&#62;
&#60;/context-param&#62;
&#60;context-param&#62;
&#60;param-name&#62;facelets.SKIP_COMMENTS&#60;/param-name&#62;
&#60;param-value&#62;true&#60;/param-value&#62;
&#60;/context-param&#62;
&#60;!-- Richfaces Configuration--&#62;
&#60;context-param&#62;
&#60;param-name&#62;org.richfaces.SKIN&#60;/param-name&#62;
&#60;param-value&#62;wine&#60;/param-value&#62;
&#60;/context-param&#62;
&#60;context-param&#62;
&#60;param-name&#62;org.ajax4jsf.VIEW_HANDLERS&#60;/param-name&#62;
&#60;param-value&#62;com.sun.facelets.FaceletViewHandler&#60;/param-value&#62;
&#60;/context-param&#62;
&#60;filter&#62;
&#60;display-name&#62;RichFaces Filter&#60;/display-name&#62;
&#60;filter-name&#62;richfaces&#60;/filter-name&#62;
&#60;filter-class&#62;org.ajax4jsf.Filter&#60;/filter-class&#62;
&#60;/filter&#62;
&#60;filter-mapping&#62;
&#60;filter-name&#62;richfaces&#60;/filter-name&#62;
&#60;servlet-name&#62;Faces Servlet&#60;/servlet-name&#62;
&#60;dispatcher&#62;REQUEST&#60;/dispatcher&#62;
&#60;dispatcher&#62;FORWARD&#60;/dispatcher&#62;
&#60;dispatcher&#62;INCLUDE&#60;/dispatcher&#62;
&#60;/filter-mapping&#62;
&#60;servlet&#62;
&#60;servlet-name&#62;Faces Servlet&#60;/servlet-name&#62;
&#60;servlet-class&#62;javax.faces.webapp.FacesServlet&#60;/servlet-class&#62;
&#60;load-on-startup&#62;1&#60;/load-on-startup&#62;
&#60;/servlet&#62;
&#60;servlet-mapping&#62;
&#60;servlet-name&#62;Faces Servlet&#60;/servlet-name&#62;
&#60;url-pattern&#62;*.jsf&#60;/url-pattern&#62;
&#60;/servlet-mapping&#62;
&#60;session-config&#62;
&#60;session-timeout&#62;
30
&#60;/session-timeout&#62;
&#60;/session-config&#62;
&#60;welcome-file-list&#62;
&#60;welcome-file&#62;index.jsp&#60;/welcome-file&#62;
&#60;/welcome-file-list&#62;
&#60;/web-app&#62;</pre>
<p><strong>Step3:</strong></p>
<p>Step3 explains the faces-config configurations.</p>
<p><em><strong>faces-config configuration</strong></em></p>
<pre class="brush: css;">&#60;application&#62;
&#60;view-handler&#62;
com.sun.facelets.FaceletViewHandler
&#60;/view-handler&#62;
&#60;/application&#62;</pre>
<p>Now you have completed the installation successfully and next you need create web pages in xhtml documents and you should specify the taglibs in XML namespaces instead of JSP taglibs.<br />
<strong></strong></p>
<p><strong>Step4</strong></p>
<p>Create a xhtml document and your web page should contain the taglibs as stated in sample.xhtml, so that you can use the rich faces components together with facelets.<br />
<em><strong></strong></em></p>
<p><em><strong>sample.xhtml</strong></em></p>
<pre class="brush: css;">
&#60;?xml version='1.0' encoding='UTF-8' ?&#62;
&#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&#62;
&#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;
xmlns:ui=&#34;http://java.sun.com/jsf/facelets&#34;
xmlns:f=&#34;http://java.sun.com/jsf/core&#34;
xmlns:h=&#34;http://java.sun.com/jsf/html&#34;
xmlns:a4j=&#34;http://richfaces.org/a4j&#34;
xmlns:rich=&#34;http://richfaces.org/rich&#34;&#62;
&#60;body&#62;
&#60;h:form method=&#34;post&#34;&#62;
&#60;rich:panel&#62;
&#60;h:outputText value=&#34;Sample Text&#34;&#62;&#60;/h:outputText&#62;
&#60;/rich:panel&#62;
&#60;/h:form&#62;
&#60;/body&#62;
&#60;/html&#62;</pre>
<p>Thatsall folks. I hope this article clearly explains the installation of Facelets and Richfaces with JSF. Some may say, this article is only about installation, but I want to get in to the action!!. Dont worry just follow the link <a href="http://technicalbrainwave.wordpress.com/2009/10/18/layouting-and-dynamic-includes-in-facelets/">Layouting and Dynamic include in Facelets</a> , which will help you to construct templates and dynamic include using Facelets. <em><strong>If you find this article is quite useful, Dont forget to share with me by your valuable comments</strong></em>. Have a joyous code day.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Resolve IE8 Compatibility Issues with Richfaces]]></title>
<link>http://technicalbrainwave.wordpress.com/2009/10/03/resolve-ie8-compatibility-issues-with-richfaces/</link>
<pubDate>Sat, 03 Oct 2009 06:38:12 +0000</pubDate>
<dc:creator>Gift Sam</dc:creator>
<guid>http://technicalbrainwave.wordpress.com/2009/10/03/resolve-ie8-compatibility-issues-with-richfaces/</guid>
<description><![CDATA[Introduction: I have developed a web application in JSF along with richfaces. My application perfect]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><div>
<p><strong>Introduction:</strong></p>
<p>I have developed a web application in JSF along with richfaces. My application perfectly works in the various browsers like Firefox, Google Chrome also in IE6 and IE7. But in IE8, I found a compatability issue with Richfaces. I felt wrecked, because the web application designed in the older version browsers, doesnt have the support in the newer versions. But eventually I have a founded a solution to resolve this Richfaces compatability issues in IE8. The way is to implement “IE=7” X-UA-Compatible tag, which instructs IE8 to display content in IE7 Standards mode. I got this resource from the following link of <a href="http://blogs.msdn.com/ie/archive/2008/06/10/introducing-ie-emulateie7.aspx">IE blogs</a>.</p>
<p><strong>The Trick:</strong></p>
<p>Resolving IE8 compatability issues with richfaces is accomplished by two tricks,</p>
<p><strong>Trick1:</strong></p>
<p><strong> </strong>Add the &#60;meta http-equiv=&#8221;X-UA-Compatible&#8221; content=&#8221;IE=EmulateIE7&#8243; /&#62; header tag <!--more-->in your jsp code like the below</p>
<pre class="brush: css;">
&#60;%@page contentType=&#34;text/html&#34; pageEncoding=&#34;UTF-8&#34;%&#62;
&#60;%@ taglib uri=&#34;http://java.sun.com/jsf/html&#34; prefix=&#34;h&#34; %&#62;
&#60;%@ taglib uri=&#34;http://java.sun.com/jsf/core&#34; prefix=&#34;f&#34; %&#62;
&#60;%@ taglib uri=&#34;http://richfaces.org/a4j&#34; prefix=&#34;a4j&#34;%&#62;
&#60;%@ taglib uri=&#34;http://richfaces.org/rich&#34; prefix=&#34;rich&#34;%&#62;

&#60;!DOCTYPE HTML PUBLIC &#34;-//W3C//DTD HTML 4.01 Transitional//EN&#34;
 &#34;http://www.w3.org/TR/html4/loose.dtd&#34;&#62;
&#60;f:view&#62;
 &#60;html&#62;
    &#60;head&#62;
         &#60;meta http-equiv=&#34;X-UA-Compatible&#34; content=&#34;IE=EmulateIE7&#34; /&#62;
         &#60;meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=UTF-8&#34;/&#62;
         &#60;title&#62;Resolve IE8 Compatability Issues&#60;/title&#62;
    &#60;/head&#62;
     &#60;body&#62;
         &#60;h1&#62;&#60;h:outputText value=&#34;Resolve IE8 Compatability Issues&#34;/&#62;&#60;/h1&#62;
     &#60;/body&#62;
 &#60;/html&#62;
&#60;/f:view&#62;
</pre>
<blockquote><p><em><strong>Note: </strong></em>This header tag should comes first in the head tag. if not IE8 will ignore all the other tags.</p></blockquote>
<p><strong>Trick2</strong>(Resolve using a filter):</p>
<p>You can also set this header tag in a HttpServletResponse, by contolling your entire java application by a filter. So that the response page processed by this servlet response will contains the specified http header tag. Thanks for the resource provided in <a href="http://cse-mjmcl.cse.bris.ac.uk/blog/2008/06/12/1213260442881.html">Mark McLaren&#8217;s Weblog</a>.</p>
<pre class="brush: css;">
package com.example.web;

import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
public class IE8CompatablityFixServlet implements Filter
{
public void init(FilterConfig filterConfig) throws ServletException
{
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException
{
((HttpServletResponse) response).setHeader(&#34;X-UA-Compatible&#34;, &#34;IE=EmulateIE7&#34;);
chain.doFilter(request, response);
}

public void destroy()
{
}
}</pre>
<p>So by implementing any of the tricks you can accomplish the IE8 Compatability issues with richfaces.</p>
<p><strong>Seam:</strong></p>
<p>Some may say I am using seam, how to resolve this issue in seam?? Dont worry there is a way to implement this and it will be touched on soon. I got this resource from the <a href="http://www.jboss.org/community/wiki/IE8CompatibilityModewithRichfaces">Jboss wiki</a>.  In seam, configurations should be done in pages.xml, which is the file used to specify the settings for the entire applications.</p>
<div><strong>Pages.xml Configuration:</strong></div>
<div>The below code is used to apply globally for all the pages in a single configuration.</div>
<div>
<pre class="brush: css;">
&#60;page view-id=&#34;*&#34;&#62;
&#60;header name=&#34;X-UA-Compatible&#34;&#62;IE=EmulateIE7&#60;/header&#62;
&#60;navigation&#62;
&#60;rule if-outcome=&#34;main&#34;&#62;
&#60;redirect view-id=&#34;pages/main.xhtml&#34;/&#62;
&#60;/rule&#62;
&#60;/navigation&#62;
&#60;/page&#62;
</pre>
<p>If you want to apply this header tag for an individual page, the below code should be invoked.</p>
<pre class="brush: css;">
&#60;page view-id=&#34;/pages/login.xhtml&#34;&#62;
&#60;header name=&#34;X-UA-Compatible&#34;&#62;IE=EmulateIE7&#60;/header&#62;
&#60;description&#62;User Login&#60;/description&#62;
&#60;/page&#62;
</pre>
<p>Thats all folks. I hope this article would be helpful to resolve the compatability issues with richfaces in IE8.<em><strong> If you find this article is quite useful, Dont forget to share with me by giving your valuable comments</strong></em>. Have a joyous code day.</p>
</div>
</div>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Tricks to Add Scroll Bars for Rich ModalPanel]]></title>
<link>http://technicalbrainwave.wordpress.com/2009/09/22/trick-to-add-scroll-bars-for-rich-modalpanel/</link>
<pubDate>Tue, 22 Sep 2009 11:04:41 +0000</pubDate>
<dc:creator>Gift Sam</dc:creator>
<guid>http://technicalbrainwave.wordpress.com/2009/09/22/trick-to-add-scroll-bars-for-rich-modalpanel/</guid>
<description><![CDATA[Introduction: Rich faces contains so many benificial components which also includes rich:modalpanel.]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p style="text-align:left;"><strong>Introduction:</strong><br />
Rich faces contains so many benificial components which also includes rich:modalpanel. Implementing rich:modalpanel is quite easy by<em> </em><a href="http://docs.jboss.org/richfaces/latest_3_3_X/en/devguide/html/rich_modalPanel.html" target="_blank">following</a> the document of richfaces. But assume that if the page to be displayed in the modal panel  is bigger that the monitor screen size, definitely the page will be extended over the screen with no scroll bars. The first question comes to the mind is &#8220;How could I invoke scroll bars to the modalpanel&#8221;. Dont worry it will be touched on soon.</p>
<p style="text-align:left;"><strong>The Trick:</strong></p>
<p style="text-align:left;">Add the below style in the style class.<!--more--></p>
<pre class="brush: css;">&#60;style type=&#34;text/css&#34;&#62;
.dr-mpnl-pnl {overflow:auto!important}
&#60;/style&#62;</pre>
<blockquote><p><em><strong>Note:</strong></em> Dont forget to define the height of the modal panel.</p></blockquote>
<pre class="brush: css;">&#60;h:form id=&#34;myForm&#34; &#62;
&#60;a4j:commandButton id=&#34;showPanelButton&#34; value=&#34;Show Modal Panel&#34;
                   reRender=&#34;myForm&#34; styleClass=&#34;button&#34; &#62;
&#60;rich:componentControl for=&#34;myModalPanel&#34; attachTo=&#34;showPanelButton&#34;
                   operation=&#34;show&#34; event=&#34;onclick&#34;/&#62;
&#60;/a4j:commandButton&#62;
&#60;rich:modalPanel id=&#34;myModalPanel&#34; height=&#34;500&#34; width=&#34;500&#34;&#62;
&#60;f:facet name=&#34;header&#34;&#62;
&#60;h:outputText value=&#34;My ModalPanel&#34; /&#62;
&#60;/f:facet&#62;
&#60;jsp:include page=&#34;./myBigPage&#34; flush=&#34;true&#34;/&#62;
&#60;/rich:modalPanel&#62;
&#60;/h:form&#62;</pre>
<p>By Invoking .dr-mpnl-pnl class in the style class, the styles for the &#60;rich:modalPanel&#62; components are redefined. So now if  the page doesnt fit inside the screen size means, the scroll bars will come automatically. I hope this article would be helpful, if you used &#8220;Ajax for JSF&#8221; for your development. Have a joyous code day.</p>
<p><a id="mPC"></a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[JSF Tips and Tricks]]></title>
<link>http://rajivas.wordpress.com/2009/09/19/jsf-tips-and-tricks/</link>
<pubDate>Sat, 19 Sep 2009 18:52:48 +0000</pubDate>
<dc:creator>rajivas</dc:creator>
<guid>http://rajivas.wordpress.com/2009/09/19/jsf-tips-and-tricks/</guid>
<description><![CDATA[Even though at surface JSF may seem easier framework to workwith it is not. After using it for a whi]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p style="margin-bottom:0;">Even though at surface JSF may seem easier framework to workwith it is not.  After using it for a while  a new deveoper may encounter a problem which may seem trivial in other frameworks or servlet/JSP implementation but very difficult  to achieve the  same result in it.</p>
<p style="margin-bottom:0;">
<p style="margin-bottom:0;">For example handling UnchekedException at JSP/View layer is very simple like just adding an ErrorPage attribute in JSP or global exception tag in Struts. To do the same in JSF-Facelets we may need to write customActionListener/delegation servlet but  these are not standards.</p>
<p style="margin-bottom:0;">
<p style="margin-bottom:0;">
<p style="margin-bottom:0;">Since JSP servlet development is request/response based to the JSF Event/Component based architecture it is bit difficult to adopt. JSF is similar to Swing so a Swing developer may find it very easy.</p>
<p style="margin-bottom:0;">
<p style="margin-bottom:0;">
<p style="margin-bottom:0;">Using Facelets as View in JSF application may contribute to further complications to the regular JSP-Struts Developer.</p>
<p style="margin-bottom:0;">
<p style="margin-bottom:0;">
<p style="margin-bottom:0;">Use RichFaces or MyFaces, as these frameworks provide rich UI components along with AJAX support out of the box developing professional looking application is a breeze.</p>
<p style="margin-bottom:0;">
<p style="margin-bottom:0;"><strong>Uses of  Facelets:</strong> It provides templating feature simlar to tiles.  It is faster than JSP.</p>
<p style="margin-bottom:0;">We can avoid using JSTL and scriptlets completely in Facelets.</p>
<p style="margin-bottom:0;">nstead of using c:if use rendered attribute to optionally display a block of html/Facelet code.</p>
<p style="margin-bottom:0;">To iterate over a list or collection use h:dataTable or h:colum instead of using c:forEach</p>
<p style="margin-bottom:0;">Unified EL is evaluated at runtime where as JSTL and EL tags are evaluated at compile time.</p>
<p style="margin-bottom:0;">
<p style="margin-bottom:0;"><strong>Writing directly to response stream in JSF</strong></p>
<p style="margin-bottom:0;"><strong><br />
</strong></p>
<p style="margin-bottom:0;font-weight:normal;">Writing to a response stream directly in JSF is not recommended but there are instances where we need this feature like report generation.  If we need to export PDF or any binary files in a JSF application  the code would be as below.</p>
<p style="margin-bottom:0;font-weight:normal;">
<p style="margin-bottom:0;"><span style="font-family:Courier New,monospace;"><strong><span style="color:#7f0055;">public</span><span style="color:#000000;"> </span><span style="color:#7f0055;">void</span><span style="color:#000000;"> writeToResponse(String headerType,</span></strong></span></p>
<p style="margin-bottom:0;" align="LEFT"><span style="color:#000000;"><span style="font-family:Courier New,monospace;"> ByteArrayOutputStream bos,String reportType) {</span></span></p>
<p style="margin-bottom:0;"><span style="color:#000000;"><span style="font-family:Courier New,monospace;"><strong>FacesContext faces = FacesContext.<em>getCurrentInstance</em>();</strong></span></span></p>
<p style="margin-bottom:0;" align="LEFT"><span style="color:#000000;"><span style="font-family:Courier New,monospace;"> HttpServletResponse resp = (HttpServletResponse) faces.getExternalContext().getResponse();</span></span></p>
<p style="margin-bottom:0;" align="LEFT"><span style="font-family:Courier New,monospace;"><span style="color:#000000;"> </span><span style="color:#7f0055;"><strong>try</strong></span><span style="color:#000000;"> { </span></span></p>
<p style="margin-bottom:0;" align="LEFT"><span style="color:#000000;"><span style="font-family:Courier New,monospace;">resp.setContentType(headerType);</span></span></p>
<p style="margin-bottom:0;" align="LEFT"><span style="font-family:Courier New,monospace;"><span style="color:#000000;"> resp.setHeader(</span><span style="color:#2a00ff;">&#8220;Content-Disposition&#8221;</span><span style="color:#000000;">, </span><span style="color:#2a00ff;">&#8220;inline;filename=&#8221;</span><span style="color:#000000;"> + </span><span style="color:#0000c0;">reportName</span><span style="color:#000000;"> + </span><span style="color:#2a00ff;">&#8220;.&#8221;</span><span style="color:#000000;"> + reportType );</span></span></p>
<p style="margin-bottom:0;" align="LEFT"><span style="color:#000000;"><span style="font-family:Courier New,monospace;">bos.writeTo(sos);</span></span></p>
<p style="margin-bottom:0;" align="LEFT"><span style="color:#000000;"><span style="font-family:Courier New,monospace;"> sos.flush();</span></span></p>
<p style="margin-bottom:0;" align="LEFT"><span style="font-family:Courier New,monospace;"><span style="color:#000000;"> faces.responseComplete();</span><span style="color:#3f7f5f;">// without this response write error will come</span></span></p>
<p style="margin-bottom:0;" align="LEFT"><span style="font-family:Courier New,monospace;"><span style="color:#000000;"> } </span><span style="color:#7f0055;"><strong>catch</strong></span><span style="color:#000000;"> (IOException e) {</span></span></p>
<p style="margin-bottom:0;" align="LEFT"><span style="color:#000000;"><span style="font-family:Courier New,monospace;"> </span></span></p>
<p style="margin-bottom:0;" align="LEFT"><span style="color:#000000;"><span style="font-family:Courier New,monospace;"> e.printStackTrace();</span></span></p>
<p style="margin-bottom:0;" align="LEFT"><span style="color:#000000;"><span style="font-family:Courier New,monospace;"> } </span></span></p>
<p style="margin-bottom:0;" align="LEFT"><span style="color:#000000;"> <span style="font-family:Courier New,monospace;"><strong>}</strong></span></span></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Adding Code Syntaxhiglighter plugin to Richfaces text editor]]></title>
<link>http://schakrap.wordpress.com/2009/09/12/adding-code-syntaxhiglighter-plugin-to-richfaces-text-editor/</link>
<pubDate>Sat, 12 Sep 2009 18:01:47 +0000</pubDate>
<dc:creator>Shrihari Chakrapani</dc:creator>
<guid>http://schakrap.wordpress.com/2009/09/12/adding-code-syntaxhiglighter-plugin-to-richfaces-text-editor/</guid>
<description><![CDATA[Exadel&#8217;s Richfaces Rich text editor integrates with TinyMCE javascript plugin to provide the r]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Exadel&#8217;s Richfaces <a href="http://docs.jboss.org/richfaces/latest_3_3_X/en/tlddoc/rich/editor.html">Rich text editor</a> integrates with <a href="http://tinymce.moxiecode.com/">TinyMCE javascript plugin</a> to provide the rich text editor functions present in any document processing application. However often would be a need where we have to embed source code from a particular programming  language. In order to support  embedding code in the richtext editor, the code should be surrounded wuth appropriate &#8220;pre&#8221; tags with options for the selected programming language. This particular tip explores integrating a <a href="http://github.com/RichGuk/syntaxhl/tree/master">SyntaxHighlighter plugin</a> with Richfaces rich text editor, enabling the editor support for source code editing:</p>
<p>1) Download the sources from <a href="http://github.com/RichGuk/syntaxhl/tree/master">site</a>.</p>
<p>2) Create a folder under ${contextroot}/js/tinymceplugins/syntaxhighlight and extract all the contents of the downloaded zip/sources here. Remember that the folder name should be &#8216;tinymceplugin&#8217; as the TinyMCE javascript plugin looks for this folder for additional plugins if configured. Also note that ${contextroot} is your web application context root.</p>
<p>3) The different languages you need to support are present under ${contextroot}/js/tinymceplugins/syntaxhighlight/dialog.htm, where you retain only the relevant ones. For XML/XHTML support, you may need to add 2 additional lines, which would convert the XML tags to respective character equivalents in ${contextroot}/js/tinymceplugins/syntaxhighlight/js/dialog.js</p>
<pre><span style="color:#0000ff;">content_text = f.syntaxhl_code.value.replace(/&#60;/g,"&#38;lt;");
 content_text = content_text.replace(/&#62;/g,"&#38;gt;");
 textarea_output +=  content_text;</span></pre>
<p>4) Create a properties file rteplugins.properties (name with custom plugins are resolved) with a property containing full path (relative with regard to ${contextroot}) of the editor_plugin.js from the downloaded sources as given below.  Remember that property name used here (syntaxhl) is the plugin name used in the richtext editor configuration</p>
<pre><span style="color:#0000ff;">syntaxhl=/js/tinymceplugins/syntaxhighlight/editor_plugin.js</span></pre>
<p>5) The richfaces text editor configuration should be modified as below:</p>
<pre><span style="color:#0000ff;">&#60;rich:editor id="description" width="750" height="250" value="#{mybackingbean.description}"
 theme="advanced" viewMode="visual"  customPlugins="rteplugins" plugins="media,fullscreen,syntaxhl"&#62;
          &#60;f:param name="theme_advanced_buttons1"  value="code,bold,italic,underline,fullscreen,justifyleft,justifycenter,justifyright,
                                    fontselect,fontsizeselect,styleprops,tablecontrols,syntaxhl,
                                    search,replace,selectall,media,forecolor,backcolor,cut,copy,paste"/&#62;
          &#60;f:param name="theme_advanced_toolbar_location" value="top" /&#62;
          &#60;f:param name="theme_advanced_toolbar_align" value="left" /&#62;
          &#60;f:param name="extended_valid_elements" value="pre[name&#124;class]"/&#62;
 &#60;/rich:editor&#62;</span></pre>
<p>Note: parameter &#8216;extended_valid_elements&#8217; identifies valid tags that can be present in the text in raw HTML form.</p>
<p>Well now you are ready to use the rich text editor to contain code snippets. Lets also try to look at how to view code in highlighted format in the next tip.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[ ViewExpiredException in JSF 1 and 2]]></title>
<link>http://ahoehma.wordpress.com/2009/09/07/viewexpiredexception-in-jsf-1-and-2/</link>
<pubDate>Mon, 07 Sep 2009 07:55:24 +0000</pubDate>
<dc:creator>Andreas Höhmann</dc:creator>
<guid>http://ahoehma.wordpress.com/2009/09/07/viewexpiredexception-in-jsf-1-and-2/</guid>
<description><![CDATA[Ed Burns beschreibt in seinem Blog wie man in JSF 2 selbst eine ViewExpiredException&#8217;s behande]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Ed Burns beschreibt in seinem <a href="http://weblogs.java.net/blog/edburns/archive/2009/09/03/dealing-gracefully-viewexpiredexception-jsf2" target="_blank">Blog</a> wie man in <strong>JSF 2</strong> selbst eine ViewExpiredException&#8217;s behandeln kann.</p>
<p>Momentan (JSF &#60; 2) kann die Standard-Fehlerbehandlung natürlich auch angepasst werden, z.B. durch Festlegung einer bestimmten Location pro Exception-Typ:</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;web-app version=&quot;2.5&quot; xmlns=&quot;http://java.sun.com/xml/ns/javaee&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
  xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&quot;&gt;
  ...
  &lt;error-page&gt;
    &lt;exception-type&gt;javax.faces.application.ViewExpiredException&lt;/exception-type&gt;
    &lt;location&gt;/pages/error/sessionexpired.xhtml&lt;/location&gt;
  &lt;/error-page&gt;
  ...
</pre>
<p>In der von Ed vorgestellten Lösung wird ein eigener <code>ViewExpiredExceptionHandler</code> registriert, welcher den ursprünglichen Handler kapselt. In der dort überschriebenen <code>void handle()</code> wir eine <code>ViewExpiredException</code> mit einem Redirect (via Navigation-Handler) auf eine Fehlerseite beantwortet. In der Fehlerseite können Variable, die im Handler gesetzt wurden, für eine sinnvolle Fehlerbeschreibung verwendet werden.</p>
<p>Beim Einsatz von Richfaces kann man diese Art von Fehler auch auf der Clientseite behandeln, beschrieben wird dies im Detail <a href="http://docs.jboss.org/richfaces/latest_3_3_X/en/devguide/html_single/index.html#RequestErrorsAndSessionExpirationHandling" target="_blank">hier</a>. Das Ganze ist mit zwei Erweiterungen machbar:</p>
<p>1. die Funktion für den Client aktivieren</p>
<pre class="brush: xml;">
&lt;context-param&gt;
  &lt;param-name&gt;org.ajax4jsf.handleViewExpiredOnClient&lt;/param-name&gt;
  &lt;param-value&gt;true&lt;/param-value&gt;
&lt;/context-param&gt;
</pre>
<p>2. den Javascript-Code für die Behandlung zur Verfügung stellen:</p>
<pre class="brush: jscript;">
if (typeof(A4J) !== 'undefined' &amp;&amp; typeof(A4J.AJAX) !== 'undefined'){
   // richfaces is available
   A4J.AJAX.onExpired = function(loc,expiredMsg) {
      var confirmMsg = 'Session expired.\n\nReload?';
      if (confirm(confirmMsg)) {
         window.location.reload();
      }
      // return false to inform &quot;link-commands&quot;, that the user doesn't want to reload the page
      return false;
   };
};
</pre>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[MyEclipse and JBoss Tools]]></title>
<link>http://aniruddhchitre.wordpress.com/2009/09/05/myeclipse-and-jboss-tools/</link>
<pubDate>Sat, 05 Sep 2009 06:53:43 +0000</pubDate>
<dc:creator>aniruddhchitre</dc:creator>
<guid>http://aniruddhchitre.wordpress.com/2009/09/05/myeclipse-and-jboss-tools/</guid>
<description><![CDATA[I have been using MyEclipse for all my Java development. Its a great IDE and I cant really think of ]]></description>
<content:encoded><![CDATA[I have been using MyEclipse for all my Java development. Its a great IDE and I cant really think of ]]></content:encoded>
</item>
<item>
<title><![CDATA[Fadein and Fadeout a Richfaces ModalPanel]]></title>
<link>http://ahoehma.wordpress.com/2009/07/22/fadein-and-fadeout-a-richfaces-modalpanel/</link>
<pubDate>Wed, 22 Jul 2009 15:59:13 +0000</pubDate>
<dc:creator>Andreas Höhmann</dc:creator>
<guid>http://ahoehma.wordpress.com/2009/07/22/fadein-and-fadeout-a-richfaces-modalpanel/</guid>
<description><![CDATA[Today i explain you a cool combination for rich:modalPanel and rich:effect. In the richfaces forum i]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Today i explain you a cool combination for rich:modalPanel and rich:effect.</p>
<p>In the richfaces forum i found a <a href="http://www.jboss.org/index.html?module=bb&#38;op=viewtopic&#38;p=4243264#4243264" target="_blank">article</a> about a modalpanel with scriptaculous-effects (&#8220;fade-in a modalpanel&#8221;). The answer was a link to the official richfaces demo-application (photoalbum). There we can find a <em>login-dialog</em> (<a href="http://anonsvn.jboss.org/repos/richfaces/branches/community/3.3.X/examples/photoalbum/source/web/src/main/webapp/includes/index/login.xhtml" target="_blank">svn source</a>) with a &#8220;appear-effect&#8221;:</p>
<pre class="brush: xml;">
&lt;rich:modalPanel id=&quot;loginPanel&quot;
onshow=&quot;applyModalPanelEffect('loginPanel', appearFunc,{delay: 0.5, afterFinish: function(){$('loginPanelForm:username').focus();}})&quot;
styleClass=&quot;login-panel&quot;
showWhenRendered=&quot;#{authenticator.loginFailed}&quot;
width=&quot;400&quot; height=&quot;150&quot; autosized=&quot;true&quot;&gt;
&lt;f:facet name=&quot;header&quot;&gt;#{messages['login.login']}&lt;/f:facet&gt;
&lt;f:facet name=&quot;controls&quot;&gt;
&lt;h:panelGroup id=&quot;loginPanelHideControl&quot;&gt;
&lt;h:graphicImage value=&quot;/img/modal/close.png&quot; style=&quot;cursor:pointer&quot;
id=&quot;loginPanelhidelink&quot; onclick=&quot;#{rich:component('loginPanel')}.hide();&quot;/&gt;
&lt;/h:panelGroup&gt;
&lt;/f:facet&gt;
...
&lt;rich:effect type=&quot;Appear&quot; name=&quot;appearFunc&quot;/&gt;
...
</pre>
<p>The javascript method applyModalPanelEffect can be found in the <em>photoalbum.js</em> (<a href="http://anonsvn.jboss.org/repos/richfaces/branches/community/3.3.X/examples/photoalbum/source/web/src/main/webapp/scripts/photoalbum.js" target="_blank">svn source</a>):</p>
<pre class="brush: jscript;">
function applyModalPanelEffect(panelId, effectFunc, params) {
 if (panelId &amp;&amp; effectFunc) {
 var modalPanel = $(panelId);
 if (modalPanel &amp;&amp; modalPanel.component) {
 var component = modalPanel.component;
 var div = component.getSizedElement();
 Element.hide(div);
effectFunc.call(this, Object.extend({targetId: div.id}, params &amp;#124;&amp;#124; {}));}}
}
</pre>
<p>With this the rich:modalPanel will not shown immediately &#8230; it appears <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  This was the &#8220;fade-in part&#8221;.</p>
<p>I improved the code for the &#8220;fade-out part&#8221;, first the dialog:</p>
<pre class="brush: xml;">

&lt;!-- first the effects --&gt;
&lt;rich:effect type=&quot;Appear&quot; name=&quot;appearDialog&quot;/&gt;
 &lt;rich:effect type=&quot;Fade&quot; name=&quot;disappearDialog&quot;/&gt;

&lt;!-- to keep the dialog-code clean --&gt;
&lt;c:set var=&quot;closeDialog&quot; value=&quot;hideModalPanelWithEffect('myDialog',disappearDialog,{delay:0.1,duration:0.5})&quot;/&gt;

&lt;rich:modalPanel id=&quot;myDialog&quot;
 onshow=&quot;showModalPanelWithEffect('myDialog',appearDialog,{delay:0.1,duration:0.5})&quot;
 width=&quot;610&quot; height=&quot;350&quot; minHeight=&quot;350&quot; autosized=&quot;true&quot; shadowDepth=&quot;0&quot;&gt;
&lt;f:facet name=&quot;controls&quot;&gt;
&lt;h:panelGroup&gt;
&lt;h:graphicImage value=&quot;/img/modal/close.png&quot; style=&quot;cursor:pointer&quot; onclick=&quot;#{closeDialog}&quot;/&gt;
&lt;/h:panelGroup&gt;
&lt;/f:facet&gt;
&lt;/rich:modalPanel&gt;
</pre>
<p>and the javascript:</p>
<pre class="brush: jscript;">
function applyModalPanelEffect(panelId, effectFunc, params, hide) {
 if (panelId &amp;&amp; effectFunc) {
 var modalPanel = $(panelId);
 if (modalPanel &amp;&amp; modalPanel.component) {
 var component = modalPanel.component;
 var div = component.getSizedElement();
 if (hide) {
 Element.hide(div);
 }
 effectFunc.call(this, Object.extend( {targetId : div.id}, params &amp;#124;&amp;#124; {}));}}
}

function showModalPanelWithEffect(panelId, showEffect, params) {
 applyModalPanelEffect(panelId, showEffect, params, true);
}

function hideModalPanelWithEffect(panelId, hideEffect, params) {
 var _params = params;
_params['afterFinish'] = function(){Richfaces.hideModalPanel(panelId)};
 applyModalPanelEffect(panelId, hideEffect, params, false);
}
</pre>
<p>Now the dialog call <strong>showModalPanelWithEffect</strong> to fade-in and <strong>hideModalPanelWithEffect</strong> to fade-out.</p>
<p>Try it <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Einschub - Internet Explorer 8 und Modale Panels]]></title>
<link>http://codingtemple.wordpress.com/2009/07/20/einschub-internet-explorer-8-und-modale-panels/</link>
<pubDate>Mon, 20 Jul 2009 11:13:17 +0000</pubDate>
<dc:creator>ct</dc:creator>
<guid>http://codingtemple.wordpress.com/2009/07/20/einschub-internet-explorer-8-und-modale-panels/</guid>
<description><![CDATA[Vielleicht hat es der ein oder andere schon bemerkt, ich habe mich heute damit rumärgern müssen: Im ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Vielleicht hat es der ein oder andere schon bemerkt, ich habe mich heute damit rumärgern müssen:</p>
<p><!--more-->Im Internet Explorer 8 ist es nicht möglich Modale Panels (&#60;rich:modalPanel&#8230;/&#62;) zu schließen. Der Fehler, der angezeigt wird, meldet <em>ui.pack.js</em> sei nicht implementiert.</p>
<p>Ein entsprechender JIRA-Artikel wurde angelegt: <a title="JIRA" href="https://jira.jboss.org/jira/browse/RF-6437" target="_blank">https://jira.jboss.org/jira/browse/RF-6437</a></p>
<p>Also, solltet ihr auf den Fehler treffen: Ihr habt ihn nicht verursacht oder einen Fehler gemacht&#8230;</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Utilizando o RichFaces no JBoss com o JBoss Tools.]]></title>
<link>http://jcanalneto.wordpress.com/2009/07/18/utilizando-o-richfaces-no-jboss-com-o-jboss-tools/</link>
<pubDate>Sat, 18 Jul 2009 18:56:05 +0000</pubDate>
<dc:creator>Jc Neto</dc:creator>
<guid>http://jcanalneto.wordpress.com/2009/07/18/utilizando-o-richfaces-no-jboss-com-o-jboss-tools/</guid>
<description><![CDATA[Não sou muito de fazer tutoriais mas como tomei uma baita surra para fazer o RichFaces Funcionar com]]></description>
<content:encoded><![CDATA[Não sou muito de fazer tutoriais mas como tomei uma baita surra para fazer o RichFaces Funcionar com]]></content:encoded>
</item>
<item>
<title><![CDATA[Howto avoid concurrent call to conversation problem in Seam]]></title>
<link>http://achorniy.wordpress.com/2009/07/14/avoid-concurrent-call-to-conversation/</link>
<pubDate>Tue, 14 Jul 2009 22:04:20 +0000</pubDate>
<dc:creator>Andrey Chorniy</dc:creator>
<guid>http://achorniy.wordpress.com/2009/07/14/avoid-concurrent-call-to-conversation/</guid>
<description><![CDATA[It&#8217;s very common that in your Seam web-application you will get &#8220;HTTP Status 503 &#8211;]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>It&#8217;s very common that in your Seam web-application you will get &#8220;HTTP Status 503 &#8211; Concurrent call to conversation&#8221; error and an exception stacktrace if you in debug-mode.</p>
<p>That can be caused by several reasons, one of them is double click on the ajax-link like &#60;a4j:commandLink action=&#8221;#{myAction.action} value=&#8221;Simple link&#8221;/&#62;<br />
A4J/RichFaces allow the solultion for that problem &#8211; you have just to specify <strong>eventsQueue</strong> attrbute<br />
&#60;a4j:commandLink action=&#8221;#{myAction.action} value=&#8221;Simple link&#8221; <strong>eventsQueue=&#8221;myQueue&#8221; </strong>/&#62;<br />
In that way even if user will click on that link twice &#8211; the events (requests) will be sent only one-by-one</p>
<p>As a side-note it worth also to specify &#8220;<strong>requestDelay</strong>&#8221; (specify the time the request will wait in queue before send) and <strong>ignoreDupResponses</strong>=&#8221;true&#8221; (A4J will ignore ajax response if another &#8220;similar&#8221; request is in queue). It&#8217;s worth for everyone to read that in <a href="http://livedemo.exadel.com/richfaces-demo/richfaces/ajaxAttributes.jsf?c=ajaxattributes" target="_blank">RichFaces docs</a></p>
<p>But, it not always solve your problem &#8211; users are unpredicted creatures and they can click on your h:commandLink (which is not ajax and can&#8217;t be set to queue) or even on some link which actually triggers an action.  So,  you are still not safe since user have a lot of ways to break your application by click on another element which will trigger action inside current conversation.</p>
<p>Besides the fact that using a4j-queues is a good practice (it improve the overall perfomance of application also) &#8211; to be absolutely safe you have to disable ALL THE LINKS in the document or make them inaccessible for the user. And the solution exists, it rather simple but very powerful. So what you have to do &#8211; is to show &#60;rich:modalPanel&#62; once user is click on the link (or start ajax request with &#60;a4j:support&#62;) and hide it after ajax-response is complete. For h:commandLink or h:commandButton &#8211; you don&#8217;t have to worry about hiding it, since once new page will be loaded rich:modalPanel will be disappeared automatically (since it belongs to previous page/DOM-document). Once rich:modalPanel is shown &#8211; it makes impossible to use any navigation elements on the page except the elements on that form itself.</p>
<p>You can even automatically enable it for all your ajax-request&#8217;s with help of &#60;a4j:status&#62; and &#8220;onstart&#8221; &#8220;onstop&#8221; handlers.  In the example below the onRequestStart() function is called by onstart handler of aj4:status component. In the example below</p>
<pre class="brush: jscript;">
//javascript
var waitDialogShown = false;
var useTimerBeforeShowWaitDialog = true;
var waitDialogTimeout = 50;
var waitDialogTimer;

function showWaitDialog() {
    //avoid attempt to show it if it is already shown
    if (!waitDialogShown) {
        Richfaces.showModalPanel('wait-dialog');
        waitDialogShown = true;
    }
}

function onRequestStart() {
    if (useTimerBeforeShowWaitDialog) {
        waitDialogTimer = setTimeout(&#34;showWaitDialog();&#34;, waitDialogTimeout);
    } else {
        showWaitDialog();
    }
}
function onRequestEnd() {
    if (waitDialogShown) {
        Richfaces.hideModalPanel('wait-dialog');
        waitDialogShown = false;
    } else if (useTimerBeforeShowWaitDialog &#38;&#38; waitDialogTimer) {
        clearTimeout(waitDialogTimer);
    }
}
</pre>
<pre class="brush: xml;">
&#60;a4j:status onstart=&#34;onRequestStart()&#34; onstop=&#34;onRequestEnd()&#34;/&#62;

&#60;rich:modalPanel id=&#34;wait-dialog&#34; resizeable=&#34;false&#34; autosized=&#34;false&#34; width=&#34;200&#34; height=&#34;65&#34; moveable=&#34;false&#34; shadowOpacity=&#34;0&#34;&#62;
  &#60;f:facet name=&#34;header&#34;&#62;One moment please..&#60;/f:facet&#62;
  &#60;h:outputText value=&#34;Your request is being processed.&#34;/&#62;
&#60;/rich:modalPanel&#62;

&#60;!-- Your wait dialog can be invisible for the users if you don't want your screen blink with that dialog on each request --&#62;
&#60;rich:modalPanel id=&#34;wait-dialog-invisible&#34; resizeable=&#34;false&#34; autosized=&#34;false&#34;
width=&#34;10&#34; height=&#34;10&#34; moveable=&#34;false&#34; left=&#34;-100&#34; top=&#34;-100&#34; shadowOpacity=&#34;0&#34;/&#62;
</pre>
<p>And if you don&#8217;t want to apply that for every component or want to modify prevention behavior you can do one of the:</p>
<ol>
<li>Explicitly define onclick function of your links/buttons<br />
&#60;h:commandButton onclick=&#8221;onRequestStart();&#8221; value=&#8221;Button&#8221;/&#62;<br />
for ajax you also have to define <strong>oncomplete</strong> to hide the modalPanel, otherwise your browser-page will be blocked<br />
&#60;a4j:commandButton onclick=&#8221;onRequestStart();&#8221; oncomplete=&#8221;onRequestEnd();&#8221; value=&#8221;Button&#8221;/&#62;</li>
<li>Define <strong>a4j:status</strong> with <strong>id</strong> and <strong>forceId=&#8221;true&#8221;</strong> and use <strong><span>status </span></strong><span>attribute of your ajax components to specify the a4j:status component they will use.<br />
</span></li>
</ol>
<pre class="brush: xml;">
   &#60;a4j:status id=&#34;waitStatus&#34; forceId=&#34;true&#34; onstart=&#34;onRequestStart()&#34; onstop=&#34;onRequestEnd()&#34;/&#62;
   &#60;a4j:commandLink status=&#34;waitStatus&#34;/&#62;
</pre>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Máscara em campo com JQuery+ MeioMask + Rich Faces + Ajax4Java]]></title>
<link>http://eryckson.wordpress.com/2009/07/09/mascara-em-campo-com-jquery-meiomask-rich-faces-ajax4java/</link>
<pubDate>Thu, 09 Jul 2009 19:31:44 +0000</pubDate>
<dc:creator>eryckson</dc:creator>
<guid>http://eryckson.wordpress.com/2009/07/09/mascara-em-campo-com-jquery-meiomask-rich-faces-ajax4java/</guid>
<description><![CDATA[  Encontramos uma solução bacana para máscaras em campos com rich faces + ajax4java + jquery. O prob]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p> </p>
<p>Encontramos uma solução bacana para máscaras em campos com rich faces + ajax4java + jquery.</p>
<p>O problema apareceu porque o uso de javascript &#8220;padrão&#8221; que estavamos fazendo conflitava com os eventos a4j, ou seja, um campo com máscara não disparava um evento onchange chamando um método no bean.</p>
<p>Segue um breve relato sobre a solução.</p>
<p>Temos que importar dois arquivos JavaScript: o do jquery e do plugin meioMask.  </p>
<p>&#60;script src=<em>&#8220;javascripts/jquery.js&#8221;</em> type=<em>&#8220;text/javascript&#8221;</em> charset=<em>&#8220;utf-8&#8243;</em>&#62;&#60;/script&#62;         </p>
<p>&#60;script src=<em>&#8220;javascripts/jquery.meio.mask.js&#8221;</em> type=<em>&#8220;text/javascript&#8221;</em> charset=<em>&#8220;utf-8&#8243;</em>&#62;&#60;/script&#62;</p>
<p>O código abaixo configura as máscaras nos campos no load da página:</p>
<p>            &#60;script type=<em>&#8220;text/javascript&#8221;</em> &#62;</p>
<p>                  (<strong>function</strong>($)</p>
<p>                  {</p>
<p>                        // call setMask function on the document.ready event</p>
<p>                        $(<strong>function</strong>()</p>
<p>                        {</p>
<p>                             $(&#8216;input:text&#8217;).setMask();</p>
<p>                        });</p>
<p>                  })(jQuery);</p>
<p>            &#60;/script&#62;</p>
<p>Já nas páginas, configuramos a máscara no campo da seguinte forma:</p>
<p>Ex. 1: Máscara de inteiro:</p>
<p>&#60;h:inputText <strong>id</strong><strong>=</strong><strong>&#8220;campoUm&#8221;</strong> value=<em>&#8220;#{managedBean.campoUm}&#8221; </em>label=<em>&#8220;#{rotulo['campo_um']}&#8221;</em> <strong>alt</strong><strong>=</strong><strong>&#8220;integer&#8221;</strong> &#62;</p>
<p>      <strong>&#60;</strong><strong>rich:jQuery</strong><strong> </strong><strong>selector</strong><strong>=</strong><strong>&#8220;#campoUm&#8221;</strong><strong> </strong><strong>query</strong><strong>=</strong><strong>&#8220;setMask({})&#8221;</strong><strong> </strong><strong>timing</strong><strong>=</strong><strong>&#8220;immediate&#8221;</strong><strong> </strong><strong>/&#62;</strong></p>
<p>&#60;/h:inputText&#62;</p>
<p>Ex. 2: Máscara de decimal:</p>
<p>&#60;h:inputText <strong>id</strong><strong>=</strong><strong>&#8220;campoDois&#8221;</strong> value=<em>&#8220;#{managedBean.campoDois}&#8221; </em>label=<em>&#8220;#{rotulo['campo_dois']}&#8221;</em> <strong>alt</strong><strong>=</strong><strong>&#8220;decimal&#8221;</strong>&#62;</p>
<p>      <strong>&#60;</strong><strong>rich:jQuery</strong><strong> </strong><strong>selector</strong><strong>=</strong><strong>&#8220;#campoDois&#8221;</strong><strong> </strong><strong>query</strong><strong>=</strong><strong>&#8220;setMask({})&#8221;</strong><strong> </strong><strong>timing</strong><strong>=</strong><strong>&#8220;immediate&#8221;</strong><strong> </strong><strong>/&#62;</strong></p>
<p>      &#60;f:convertNumber groupingUsed=<em>&#8220;true&#8221;</em> minFractionDigits=<em>&#8220;2&#8243;</em> maxFractionDigits=<em>&#8220;2&#8243;</em> locale=<em>&#8220;pt_br&#8221;</em> /&#62;</p>
<p>&#60;/h:inputText&#62;</p>
<p>Então, no h:inputText configuramos o atributo <strong>id</strong> com o identificador do componente e o atributo <strong>alt</strong> com a máscara que queremos utilizar (já definida no js do meioMask).</p>
<p>A tag <strong>rich:jQuery</strong> é utilizada para “manter” a máscara quando há alguma requisição no servidor.</p>
<p>A tag <strong>f:convertNumber</strong> é utilizada devido ao “locale” dos decimais, para evitar erros de considerar um número com vírgula decimal sendo uma string, por exemplo.</p>
<p>É somente isto. No caso de um campo com Ajax Suport não pega nada, é só seguir o jogo:</p>
<p>Ex. 3: Ajax suport com validação de length e exibição de modal:</p>
<p>&#60;h:inputText <strong>id</strong><strong>=</strong><strong>&#8220;campoTres&#8221;</strong> value=<em>&#8220;#{managedBean.campoTres}&#8221;</em> required=<em>&#8220;true&#8221;</em> label=<em>&#8220;#{rotulo['campo_tres']}&#8221;</em> <strong>alt</strong><strong>=</strong><strong>&#8220;decimal&#8221;</strong>&#62;</p>
<p>      <strong>&#60;</strong><strong>rich:jQuery</strong><strong> </strong><strong>selector</strong><strong>=</strong><strong>&#8220;#campoTres&#8221;</strong><strong> </strong><strong>query</strong><strong>=</strong><strong>&#8220;setMask({})&#8221;</strong><strong> </strong><strong>timing</strong><strong>=</strong><strong>&#8220;immediate&#8221;</strong><strong> </strong><strong>/&#62;</strong></p>
<p>      &#60;f:convertNumber groupingUsed=<em>&#8220;true&#8221;</em> minFractionDigits=<em>&#8220;2&#8243;</em> maxFractionDigits=<em>&#8220;2&#8243;</em> locale=<em>&#8220;pt_br&#8221;</em> /&#62;</p>
<p>      &#60;a4j:support action=<em>&#8220;#{managedBean.metodoUm}&#8221;</em> event=<em>&#8220;onchange&#8221;</em> reRender=<em>&#8220;panelUm&#8221; </em>oncomplete=<em>&#8220;if(#{managedBean.exibirModal}){Richfaces.showModalPanel(&#8216;modalUm&#8217;)}&#8221; </em>&#62;</p>
<p>       &#60;f:validateLength maximum=<em>&#8220;10&#8243;</em> /&#62;</p>
<p>&#60;/h:inputText&#62;   </p>
<p>Ex. 4: Ajax suport com setPropertyActionListener:</p>
<p>&#60;h:<strong>inputText</strong><strong> </strong><strong>id</strong><strong>=</strong><strong>&#8220;campoQuatro&#8221;</strong> value=<em>&#8220;#{managedBean.campoQuatro}&#8221;</em> required=<em>&#8220;true&#8221;</em> label=<em>&#8220;Campo Quatro&#8221;</em> <strong>alt</strong><strong>=</strong><strong>&#8220;decimal&#8221;</strong>&#62;</p>
<p>      <strong>&#60;</strong><strong>rich:jQuery</strong><strong> </strong><strong>selector</strong><strong>=</strong><strong>&#8220;#campoQuatro&#8221;</strong><strong> </strong><strong>query</strong><strong>=</strong><strong>&#8220;setMask({})&#8221;</strong><strong> </strong><strong>timing</strong><strong>=</strong><strong>&#8220;immediate&#8221;</strong><strong> </strong><strong>/&#62;</strong></p>
<p>      &#60;f:convertNumber groupingUsed=<em>&#8220;true&#8221;</em> minFractionDigits=<em>&#8220;2&#8243;</em> maxFractionDigits=<em>&#8220;2&#8243;</em> locale=<em>&#8220;pt_br&#8221;</em> /&#62;</p>
<p>      &#60;a4j:support action=<em>&#8220;#{managedBean.metodoDois}&#8221;</em> event=<em>&#8220;onchange&#8221;</em> reRender=<em>&#8220;panelDois&#8221;</em>&#62;</p>
<p>           &#60;f:setPropertyActionListener value=<em>&#8220;#{produto}&#8221;</em> target=<em>&#8220;{managedBean.campoSelecionado}&#8221;</em> /&#62;</p>
<p>      &#60;/a4j:support&#62;</p>
<p>&#60;/h:inputText&#62;</p>
<p>O plugin meioMask tem muitas funcionalidades interessantes, permitindo configurar novas máscaras, estender máscaras existentes, etc.</p>
<p>Para maiores detalhes, segue os links:</p>
<p><a href="https://webmail.gaiatech.com.br/exchweb/bin/redir.asp?URL=http://www.meiocodigo.com/projects/meiomask" target="_blank">http://www.meiocodigo.com/projects/meiomask</a>/</p>
<p><a href="https://webmail.gaiatech.com.br/exchweb/bin/redir.asp?URL=http://jquery.com/" target="_blank">http://jquery.com/</a></p>
<p>Abraços!</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Dynamic Richfaces Menu, MenuItem and Action]]></title>
<link>http://lamida.wordpress.com/2009/07/08/dynamic-richfaces-menu-menuitem-and-action/</link>
<pubDate>Wed, 08 Jul 2009 14:32:15 +0000</pubDate>
<dc:creator>lamida</dc:creator>
<guid>http://lamida.wordpress.com/2009/07/08/dynamic-richfaces-menu-menuitem-and-action/</guid>
<description><![CDATA[Currently I have necessity to build dynamic menu use rich:menu and rich:menuitem. I make simple POJO]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Currently I have necessity to build dynamic menu use rich:menu and rich:menuitem. I make simple POJO model class for each menu and menuitem. Of course you can use EntityBean if necessary. Menu is just used for grouping while menuitem, children of menu which has action property that will triger some action when it is clicked.</p>
<pre class="brush: java;">
// Menu model
public class Menu{
private String menuCaption;
private boolean enabled;
// Relation to MenuItem
private List menuItems;

public Menu(String menuCaption, List menuItems, boolean enabled){
this.menuCaption = menuCaption;
this.menuItems = menuItems;
this.enabled = enabled;
}
// don't forget getter and setter
}

// MenuItem Model
public class MenuItem{
private String menuItemCaption;
private String menuItemAction;
private boolean enabled;  

public MenuItem(String menuItemCaption, String menuItemAction, boolean enabled){
this.menuItemCaption = menuItemCaption;
this.menuItemAction = menuItemAction;
this.enabled = enabled;
}
// don't forget getter and setter
}
</pre>
<p>Here are MenuManagedBean class. Property menuList will be refered in page and make some kind of this representation.<br />
Menu1		               Menu2<br />
-MenuItem1	               -MenuItem5<br />
-MenuItem2	               -MenuItem6<br />
-MenuItem3<br />
-MenuItem4</p>
<pre class="brush: java;">
public class MenuManagedBean{
private List menuList;
public List getMenuList(){
List menuItemList1 = new ArrayList();
MenuItem menuItem1 = new MenuItem(&quot;Menu Item1&quot;, &quot;#{someManagedBean.someAction}&quot;, true);
MenuItem menuItem2 = new MenuItem(&quot;Menu Item2&quot;, &quot;#{someManagedBean.someAction}&quot;, true);
MenuItem menuItem3 = new MenuItem(&quot;Menu Item3&quot;, &quot;#{someManagedBean.someAction}&quot;, true);
MenuItem menuItem4 = new MenuItem(&quot;Menu Item4&quot;, &quot;#{someManagedBean.someAction}&quot;, true);
menuItemList1.add(menuItem1);
menuItemList1.add(menuItem2);
menuItemList1.add(menuItem3);
menuItemList1.add(menuItem4);

List menuItemList2 = new ArrayList();
MenuItem menuItem5 = new MenuItem(&quot;Menu Item5&quot;, &quot;#{someManagedBean.someAction}&quot;, true);
MenuItem menuItem6 = new MenuItem(&quot;Menu Item6&quot;, &quot;#{someManagedBean.someAction}&quot;, true);
menuItemList2.add(menuItem5);
menuItemList2.add(menuItem6);

Menu menu1 = new Menu(&quot;Menu1&quot;, menuItemList1, true);
Menu menu2 = new Menu(&quot;Menu2&quot;, menuItemList2, true);

menuList = new ArrayList();
menuList.add(menu1);
menuList.add(menu2);
return menuList;
}
// getter and setter
}
</pre>
<p>Next is faces page. You can use facelets or jsp page. For your notice we use jstl c:forEach tag for looping menuList in MenuManagedBean. We can not use ui:repeat or a4j:repeat here. They will not work because ui:repeat and a4j:repeat is rendered on runtime. Otherwise c:forEach is compiled before. </p>
<p>Eventhough the faces page will be shown, and every other value attribute appear correctly, the action attribute is not work. When we click a menuitem, rather than call appropriate string action from menuItemAction property of class MenuItem, its try to call  menuItemAction method from menuItem managed bean which don&#8217;t exist.</p>
<pre class="brush: xml;">
&lt;c:forEach var=&quot;listMenu&quot; items=&quot;#{menuManagedBean.menuList}&quot;&gt;
&lt;rich:dropDownMenu disabled=&quot;#{!listMenu.enabled}&quot;&gt;
&lt;f:facet name=&quot;label&quot;&gt;
&lt;h:panelGroup&gt;
&lt;h:outputText value=&quot;#{listMenu.menuCaption}&quot;/&gt;
&lt;/h:panelGroup&gt;
&lt;/f:facet&gt;
&lt;c:forEach var=&quot;menuItem&quot; items=&quot;#{listMenu.menuItemList}&quot;&gt;
&lt;%-- The action attribute bellow is not work --%&gt;
&lt;rich:menuItem value=&quot;#{menuItem.menuItemCaption}&quot; action=&quot;#{menuItem.menuItemAction}&quot; disabled=&quot;#{!menuItem.enabled}&quot;/&gt;
&lt;/c:forEach&gt;
&lt;/rich:dropDownMenu&gt;
&lt;/c:forEach&gt;
</pre>
<p>After some trial and error, I use binding aproach. I add htmlMenuItem property from class org.richfaces.component.html.HtmlMenuItem. This property will be use as binding value in revised MenuManagedBean class bellow. </p>
<pre class="brush: java;">
import org.richfaces.component.html.HtmlMenuItem;
public class MenuItem{
private String menuItemCaption;
private String menuItemAction;
private boolean enabled;
private HtmlMenuItem htmlMenuItem;

public MenuItem(String menuItemCaption, String menuItemAction, boolean enabled){
this.menuItemCaption = menuItemCaption;
this.menuItemAction = menuItemAction;
this.enabled = enabled;
}

// getter setter

}

public class MenuManagedBean{
private List menuList;
public List getMenuList(){
List menuItemList1 = new ArrayList();
MenuItem menuItem1 = new MenuItem(&quot;Menu Item1&quot;, &quot;#{someManagedBean.someAction}&quot;, true);
// make binding
HtmlMenuItem htmlMenuItem = new HtmlMenuItem();
Class[] params = {};
MethodExpression actionExpression = app.getExpressionFactory().createMethodExpression(ctx.getELContext(),
                    menuItem1, String.class, params);
            htmlMenuItem.setActionExpression(actionExpression);
            htmlMenuItem.setDisabled(!menuItem1.getEnabled());
            htmlMenuItem.setValue(menuItem1.getMenuItemUrl());
            menuItem1.setHtmlMenuItem(htmlMenuItem);

MenuItem menuItem2 = new MenuItem(&quot;Menu Item2&quot;, &quot;#{someManagedBean.someAction}&quot;, true);
// make binding same as above
// ...
MenuItem menuItem3 = new MenuItem(&quot;Menu Item3&quot;, &quot;#{someManagedBean.someAction}&quot;, true);
// make binding same as above
// ...

MenuItem menuItem4 = new MenuItem(&quot;Menu Item4&quot;, &quot;#{someManagedBean.someAction}&quot;, true);
// make binding same as above
// ...

menuItemList1.add(menuItem1);
menuItemList1.add(menuItem2);
menuItemList1.add(menuItem3);
menuItemList1.add(menuItem4);

List menuItemList2 = new ArrayList();
MenuItem menuItem5 = new MenuItem(&quot;Menu Item5&quot;, &quot;#{someManagedBean.someAction}&quot;, true);
// make binding same as above
// ...

MenuItem menuItem6 = new MenuItem(&quot;Menu Item6&quot;, &quot;#{someManagedBean.someAction}&quot;, true);
// make binding same as above
// ...

menuItemList2.add(menuItem5);
menuItemList2.add(menuItem6);

Menu menu1 = new Menu(&quot;Menu1&quot;, menuItemList1, true);
Menu menu2 = new Menu(&quot;Menu2&quot;, menuItemList2, true);

menuList = new ArrayList();
menuList.add(menu1);
menuList.add(menu2);
return menuList;
}
}
</pre>
<p>Last step is we use binding attribute to refer every menu and its menu item. Finally, dynamic menu item work as I expect</p>
<pre class="brush: xml;">
&lt;c:forEach var=&quot;listMenu&quot; items=&quot;#{menuManagedBean.menuList}&quot;&gt;
&lt;rich:dropDownMenu disabled=&quot;#{!listMenu.enabled}&quot;&gt;
&lt;f:facet name=&quot;label&quot;&gt;
&lt;h:panelGroup&gt;
&lt;h:outputText value=&quot;#{listMenu.menuCaption}&quot;/&gt;
&lt;/h:panelGroup&gt;
&lt;/f:facet&gt;
&lt;c:forEach var=&quot;menuItem&quot; items=&quot;#{listMenu.menuItemList}&quot;&gt;
&lt;%-- We make change here --&gt;
&lt;rich:menuItem binding=&quot;#{menuItem.htmlMenuItem}&quot;/&gt;
&lt;/c:forEach&gt;
&lt;/rich:dropDownMenu&gt;
&lt;/c:forEach&gt;
</pre>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Utilizando o a4j:status]]></title>
<link>http://luisfelipevs.wordpress.com/2009/06/24/utilizando-o-a4jstatus/</link>
<pubDate>Wed, 24 Jun 2009 14:28:59 +0000</pubDate>
<dc:creator>luisfelipevs</dc:creator>
<guid>http://luisfelipevs.wordpress.com/2009/06/24/utilizando-o-a4jstatus/</guid>
<description><![CDATA[Em algumas vezes necessitamos informar ao usuário, ou ao menos, alertá-lo do que está acontecendo, q]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Em algumas vezes necessitamos informar ao usuário, ou ao menos, alertá-lo do que está acontecendo, quando fazemos isso utilizando <em>JSF</em> puro ou até mesmo <em>Struts </em>temos o re-trabalho de levar a nossa página para outra e informar o status de uma determinada ação.<br />
Utilizando ferramentas <em>Ajax</em> essas ações são interativas para o usuário, pois não mudam a página e as mantém em um mesmo lugar sem a necessidade de redirecionamento de páginas.<br />
Porém como mostrar ao usuário o que está acontecendo no momento ? De que forma isso pode ser feito ?</p>
<p>Na ótima coleção de componentes do Jboss RichFaces encontramos um componente que resolve os nossos problemas !</p>
<p>O <strong>a4j:status</strong> !</p>
<p><em>Como Funciona ?</em></p>
<p>Sua função é identificar um Evento <em>Ajax</em> seja ele em uma região associada através do atributo &#8220;<strong>for</strong>&#8221; pelo ID da região, associar o componente de eventos AJAX (a4j:commandButton, a4j:commandLink) através do atributo &#8220;status&#8221; associado ao ID do <strong>a4j:status</strong>, ou simplesmente pegar todos os eventos ajax de uma página.</p>
<p><em>Como Utilizá-lo ?</em></p>
<p>Abaixo um exemplo simples do a4j:status associado à um rich:modalPanel, o atributo &#8220;<strong>onstart</strong>&#8221; define o que ele deve fazer quando iniciar um evento Ajax, e o evento &#8220;<strong>onstop</strong>&#8221; define o que ele deve fazer quando terminar o evento <strong>Ajax</strong>.</p>
<p align="left"> </p>
<p><span style="color:#3f7f7f;"><span style="font-size:x-small;">&#60;rich:modalPanel</span></span><span style="color:#008080;"><span style="font-size:x-small;"> </span></span><span style="color:#7f007f;"><span style="font-size:x-small;">id</span></span><span style="color:#008080;"><span style="font-size:x-small;">=</span></span><em><span style="color:#2a00ff;"><span style="font-size:x-small;">&#8220;panelStatus&#8221;</span></span></em><em><span style="color:#008080;"><span style="font-size:x-small;"> </span></span></em><em><span style="color:#7f007f;"><span style="font-size:x-small;">autosized</span></span></em><em><span style="color:#008080;"><span style="font-size:x-small;">=</span></span></em><em><span style="color:#2a00ff;"><span style="font-size:x-small;">&#8220;true&#8221;</span></span></em><em><span style="color:#008080;"><span style="font-size:x-small;"> &#62;</span></span></em>  </p>
<p style="padding-left:30px;"><em><span style="color:#008080;"><span style="font-size:x-small;">&#60;<span style="color:#3f7f7f;"><span style="font-size:x-small;">h:panelGrid </span></span></span></span></em><em><span style="color:#7f007f;"><span style="font-size:x-small;">columns</span></span></em><em><span style="font-size:x-small;">=</span></em><em><span style="color:#2a00ff;"><span style="font-size:x-small;">&#8220;3&#8243;</span></span></em><em><span style="color:#008080;"><span style="font-size:x-small;">&#62;</span></span></em><em> </em></p>
<p style="padding-left:60px;" align="left"><span style="color:#008080;"><span style="font-size:x-small;">&#60;</span></span><span style="color:#3f7f7f;"><span style="font-size:x-small;">h:graphicImage</span></span> <span style="color:#7f007f;"><span style="font-size:x-small;">url</span></span><span style="font-size:x-small;">=</span><em><span style="color:#2a00ff;"><span style="font-size:x-small;">&#8220;pt/imagens/carregando.gif&#8221;</span></span></em><em> </em><em><span style="color:#7f007f;"><span style="font-size:x-small;">style</span></span></em><em><span style="font-size:x-small;">=</span></em><em><span style="color:#2a00ff;"><span style="font-size:x-small;">&#8220;border:0px&#8221;</span></span></em><em><span style="color:#008080;"><span style="font-size:x-small;">/&#62;</span></span></em><em> </em></p>
<p style="padding-left:60px;" align="left"><span style="color:#008080;"><span style="font-size:x-small;">&#60;</span></span><span style="color:#3f7f7f;"><span style="font-size:x-small;">h:outputText</span></span> <span style="color:#7f007f;"><span style="font-size:x-small;">value</span></span><span style="font-size:x-small;">=</span><em><span style="color:#2a00ff;"><span style="font-size:x-small;">&#8220;Carregando&#8230;&#8221;</span></span></em><em> </em><em><span style="color:#008080;"><span style="font-size:x-small;">/&#62;</span></span></em><em> </em></p>
<p style="padding-left:60px;" align="left"><span style="color:#008080;"><span style="font-size:x-small;">&#60;</span></span><span style="color:#3f7f7f;"><span style="font-size:x-small;">h:graphicImage</span></span> <span style="color:#7f007f;"><span style="font-size:x-small;">url</span></span><span style="font-size:x-small;">=</span><em><span style="color:#2a00ff;"><span style="font-size:x-small;">&#8220;pt/imagens/img_carregando.gif&#8221;</span></span></em><em> </em><em><span style="color:#7f007f;"><span style="font-size:x-small;">style</span></span></em><em><span style="font-size:x-small;">=</span></em><em><span style="color:#2a00ff;"><span style="font-size:x-small;">&#8220;border:0px&#8221;</span></span></em><em><span style="color:#008080;"><span style="font-size:x-small;">/&#62;</span></span></em><em> </em></p>
<p style="padding-left:30px;" align="left"><span style="color:#008080;"><span style="font-size:x-small;">&#60;/</span></span><span style="color:#3f7f7f;"><span style="font-size:x-small;">h:panelGrid</span></span><span style="color:#008080;"><span style="font-size:x-small;">&#62;</span></span> </p>
<p><span style="color:#008080;"><span style="font-size:x-small;">&#60;/</span></span><span style="color:#3f7f7f;"><span style="font-size:x-small;">rich:modalPanel</span></span><span style="color:#008080;"><span style="font-size:x-small;">&#62;</span></span> </p>
<p><span style="color:#008080;"><span style="font-size:x-small;">&#60;</span></span><span style="color:#3f7f7f;"><span style="font-size:x-small;">a4j:status</span></span> <span style="color:#7f007f;"><span style="font-size:x-small;">id</span></span><span style="font-size:x-small;">=</span><em><span style="color:#2a00ff;"><span style="font-size:x-small;">&#8220;statusCarregarModalPanel&#8221;</span></span></em><em> </em><em><span style="color:#7f007f;"><span style="font-size:x-small;">onstart</span></span></em><em><span style="font-size:x-small;">=</span></em><em><span style="color:#2a00ff;"><span style="font-size:x-small;">&#8220;Richfaces.showModalPanel(&#8216;panelStatus&#8217;);&#8221;</span></span></em><em> </em><em><span style="color:#7f007f;"><span style="font-size:x-small;">onstop</span></span></em><em><span style="font-size:x-small;">=</span></em><em><span style="color:#2a00ff;"><span style="font-size:x-small;">&#8220;#{rich:component(&#8216;panelStatus&#8217;)}.hide()&#8221;</span></span></em><em> </em><em><span style="color:#008080;"><span style="font-size:x-small;">&#62;</span></span></em></p>
<p><em><span style="color:#008080;"><span style="font-size:x-small;">&#60;/</span></span></em><em><span style="color:#3f7f7f;"><span style="font-size:x-small;">a4j:status</span></span></em><em><span style="color:#008080;"><span style="font-size:x-small;">&#62;</span></span></em></p>
<p>Dessa forma quando ocorrer o evento <em>Ajax </em>ele irá renderizar o ModalPanel:</p>
<p><img src="http://luisfelipevs.wordpress.com/files/2009/06/carregando.jpg" border="0" alt="carregando" width="163" height="57" align="bottom" /></p>
<p>O <strong>a4j:status</strong> também captura eventos na página de acordo com a orientação dada a ele, exemplo:</p>
<p><span style="color:#3f7f7f;"><span style="font-size:x-small;">&#60;a4j:region</span></span> <span style="color:#7f007f;"><span style="font-size:x-small;">id</span></span><span style="font-size:x-small;">=</span><em><span style="color:#2a00ff;"><span style="font-size:x-small;">&#8220;region&#8221;</span></span></em><em><span style="color:#008080;"><span style="font-size:x-small;">&#62;</span></span></em></p>
<p style="padding-left:30px;" align="left"><em><span style="color:#008080;"><span style="font-size:x-small;">&#60;</span></span></em><em><span style="color:#3f7f7f;"><span style="font-size:x-small;">a4j:commandButton</span></span></em><em> </em><em><span style="color:#7f007f;"><span style="font-size:x-small;">value</span></span></em><em><span style="font-size:x-small;">=</span></em><em><span style="color:#2a00ff;"><span style="font-size:x-small;">&#8220;OK&#8221;</span></span></em><em> </em><em><span style="color:#7f007f;"><span style="font-size:x-small;">id</span></span></em><em><span style="font-size:x-small;">=</span></em><em><span style="color:#2a00ff;"><span style="font-size:x-small;">&#8220;btnOK&#8221;</span></span></em><em> </em><em><span style="color:#008080;"><span style="font-size:x-small;">/&#62;</span></span></em></p>
<p><em><span style="color:#008080;"><span style="font-size:x-small;">&#60;/</span></span></em><em><span style="color:#3f7f7f;"><span style="font-size:x-small;">a4j:region</span></span></em><em><span style="color:#008080;"><span style="font-size:x-small;">&#62;</span></span></em></p>
<p><em><span style="color:#3f7f7f;"><span style="font-size:x-small;">a4j:status</span></span></em><em> </em><em><span style="color:#7f007f;"><span style="font-size:x-small;">id</span></span></em><em><span style="font-size:x-small;">=</span></em><em><span style="color:#2a00ff;"><span style="font-size:x-small;">&#8220;statusSalvandoModalPanel&#8221;</span></span></em><em> </em><em><span style="color:#7f007f;"><span style="font-size:x-small;">for</span></span></em><em><span style="font-size:x-small;">=</span></em><em><span style="color:#2a00ff;"><span style="font-size:x-small;">&#8220;region&#8221;</span></span></em><em> </em><em><span style="color:#7f007f;"><span style="font-size:x-small;">onstart</span></span></em><em><span style="font-size:x-small;">=</span></em><em><span style="color:#2a00ff;"><span style="font-size:x-small;">&#8220;Richfaces.showModalPanel(&#8216;panelStatusSalvandoInformacoes&#8217;);&#8221; </span></span></em><em><span style="color:#7f007f;"><span style="font-size:x-small;">onstop</span></span></em><em><span style="font-size:x-small;">=</span></em><em><span style="color:#2a00ff;"><span style="font-size:x-small;">&#8220;#{rich:component(&#8216;panelStatusSalvandoInformacoes&#8217;)}.hide()&#8221;</span></span></em><em> </em><em><span style="color:#008080;"><span style="font-size:x-small;">&#62;</span></span></em></p>
<p><em><span style="color:#008080;"><span style="font-size:x-small;">&#60;/</span></span></em><em><span style="color:#3f7f7f;"><span style="font-size:x-small;">a4j:status</span></span></em><em><span style="color:#008080;"><span style="font-size:x-small;">&#62;</span></span></em></p>
<p>No caso acima todo e qualquer evento <em>Ajax</em> que ocorrer dentro da região especificada irá iniciar o a4j:status.</p>
<p>Outra forma de inicializar o <strong>a4j:status</strong> é através do atributo &#8220;<strong>status</strong>&#8221; de um determinado componente, incrementando um pouco mais o exemplo acima:</p>
<p><em><span style="color:#3f7f7f;"><span style="font-size:x-small;"><em><span style="color:#008080;"><span style="font-size:x-small;">&#60;</span></span></em>a4j:region</span></span></em><em> </em><em><span style="color:#7f007f;"><span style="font-size:x-small;">id</span></span></em><em><span style="font-size:x-small;">=</span></em><em><span style="color:#2a00ff;"><span style="font-size:x-small;">&#8220;region&#8221;</span></span></em><em><span style="color:#008080;"><span style="font-size:x-small;">&#62;</span></span></em></p>
<p style="padding-left:30px;" align="left"><em><span style="color:#008080;"><span style="font-size:x-small;">&#60;</span></span></em><em><span style="color:#3f7f7f;"><span style="font-size:x-small;">a4j:commandButton</span></span></em><em><span style="font-size:x-small;"> </span></em><em><span style="color:#7f007f;"><span style="font-size:x-small;">value</span></span></em><em><span style="font-size:x-small;">=</span></em><em><span style="color:#2a00ff;"><span style="font-size:x-small;">&#8220;OK&#8221;</span></span></em><em><span style="font-size:x-small;"> </span></em><em><span style="color:#7f007f;"><span style="font-size:x-small;">id</span></span></em><em><span style="font-size:x-small;">=</span></em><em><span style="color:#2a00ff;"><span style="font-size:x-small;">&#8220;btnOK&#8221; </span></span></em><em><span style="color:#7f007f;"><span style="font-size:x-small;">status</span></span></em><em><span style="color:#000000;"><span style="font-size:x-small;">=</span></span></em><em><span style="color:#2a00ff;"><span style="font-size:x-small;">&#8220;statusSalvandoModalPanel&#8221;</span></span></em><em><span style="font-size:x-small;"> </span></em><em><span style="color:#008080;"><span style="font-size:x-small;">/&#62;</span></span></em></p>
<p><em><span style="color:#008080;"><span style="font-size:x-small;">&#60;/</span></span></em><em><span style="color:#3f7f7f;"><span style="font-size:x-small;">a4j:region</span></span></em><em><span style="color:#008080;"><span style="font-size:x-small;">&#62;</span></span></em></p>
<p align="left"><em><span style="color:#008080;"><span style="font-size:x-small;">&#60;</span></span></em><em><span style="color:#3f7f7f;"><span style="font-size:x-small;">a4j:status</span></span></em><em> </em><em><span style="color:#7f007f;"><span style="font-size:x-small;">id</span></span></em><em><span style="font-size:x-small;">=</span></em><em><span style="color:#2a00ff;"><span style="font-size:x-small;">&#8220;statusSalvandoModalPanel&#8221;</span></span></em><em> </em><em><span style="color:#7f007f;"><span style="font-size:x-small;">onstart</span></span></em><em><span style="font-size:x-small;">=</span></em><em><span style="color:#2a00ff;"><span style="font-size:x-small;">&#8220;Richfaces.showModalPanel(&#8216;panelStatusSalvandoInformacoes&#8217;);&#8221; </span></span></em><em><span style="color:#7f007f;"><span style="font-size:x-small;">onstop</span></span></em><em><span style="font-size:x-small;">=</span></em><em><span style="color:#2a00ff;"><span style="font-size:x-small;">&#8220;#{rich:component(&#8216;panelStatusSalvandoInformacoes&#8217;)}.hide()&#8221;</span></span></em><em> </em><em><span style="color:#008080;"><span style="font-size:x-small;">&#62;</span></span></em></p>
<p align="left"><em><span style="color:#008080;"><span style="font-size:x-small;">&#60;/</span></span></em><em><span style="color:#3f7f7f;"><span style="font-size:x-small;">a4j:status</span></span></em><em><span style="color:#008080;"><span style="font-size:x-small;">&#62;</span></span></em></p>
<p>Dessa forma o <strong>a4j:status</strong> só irá funcionar se caso algum componente o referenciar.</p>
<p>Bom é isso ai Pessoal !</p>
<p>Até a próxima !</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Clear JSF Input Components]]></title>
<link>http://ahoehma.wordpress.com/2009/06/22/clear-jsf-input-components/</link>
<pubDate>Mon, 22 Jun 2009 15:13:02 +0000</pubDate>
<dc:creator>Andreas Höhmann</dc:creator>
<guid>http://ahoehma.wordpress.com/2009/06/22/clear-jsf-input-components/</guid>
<description><![CDATA[Beim Implementieren einer einfachen CRUD Anwendung mit Hilfe von Richfaces Datatable und ModalPanel ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Beim Implementieren einer einfachen CRUD Anwendung mit Hilfe von Richfaces Datatable und ModalPanel bin ich über ein &#8220;Problem&#8221; mit <strong>validierten (leeren) Eingabefeldern</strong> gestolpert.</p>
<p>Das Problem ist eigentlich kein richtiges Problem, sondern das Standardverhalten von JSF <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  Unschön wird es wenn man einen <strong>rich:modalPanel</strong> als Edit-Dialog einsetzt und diesen <strong>wiederverwendet</strong>.</p>
<p>Der grobe Aufbau:</p>
<ul>
<li>eine <strong>DataTable </strong>zeigt eine Liste von Entities (z.B. mit Hilfe eine DAOs geladen)</li>
<li> jedes Entity hat eine eindeutige ID (z.B. PrimaryKey aus JPA)</li>
<li>pro Tabellenzeile gibt es einen &#8220;Edit&#8221;-CommandLink der eine <strong>rich:modalPanel</strong> für das Editieren eines Entity öffnet</li>
<li>vor jedem <strong>Edit</strong> muss die gewünschte Entity in einen <strong>CrudManager</strong> (Session-Scoped Bean) gelangen, aus der sich der Edit-Dialog mit Daten versorgen kann und mit dessen Hilfe die eigentliche Edit-Aktion durchgeführt wird</li>
</ul>
<p>Nun sollen bestimmte Eingabefelder im Edit-Dialog validiert werden (z.B. mit einer @NotEmpty Annotation an den ensprechenden Properties der Entitiy-Klasse). Wenn man nun den Dialog für eine Entity mir der ID &#8216;1&#8242; öffnet und eine Validierungsfehler auslöst, z.B. durch das Abschicken mit leeren Eingabefeldern, wird dieser Fehler ausgegeben &#8230; soweit so gut. Der Dialog kann dann geschlossen werden. Soll nun Entity mit der ID &#8216;2&#8242; mit dem gleichen Dialog editiert werden, sind die Eingabefelder immer noch leer und nicht wie gewünscht mit den Werten aus Entity-2 gefüllt. Warum?!</p>
<p>Nach einer kurzen Googlesuche landete ich auf der Seite http://wiki.apache.org/myfaces/ClearInputComponents die den Effekt beschreibt. Der Grund für das Verhalten ist die Zwischenspeicherung von &#8220;SubmitedValues&#8221; in den jeweiligen UIComponents (z.B. h:inputText). Die werden den eigentlichen Modeldaten vorgezogen.</p>
<p>Will man nun einen immer aktuellen Edit-Dialog haben, gibt es verschiedene Möglichkeiten (siehe MyFaces). Ich habe mich für die &#8220;radikal einfache&#8221; Lösung entschieden &#8230; lösche alle Elemente innerhalb des Edit-Dialogs und lasse sie immer neu erzeugen.</p>
<p>Die Entity-Liste besteht aus einer rich:dataTable, pro Zeile ein a4j:commandButton:</p>
<pre class="brush: xml;">

&lt;rich:dataTable value=&quot;#{tableManager.model}&quot; var=&quot;dataItem&quot;&gt;

&lt;!-- Edit-Command Column --&gt;
&lt;rich:column sortable=&quot;false&quot;&gt;
&lt;a4j:commandButton ajaxSingle=&quot;true&quot; limitToList=&quot;true&quot;
reRender=&quot;foobar_editPanel&quot;
oncomplete=&quot;Richfaces.showModalPanel('foobar_editPanel')&quot;
 actionListener=&quot;#{crudManager.onEdit}&quot;&gt;
 &lt;f:attribute name=&quot;onEditClearTarget&quot; value=&quot;foobar_editPanel&quot;/&gt;
 &lt;f:setPropertyActionListener value=&quot;#{dataItem}&quot; target=&quot;#{crudManager.currentEntity}&quot; /&gt;
&lt;/a4j:commandButton&gt;

&lt;!-- more Columns ... --&gt;
&lt;/rich:dataTable&gt;
</pre>
<p>Der <strong>tableManager</strong> liefert die Entity-Daten, also eine Liste von Entity-Beans, jede Bean hat eine eindeutige ID. Der crudManager enthält stellt die gesamte CRUD Funktionalität zur Verfügung. Für eine Edit muss er mit einer Entity &#8220;initialisiert&#8221; werden, dies geschieht via <strong>f:setPropertyActionListener</strong>. Das reRender bewirkt, dass der Edit-Dialog aktuallisiert wird.</p>
<p>Der Edit-Dialog wird mit Hilfe von rich:modalPanel erzeugt (foobar_editPanel) und enthält eine Reihe von h:inputText Elementen. Diese sind wiederum an den crudManager gebunden.</p>
<p>Der Code für das Zurücksetzen der Inputelemente im Edit-Dialog ist ebenfalls im <strong>crudManager</strong> verborgen und sieht folgendermaßen aus:</p>
<pre class="brush: java;">

public abstract class AbstractCrudManager {

public static final String ONEDIT_ATTRIBUTE_CLEARTARGET = &quot;onEditClearTarget&quot;; //$NON-NLS-1$

/**
 * Event-handler will be triggered on &lt;tt&gt;edit&lt;/tt&gt;. This method is used as a
 * {@link ActionListener} and will be called before a &lt;tt&gt;edit-view&lt;/tt&gt; is
 * shown. So here we can do some &quot;initializations&quot; for the edit-view, i.e.
 * reset input-fields.
 *
 *
 * This base implementation will call {@link #clearEditTarget(UIComponent)}.
 *
 *
 * @param aEvent
 *          is never &lt;code&gt;null&lt;/code&gt;
 */
public void onEdit(final ActionEvent aEvent) {
clearEditTarget(aEvent.getComponent());
 }

/**
 * This method handle a edit-form-clear. Per default the command-button which delegates to the
 * edit-view could have a attribute {@link #ONEDIT_ATTRIBUTE_CLEARTARGET}.
 *
 * @param theSourceComponent
 *          is never &lt;code&gt;null&lt;/code&gt;
 */
 protected void clearEditTarget(final UIComponent theSourceComponent) {
 final String onEditTarget = (String) theSourceComponent.getAttributes().get(ONEDIT_ATTRIBUTE_CLEARTARGET);
 if (onEditTarget == null) {
 return;
 }
 final UIComponent editTarget = FacesContext.getCurrentInstance().getViewRoot().findComponent(onEditTarget);
 if (editTarget == null) {
 return;
 }
 editTarget.getChildren().clear();
 }

...

}
</pre>
<p>Damit ist auch klar was das &#60;f:attribute name=&#8221;onEditClearTarget&#8221; value=&#8221;#{id}_editPanel&#8221;/&#62; bewirkt &#8230; es definiert die UI-Komponente die vor dem Öffnen des Dialogs zurückgesetzt werden soll.</p>
<p>Damit wird bei jedem Klick auf &#8220;Edit&#8221; ein Ajax-Request zum Server geschickt, dort wird die aktuelle Entity in den crudManager hinterlegt, es wird onEdit aufgerufen und damit der Inhalt des Edit-Dialogs gelöscht. JSF sorgt dann beim RenderResponse wieder dafür, dass alle UI Componenten korrekt erzeugt werden. Da dann alle Eingabeelement noch vollkommen &#8220;neu&#8221; sind, zeigen diese auch die Werte aus dem Modell an.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Integrating richfaces &amp; myfaces]]></title>
<link>http://punnyatuladhar.wordpress.com/2009/06/18/integrating-richfaces-myfaces/</link>
<pubDate>Thu, 18 Jun 2009 04:23:14 +0000</pubDate>
<dc:creator>Punnya Tuladhar</dc:creator>
<guid>http://punnyatuladhar.wordpress.com/2009/06/18/integrating-richfaces-myfaces/</guid>
<description><![CDATA[On this blog, I have tried to use myfaces components in richfaces application. Please, check it out.]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>On this blog, I have tried to use myfaces components in richfaces application. Please, check it out.</p>
<p><a href="http://n2.nabble.com/Integrating-Myfaces---Richfaces-f3096871.html">http://n2.nabble.com/Integrating-Myfaces&#8212;Richfaces-f3096871.html</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Spring, Hibernate, Richfaces Together]]></title>
<link>http://punnyatuladhar.wordpress.com/2009/06/17/spring-hibernate-richfaces-together/</link>
<pubDate>Wed, 17 Jun 2009 03:26:27 +0000</pubDate>
<dc:creator>Punnya Tuladhar</dc:creator>
<guid>http://punnyatuladhar.wordpress.com/2009/06/17/spring-hibernate-richfaces-together/</guid>
<description><![CDATA[I have put one project named eDesk (jaas) making it open source on sourceforge.net for beginners to ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I have put one project named eDesk (jaas) making it open source on sourceforge.net for beginners to download if they want to have a sample application which integrates richfaces and hibernate in spring framework and on tomcat server. It uses firebird database.</p>
<p>eDesk is an open source java assignment submission system.</p>
<p>For linux users, it is also available on that platform for which you will have to email me to punyadotprt@gmail.com.</p>
<p>Here is the link for my project:</p>
<p><a href="http://jaas.sourceforge.net">http://jaas.sourceforge.net </a></p>
<p>Any query for help will be highly entertained.</p>
<p>Enjoy while learning!</p>
<p><img class="alignnone size-full wp-image-26" title="java assignment submission system" src="http://punnyatuladhar.wordpress.com/files/2009/06/edesk.jpg" alt="java assignment submission system" width="450" height="347" /></p>
</div>]]></content:encoded>
</item>

</channel>
</rss>
