<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-9079494833044939711</id><updated>2011-09-14T11:08:40.390-07:00</updated><title type='text'>Random thoughts vortex</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://random-thoughts-vortex.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9079494833044939711/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://random-thoughts-vortex.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>agema-makedonin</name><uri>http://www.blogger.com/profile/17141246309473354181</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_ofsKG4Jlu5I/SyoTaP7ijYI/AAAAAAAAA_c/ddPpEY159H4/S220/phpMJlNct_c3AM.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>16</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-9079494833044939711.post-2202809072358807504</id><published>2010-02-03T08:07:00.001-08:00</published><updated>2010-08-02T01:04:17.621-07:00</updated><title type='text'>Custom Portlet Scope for Spring, JSF, RichFaces portlet Applications</title><content type='html'>It is all to usual scenario. Create a Portlet, create a Spring bean with the &lt;span style="font-weight: bold;"&gt;scope="session"&lt;/span&gt; or &lt;span style="font-weight: bold;"&gt;scope="globalSession"&lt;/span&gt; and hope that everything works just fine. And it does, until you don't have the scenario where the user creates two separate instance of the same portlet definition.&lt;br /&gt;&lt;br /&gt;In that case, all you get is two portlets which display the same informations. Why? Because both of the portlet instances are getting their data from  the same Backing Bean instance.&lt;br /&gt;&lt;br /&gt;One would wonder, should one use the Spring DispatcherPortlet. If yes, how do I put all that together with JSF, RichFaces etc. At least I did not manage to find any tutorial or example how to put all that technologies together.&lt;br /&gt;&lt;br /&gt;So, are we using the right technologies? Still the Answear is most probably yes!&lt;br /&gt;&lt;br /&gt;Looking for a soulution, I came accross the information, that one can define his own scope for the Spring Beans.&lt;br /&gt;&lt;br /&gt;So I decidet to create own custom scope that saves the Spring Beans per portlet Instance. In other words, each Spring Bean Instance is saved in the PortletSession.PORTLET_SCOPE of the session.&lt;br /&gt;&lt;br /&gt;Here is the Custom Scope definition.&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;public class PortletSessionScope extends AbstractRequestAttributesScope {&lt;br /&gt;&lt;br /&gt;private final int scope;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public PortletSessionScope() {&lt;br /&gt;   this.scope = PortletSession.PORTLET_SCOPE;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;@Override&lt;br /&gt;protected int getScope() {&lt;br /&gt;  return this.scope;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public String getConversationId() {&lt;br /&gt;  String sessionId = RequestContextHolder.currentRequestAttributes().getSessionId();&lt;br /&gt;  return sessionId;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;@Override&lt;br /&gt;public Object get(String name, ObjectFactory objectFactory) {&lt;br /&gt;RequestAttributes requestAttributes =  RequestContextHolder.currentRequestAttributes();&lt;br /&gt;Object mutex = requestAttributes.getSessionMutex();&lt;br /&gt;synchronized (mutex) {&lt;br /&gt;   ExternalContext external = FacesContext.getCurrentInstance().getExternalContext();&lt;br /&gt;   Object scopedObject = null;&lt;br /&gt;   Object session = null;&lt;br /&gt;   if (null != external) {&lt;br /&gt;     session = external.getSession(false);&lt;br /&gt;     if (null != session &amp;amp;&amp;amp; session instanceof PortletSession) {&lt;br /&gt;&lt;br /&gt;       scopedObject = ((PortletSession) session).getAttribute(name, PortletSession.PORTLET_SCOPE);&lt;br /&gt;if (scopedObject == null) {&lt;br /&gt; scopedObject = objectFactory.getObject();&lt;br /&gt; ((PortletSession) session).setAttribute(name, scopedObject, PortletSession.PORTLET_SCOPE);&lt;br /&gt;}&lt;br /&gt;else if (null != session &amp;amp;&amp;amp; session instanceof ServletSessionWrapper) {&lt;br /&gt;    &lt;br /&gt;   scopedObject = ((ServletSessionWrapper) session).getAttribute(name);&lt;br /&gt;   if (scopedObject == null) {&lt;br /&gt;     scopedObject = objectFactory.getObject();&lt;br /&gt;     ((ServletSessionWrapper) session).setAttribute(name, scopedObject);&lt;br /&gt;   }&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt; return scopedObject;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;@Override&lt;br /&gt;public Object remove(String name) {&lt;br /&gt;&lt;br /&gt; Object mutex = RequestContextHolder.currentRequestAttributes().getSessionMutex();&lt;br /&gt; synchronized (mutex) {&lt;br /&gt;   Object scopedObject = super.remove(name);&lt;br /&gt;   return scopedObject;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;So now that you have the scoped bean, all it takes is to make it known to Spring. That is streight process.&lt;br /&gt;&lt;br /&gt;In your applicationContext.xml, where all the beans are ceclared, do the following:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&lt;bean class="org.springframework.beans.factory.config.CustomScopeConfigurer"&gt;&lt;br /&gt;  &lt;property name="scopes"&gt;&lt;br /&gt;    &lt;map&gt;&lt;br /&gt;      &lt;entry key="portletSession"&gt;&lt;br /&gt;       &lt;bean class="my.package.PortletSessionScope"&gt;&lt;br /&gt;       &lt;/bean&gt;&lt;br /&gt;      &lt;/entry&gt;&lt;br /&gt;    &lt;/map&gt;&lt;br /&gt;   &lt;/property&gt;&lt;br /&gt;&lt;/bean&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;So, with that done, all it takes to get Spring Bean in PorltetSession.PORTLET_SCOPE is a deffinition of a Bean with the above scope, something like this:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&lt;bean id="myPortletScopeBeanId" class="package.MyBean" scope="portletSession"&gt;&lt;br /&gt;&lt;/bean&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;That was it. Hope it works for you!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9079494833044939711-2202809072358807504?l=random-thoughts-vortex.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://random-thoughts-vortex.blogspot.com/feeds/2202809072358807504/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://random-thoughts-vortex.blogspot.com/2010/02/custom-portlet-scope-for-spring-jsf.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9079494833044939711/posts/default/2202809072358807504'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9079494833044939711/posts/default/2202809072358807504'/><link rel='alternate' type='text/html' href='http://random-thoughts-vortex.blogspot.com/2010/02/custom-portlet-scope-for-spring-jsf.html' title='Custom Portlet Scope for Spring, JSF, RichFaces portlet Applications'/><author><name>agema-makedonin</name><uri>http://www.blogger.com/profile/17141246309473354181</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_ofsKG4Jlu5I/SyoTaP7ijYI/AAAAAAAAA_c/ddPpEY159H4/S220/phpMJlNct_c3AM.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9079494833044939711.post-2417866882287621592</id><published>2009-09-23T02:14:00.000-07:00</published><updated>2010-02-03T09:11:03.319-08:00</updated><title type='text'>RichFaces Table with DataModel</title><content type='html'>Recently I needed to get the selected  Row Object of my RichFaces Data Table in to a backing bean, so that I can further manipulate it.&lt;br /&gt;&lt;br /&gt;Before that, I was using Array List to feed my Data Table. Somewhere on the way, I picked up that one can use the&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;import javax.faces.model.ArrayDataModel;&lt;br /&gt;import javax.faces.model.DataModel;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;from JSF. Let us say, that you have a Data Table, where you have a Data Object similar to this one:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;public class DataObject{&lt;br /&gt;&lt;br /&gt; private String fileName;&lt;br /&gt; private String fileMime;&lt;br /&gt; public DataObject(String fileName, String fileMime){&lt;br /&gt;      this.fileName=fileName;&lt;br /&gt;      this.fileMime=fileMime;&lt;br /&gt; }&lt;br /&gt; // getter and setter&lt;br /&gt; // exist but are omitted for this example.&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This Data Object can come from various sources, such as data base or services, or your business layer.&lt;br /&gt;&lt;br /&gt;It is nice to have an icon displayed in the Data Table instead of the row Mime type, such as &lt;span style="font-weight: bold;"&gt;plain/text&lt;/span&gt; or something similar.&lt;br /&gt;&lt;br /&gt;Let us assume, you have a set of application icons.&lt;br /&gt;&lt;br /&gt;Now you write your data table in the XHTML File, and it looks similar to this:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&lt;rich:datatable id="myTable" value="#{myBean.dataModel}" var="row"&gt;   &lt;br /&gt;&lt;rich:column&gt;&lt;br /&gt;  &lt;f:facet name="header"&gt;&lt;br /&gt;   &lt;h:outputlabel value="Name"&gt;&lt;br /&gt;  &lt;/h:outputlabel&gt;&lt;br /&gt;   &lt;h:outputtext value="#{row.name}"&gt;&lt;br /&gt;&lt;/h:outputtext&gt;&lt;br /&gt;&lt;rich:column&gt;&lt;br /&gt;  &lt;f:facet name="header"&gt;&lt;br /&gt;    &lt;h:outputlabel value="File Type"&gt;&lt;br /&gt;  &lt;/h:outputlabel&gt;      &lt;br /&gt;    &lt;h:graphicimage url="#{myBean.mimeIcon}"&gt;&lt;br /&gt;&lt;/h:graphicimage&gt;&lt;br /&gt;&lt;/f:facet&gt;&lt;br /&gt;&lt;/rich:column&gt;&lt;/f:facet&gt;&lt;/rich:column&gt;&lt;/rich:datatable&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;As you can see, the name of the file is taken directly from the table Data Model, while for the file type, we call a backing bean method to handle the mime type.&lt;br /&gt;&lt;br /&gt;The real question is, how do we know which index of the array do we have at rendering time, so that we can calculate the image URL for the certain mime type.&lt;br /&gt;&lt;br /&gt;The Backing bean would look similar to this:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;public class MyBean{&lt;br /&gt;&lt;br /&gt; private List dataModelList;&lt;br /&gt; private DataModel dataModel;&lt;br /&gt;&lt;br /&gt; public void init(){&lt;br /&gt;  // populate simple Array List&lt;br /&gt;  // with Data Objects.&lt;br /&gt;   dataModelList = new ArrayList();&lt;br /&gt;   dataModelList.add(new DataObject("first","plain/text"));&lt;br /&gt;   dataModelList.add(new DataObject("second","text/html"));&lt;br /&gt; &lt;br /&gt;   // fill the Data Model&lt;br /&gt;   dataModel = new ArrayDataModel(dataModelList);&lt;br /&gt; }&lt;br /&gt; /**&lt;br /&gt; * The method that returns an string representation of&lt;br /&gt; * of Image URL for the mime type of the file.&lt;br /&gt; */&lt;br /&gt; public String getMimeIcon(){&lt;br /&gt; &lt;br /&gt;     if(null == dataModel){&lt;br /&gt;       return null;&lt;br /&gt;     }&lt;br /&gt; &lt;br /&gt;     if(dataModel.isRowAvailable()){&lt;br /&gt;        DataObject  rowDataObject =&lt;br /&gt;           (DataObject) dataModel.getRowData();&lt;br /&gt;          return calculateMimeType(rowDataObject.getFileMime());&lt;br /&gt;     }&lt;br /&gt;    return null;&lt;br /&gt; }&lt;br /&gt; //getter and setter for the Data Model omitted here&lt;br /&gt; // but exist in the real source.&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;As you can see, in the backing bean, the getter method &lt;span style="font-weight: bold;"&gt;getMimeIcon();&lt;/span&gt; we look up if the data model row is available.&lt;br /&gt;&lt;br /&gt;If so, the &lt;span style="font-weight: bold;"&gt;getRowData();&lt;/span&gt; of the Data Model will return exactly the the Object for the row referenced by the &lt;rich:column&gt; Tag at iteration (render) time.&lt;br /&gt;&lt;br /&gt;In this case, we can have as many mime typed object in the Data Model Object as we want. We can be certain of it, that each of them get their right mime type icon.&lt;/rich:column&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9079494833044939711-2417866882287621592?l=random-thoughts-vortex.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://random-thoughts-vortex.blogspot.com/feeds/2417866882287621592/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://random-thoughts-vortex.blogspot.com/2009/09/richfaces-table-working-with-datamodel.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9079494833044939711/posts/default/2417866882287621592'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9079494833044939711/posts/default/2417866882287621592'/><link rel='alternate' type='text/html' href='http://random-thoughts-vortex.blogspot.com/2009/09/richfaces-table-working-with-datamodel.html' title='RichFaces Table with DataModel'/><author><name>agema-makedonin</name><uri>http://www.blogger.com/profile/17141246309473354181</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_ofsKG4Jlu5I/SyoTaP7ijYI/AAAAAAAAA_c/ddPpEY159H4/S220/phpMJlNct_c3AM.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9079494833044939711.post-7781631758459177807</id><published>2009-08-25T02:29:00.000-07:00</published><updated>2009-08-25T02:55:44.114-07:00</updated><title type='text'>IPC issue in WebSphere 6.1</title><content type='html'>Inter Portlet Comunication (IPC) is the hot spot in Portal environment. I already had some experience with it and described it here: &lt;a href="http://random-thoughts-vortex.blogspot.com/2009/03/jsr-286-ipc-with-faces.html"&gt;IPC with JSR 286&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Everyone would probably think as I thought, that this should work in WebSphere Portal 6.1.&lt;br /&gt;&lt;br /&gt;And it does. BUT! There is one additional requirement for having this to work under WPS 6.1.&lt;br /&gt;&lt;br /&gt;After  deploying your Portlets in the WPS you will have to go to the &lt;span style="font-weight: bold; color: rgb(204, 0, 0);"&gt;Administration Tab&lt;/span&gt; of WPS.&lt;br /&gt;&lt;br /&gt;Than on the left side click the &lt;span style="font-weight: bold; color: rgb(204, 0, 0);"&gt;Manage Pages&lt;/span&gt;.&lt;br /&gt;In the newly opened page, you will see a Table with only one column. Click on&lt;span style="color: rgb(204, 0, 0);"&gt; &lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(204, 0, 0);"&gt;ContentRoot&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;After that you will have to find your own Page-Name, which corresponds to the the &lt;span style="font-weight: bold;"&gt;Tab-Name&lt;/span&gt; where you run your Portlets.&lt;br /&gt;&lt;br /&gt;When done, on the far right you will see bunch of icons. Click &lt;span style="font-weight: bold;"&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;pencil like icon&lt;/span&gt; (it also displays the name EDIT PAGE LAYOUT when going over with your mouse).&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;The &lt;span style="font-weight: bold;"&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;Page Customizer&lt;/span&gt; &lt;/span&gt;will open. Four Tabs are available:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;Content &lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="color: rgb(204, 0, 0);"&gt;&lt;span style="font-weight: bold;"&gt;Appearance&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="color: rgb(204, 0, 0);"&gt; Locks &lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="color: rgb(204, 0, 0);"&gt;&lt;span style="font-weight: bold;"&gt;Wires &lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;In the Content Tab, you add all the Portlets you want to run here on this page (your newly developed Portlets with IPC).&lt;br /&gt;&lt;br /&gt;After doing, click the &lt;span style="font-weight: bold; color: rgb(204, 0, 0);"&gt;Wires&lt;/span&gt;&lt;span style="color: rgb(204, 0, 0);"&gt; &lt;/span&gt;Tab. WPS has already read your &lt;span style="font-weight: bold; color: rgb(204, 0, 0);"&gt;portlet.xml&lt;/span&gt; file. You will see a table with the following columns:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color: rgb(204, 0, 0); font-weight: bold;"&gt;Source portlet&lt;/span&gt;  - The Event Publishing Portlet &lt;/li&gt;&lt;li&gt;&lt;span style="color: rgb(204, 0, 0); font-weight: bold;"&gt;Sending&lt;/span&gt;  - The Publishing Event name space and name&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold; color: rgb(204, 0, 0);"&gt;Target page&lt;/span&gt;   - leave it as it is. Here you can define the Page if your target Portlet is on another page. If on the same page, leave it as it is.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold; color: rgb(204, 0, 0);"&gt;Switch page&lt;/span&gt; - I don't really get it what this has to do with all of this here (but hey)&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold; color: rgb(204, 0, 0);"&gt;Target portlet&lt;/span&gt; - The Portlet that has to consume your Published Event&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold; color: rgb(204, 0, 0);"&gt;Receiving&lt;/span&gt;  - The name space and name of your Published Event.&lt;/li&gt;&lt;li&gt; &lt;span style="font-weight: bold; color: rgb(204, 0, 0);"&gt;Wire Type&lt;/span&gt; - leave it to Public&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;Don't forget to press the tiny + button on the end. This has to be repeated for each IPC Event of your Portlets.&lt;br /&gt;&lt;br /&gt;When done, press the &lt;span style="font-weight: bold; color: rgb(204, 0, 0);"&gt;Done &lt;/span&gt;Button.&lt;br /&gt;&lt;br /&gt;Now you can go to your Page Tab and test your IPC Eventing.&lt;br /&gt;&lt;br /&gt;Hope it works for you too.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9079494833044939711-7781631758459177807?l=random-thoughts-vortex.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://random-thoughts-vortex.blogspot.com/feeds/7781631758459177807/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://random-thoughts-vortex.blogspot.com/2009/08/ipc-issue-in-websphere-61.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9079494833044939711/posts/default/7781631758459177807'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9079494833044939711/posts/default/7781631758459177807'/><link rel='alternate' type='text/html' href='http://random-thoughts-vortex.blogspot.com/2009/08/ipc-issue-in-websphere-61.html' title='IPC issue in WebSphere 6.1'/><author><name>agema-makedonin</name><uri>http://www.blogger.com/profile/17141246309473354181</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_ofsKG4Jlu5I/SyoTaP7ijYI/AAAAAAAAA_c/ddPpEY159H4/S220/phpMJlNct_c3AM.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9079494833044939711.post-4981444194141050803</id><published>2009-08-25T01:19:00.000-07:00</published><updated>2009-08-25T03:08:43.787-07:00</updated><title type='text'>Maven Dependency Management for running RichFaces project on WebSphere 6.1</title><content type='html'>It is somewhat troubling issue when trying to deploy the same project in different environments. Some Application Servers (AS) ship their own versions of different library's. This will cause the same application to fail or run on different AS.  For example, JBoss ships the JSF Library's while WebSphere does not. Examples are numerous.&lt;br /&gt;&lt;br /&gt;Here is how you can configure Maven to build your RichFaces Application with all the needed Jar's and up and running to WebSphere AS  6.1. -  WebSphere Porta 6.1&lt;br /&gt;&lt;br /&gt;NOTE: This might not work  for another Server version!?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&lt;br /&gt;&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xsi="http://www.w3.org/2001/XMLSchema-instance" schemalocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;&lt;br /&gt;&lt;modelversion&gt;4.0.0&lt;/modelversion&gt;&lt;br /&gt;&lt;groupid&gt;de.mycompany.group.id&lt;/groupid&gt;&lt;br /&gt;&lt;artifactid&gt;myproject-artifact-id&lt;/artifactid&gt;&lt;br /&gt;&lt;packaging&gt;war&lt;/packaging&gt;&lt;br /&gt;&lt;name&gt;Basic RichFaces on WebSphere&lt;/name&gt;&lt;br /&gt;&lt;version&gt;1.0&lt;/version&gt;&lt;br /&gt;&lt;description&gt;Basis RichFaces Project running on WebSphere 6.1&lt;/description&gt;&lt;br /&gt;&lt;build&gt;&lt;br /&gt; &lt;plugins&gt;&lt;br /&gt;  &lt;plugin&gt;&lt;br /&gt;   &lt;artifactid&gt;maven-compiler-plugin&lt;/artifactid&gt;&lt;br /&gt;   &lt;configuration&gt;&lt;br /&gt;    &lt;source&gt;1.5&lt;br /&gt;    &lt;target&gt;1.5&lt;/target&gt;&lt;br /&gt;   &lt;/configuration&gt;&lt;br /&gt;  &lt;/plugin&gt;&lt;br /&gt; &lt;/plugins&gt;&lt;br /&gt;&lt;/build&gt;&lt;br /&gt;&lt;!--  Some online repositories where maven can download it's dependencies.--&gt;&lt;br /&gt;&lt;repositories&gt;&lt;br /&gt; &lt;repository&gt;&lt;br /&gt;  &lt;id&gt;apache-repo&lt;/id&gt;&lt;br /&gt;  &lt;name&gt;apache-repo&lt;/name&gt;&lt;br /&gt;  &lt;url&gt;http://myfaces.zones.apache.org/dist/maven-repository &lt;/url&gt;&lt;br /&gt; &lt;/repository&gt;&lt;br /&gt; &lt;repository&gt;&lt;br /&gt;  &lt;id&gt;ibiblio&lt;/id&gt;&lt;br /&gt;  &lt;name&gt;ibiblio-repo&lt;/name&gt;&lt;br /&gt;  &lt;url&gt;http://mirrors.ibiblio.org/pub/mirrors/maven&lt;/url&gt;&lt;br /&gt; &lt;/repository&gt;&lt;br /&gt; &lt;repository&gt;&lt;br /&gt;  &lt;id&gt;jboss-repository&lt;/id&gt;&lt;br /&gt;  &lt;name&gt;jboss-maven&lt;/name&gt;&lt;br /&gt;  &lt;url&gt;http://repository.jboss.org/maven2/&lt;br /&gt;           &lt;/url&gt;&lt;br /&gt; &lt;/repository&gt;&lt;br /&gt; &lt;repository&gt;&lt;br /&gt;  &lt;id&gt;just-another-repository&lt;/id&gt;&lt;br /&gt;  &lt;name&gt;maven-repo&lt;/name&gt;&lt;br /&gt;  &lt;url&gt;http://mariner.volantis.com/maven&lt;br /&gt;           &lt;/url&gt;&lt;br /&gt; &lt;/repository&gt;&lt;br /&gt; &lt;repository&gt;&lt;br /&gt;  &lt;id&gt;central&lt;/id&gt;&lt;br /&gt;  &lt;name&gt;repository&lt;/name&gt;&lt;br /&gt;  &lt;url&gt;http://repo1.maven.org/maven2&lt;/url&gt;&lt;br /&gt; &lt;/repository&gt;&lt;br /&gt; &lt;repository&gt;&lt;br /&gt;  &lt;id&gt;maven2-repository.dev.java.net&lt;/id&gt;&lt;br /&gt;  &lt;name&gt;Java.net Repository for Maven&lt;/name&gt;&lt;br /&gt;  &lt;url&gt;http://download.java.net/maven/2&lt;/url&gt;&lt;br /&gt;  &lt;layout&gt;default&lt;/layout&gt;&lt;br /&gt; &lt;/repository&gt;&lt;br /&gt;&lt;/repositories&gt;&lt;br /&gt;&lt;!-- Some maven plugin's repositories. --&gt;&lt;br /&gt;&lt;pluginrepositories&gt;&lt;br /&gt; &lt;pluginrepository&gt;&lt;br /&gt;  &lt;id&gt;codehaus-repository&lt;/id&gt;&lt;br /&gt;  &lt;name&gt;Plugin Repository von Mojo Codehaus&lt;/name&gt;&lt;br /&gt;  &lt;url&gt;http://repository.codehaus.org/&lt;br /&gt;           &lt;/url&gt;&lt;br /&gt; &lt;/pluginrepository&gt;&lt;br /&gt;&lt;/pluginrepositories&gt;&lt;br /&gt;&lt;!-- The dependencies management. The versions are handled here. --&gt;&lt;br /&gt;&lt;dependencymanagement&gt;&lt;br /&gt; &lt;dependencies&gt;&lt;br /&gt;  &lt;dependency&gt;&lt;br /&gt;   &lt;groupid&gt;com.sun.facelets&lt;/groupid&gt;&lt;br /&gt;   &lt;artifactid&gt;jsf-facelets&lt;/artifactid&gt;&lt;br /&gt;   &lt;version&gt;1.1.14&lt;/version&gt;&lt;br /&gt;  &lt;/dependency&gt;&lt;br /&gt;  &lt;dependency&gt;&lt;br /&gt;   &lt;groupid&gt;javax.faces&lt;/groupid&gt;&lt;br /&gt;   &lt;artifactid&gt;jsf-impl&lt;/artifactid&gt;&lt;br /&gt;   &lt;version&gt;${jsf.version}&lt;/version&gt;&lt;br /&gt;  &lt;/dependency&gt;&lt;br /&gt;  &lt;dependency&gt;&lt;br /&gt;   &lt;groupid&gt;javax.faces&lt;/groupid&gt;&lt;br /&gt;   &lt;artifactid&gt;jsf-api&lt;/artifactid&gt;&lt;br /&gt;   &lt;version&gt;${jsf.version}&lt;/version&gt;&lt;br /&gt;  &lt;/dependency&gt;&lt;br /&gt;  &lt;dependency&gt;&lt;br /&gt;   &lt;groupid&gt;org.richfaces.ui&lt;/groupid&gt;&lt;br /&gt;   &lt;artifactid&gt;richfaces-ui&lt;/artifactid&gt;&lt;br /&gt;   &lt;version&gt;${richfaces.version}&lt;/version&gt;&lt;br /&gt;   &lt;exclusions&gt;&lt;br /&gt;    &lt;exclusion&gt;&lt;br /&gt;     &lt;groupid&gt;org.ajax4jsf&lt;/groupid&gt;&lt;br /&gt;     &lt;artifactid&gt;ajax4jsf&lt;/artifactid&gt;&lt;br /&gt;    &lt;/exclusion&gt;&lt;br /&gt;    &lt;exclusion&gt;&lt;br /&gt;     &lt;groupid&gt;javax.faces&lt;/groupid&gt;&lt;br /&gt;     &lt;artifactid&gt;jsf-api&lt;/artifactid&gt;&lt;br /&gt;    &lt;/exclusion&gt;&lt;br /&gt;    &lt;exclusion&gt;&lt;br /&gt;     &lt;groupid&gt;javax.faces&lt;/groupid&gt;&lt;br /&gt;     &lt;artifactid&gt;jsf-impl&lt;/artifactid&gt;&lt;br /&gt;    &lt;/exclusion&gt;&lt;br /&gt;   &lt;/exclusions&gt;&lt;br /&gt;  &lt;/dependency&gt;&lt;br /&gt;  &lt;dependency&gt;&lt;br /&gt;   &lt;groupid&gt;org.jboss.portletbridge&lt;/groupid&gt;&lt;br /&gt;   &lt;artifactid&gt;portletbridge-api&lt;/artifactid&gt;&lt;br /&gt;   &lt;version&gt;${portletbridge.version}&lt;/version&gt;&lt;br /&gt;   &lt;exclusions&gt;&lt;br /&gt;    &lt;exclusion&gt;&lt;br /&gt;     &lt;groupid&gt;javax.faces&lt;/groupid&gt;&lt;br /&gt;     &lt;artifactid&gt;jsf-api&lt;/artifactid&gt;&lt;br /&gt;    &lt;/exclusion&gt;&lt;br /&gt;    &lt;exclusion&gt;&lt;br /&gt;     &lt;groupid&gt;javax.faces&lt;/groupid&gt;&lt;br /&gt;     &lt;artifactid&gt;jsf-impl&lt;/artifactid&gt;&lt;br /&gt;    &lt;/exclusion&gt;&lt;br /&gt;   &lt;/exclusions&gt;&lt;br /&gt;  &lt;/dependency&gt;&lt;br /&gt;  &lt;dependency&gt;&lt;br /&gt;   &lt;groupid&gt;org.jboss.portletbridge&lt;/groupid&gt;&lt;br /&gt;   &lt;artifactid&gt;portletbridge-impl&lt;/artifactid&gt;&lt;br /&gt;   &lt;version&gt;${portletbridge.version}&lt;/version&gt;&lt;br /&gt;   &lt;exclusions&gt;&lt;br /&gt;    &lt;exclusion&gt;&lt;br /&gt;     &lt;groupid&gt;javax.faces&lt;/groupid&gt;&lt;br /&gt;     &lt;artifactid&gt;jsf-api&lt;/artifactid&gt;&lt;br /&gt;    &lt;/exclusion&gt;&lt;br /&gt;    &lt;exclusion&gt;&lt;br /&gt;     &lt;groupid&gt;javax.faces&lt;/groupid&gt;&lt;br /&gt;     &lt;artifactid&gt;jsf-impl&lt;/artifactid&gt;&lt;br /&gt;    &lt;/exclusion&gt;&lt;br /&gt;   &lt;/exclusions&gt;&lt;br /&gt;  &lt;/dependency&gt;&lt;br /&gt;  &lt;dependency&gt;&lt;br /&gt;   &lt;artifactid&gt;spring&lt;/artifactid&gt;&lt;br /&gt;   &lt;groupid&gt;org.springframework&lt;/groupid&gt;&lt;br /&gt;   &lt;version&gt;2.5.6&lt;/version&gt;&lt;br /&gt;  &lt;/dependency&gt;&lt;br /&gt;&lt;br /&gt;  &lt;dependency&gt;&lt;br /&gt;   &lt;artifactid&gt;portlet-api&lt;/artifactid&gt;&lt;br /&gt;   &lt;groupid&gt;javax.portlet&lt;/groupid&gt;&lt;br /&gt;   &lt;version&gt;2.0&lt;/version&gt;&lt;br /&gt;  &lt;/dependency&gt;   &lt;br /&gt;  &lt;dependency&gt;&lt;br /&gt;   &lt;groupid&gt;commons-beanutils&lt;/groupid&gt;&lt;br /&gt;   &lt;artifactid&gt;commons-beanutils&lt;/artifactid&gt;&lt;br /&gt;   &lt;version&gt;1.8.0&lt;/version&gt;&lt;br /&gt;  &lt;/dependency&gt;&lt;br /&gt;  &lt;dependency&gt;&lt;br /&gt;   &lt;groupid&gt;commons-collections&lt;/groupid&gt;&lt;br /&gt;   &lt;artifactid&gt;commons-collections&lt;/artifactid&gt;&lt;br /&gt;   &lt;version&gt;3.2&lt;/version&gt;&lt;br /&gt;  &lt;/dependency&gt;&lt;br /&gt;  &lt;dependency&gt;&lt;br /&gt;   &lt;groupid&gt;commons-digester&lt;/groupid&gt;&lt;br /&gt;   &lt;artifactid&gt;commons-digester&lt;/artifactid&gt;&lt;br /&gt;   &lt;version&gt;1.8&lt;/version&gt;&lt;br /&gt;  &lt;/dependency&gt;&lt;br /&gt;  &lt;dependency&gt;&lt;br /&gt;   &lt;groupid&gt;commons-fileupload&lt;/groupid&gt;&lt;br /&gt;   &lt;artifactid&gt;commons-fileupload&lt;/artifactid&gt;&lt;br /&gt;   &lt;version&gt;1.2&lt;/version&gt;&lt;br /&gt;  &lt;/dependency&gt;&lt;br /&gt;  &lt;dependency&gt;&lt;br /&gt;   &lt;groupid&gt;commons-logging&lt;/groupid&gt;&lt;br /&gt;   &lt;artifactid&gt;commons-logging&lt;/artifactid&gt;&lt;br /&gt;   &lt;version&gt;1.1.1&lt;/version&gt;&lt;br /&gt;   &lt;exclusions&gt;&lt;br /&gt;    &lt;exclusion&gt;&lt;br /&gt;     &lt;groupid&gt;logkit&lt;/groupid&gt;&lt;br /&gt;     &lt;artifactid&gt;logkit&lt;/artifactid&gt;&lt;br /&gt;    &lt;/exclusion&gt;&lt;br /&gt;    &lt;exclusion&gt;&lt;br /&gt;     &lt;groupid&gt;avalon-framework&lt;/groupid&gt;&lt;br /&gt;     &lt;artifactid&gt;avalon-framework&lt;/artifactid&gt;&lt;br /&gt;    &lt;/exclusion&gt;&lt;br /&gt;   &lt;/exclusions&gt;&lt;br /&gt;  &lt;/dependency&gt;&lt;br /&gt;  &lt;dependency&gt;&lt;br /&gt;   &lt;groupid&gt;commons-logging&lt;/groupid&gt;&lt;br /&gt;   &lt;artifactid&gt;commons-logging-api&lt;/artifactid&gt;&lt;br /&gt;   &lt;version&gt;1.1&lt;/version&gt;&lt;br /&gt;  &lt;/dependency&gt;&lt;br /&gt;  &lt;dependency&gt;&lt;br /&gt;   &lt;groupid&gt;commons-httpclient&lt;/groupid&gt;&lt;br /&gt;   &lt;artifactid&gt;commons-httpclient&lt;/artifactid&gt;&lt;br /&gt;   &lt;version&gt;3.0.1&lt;/version&gt;&lt;br /&gt;  &lt;/dependency&gt; &lt;br /&gt;  &lt;dependency&gt;&lt;br /&gt;   &lt;groupid&gt;javax.el&lt;/groupid&gt;&lt;br /&gt;   &lt;artifactid&gt;el-api&lt;/artifactid&gt;&lt;br /&gt;   &lt;version&gt;1.2&lt;/version&gt;&lt;br /&gt;  &lt;/dependency&gt;&lt;br /&gt;  &lt;dependency&gt;&lt;br /&gt;   &lt;groupid&gt;javax.el&lt;/groupid&gt;&lt;br /&gt;   &lt;artifactid&gt;el-ri&lt;/artifactid&gt;&lt;br /&gt;   &lt;version&gt;1.2&lt;/version&gt;&lt;br /&gt;  &lt;/dependency&gt;&lt;br /&gt;  &lt;dependency&gt;&lt;br /&gt;   &lt;groupid&gt;sun-jaxb&lt;/groupid&gt;&lt;br /&gt;   &lt;artifactid&gt;jaxb-api&lt;/artifactid&gt;&lt;br /&gt;   &lt;version&gt;2.1.9&lt;/version&gt;&lt;br /&gt;  &lt;/dependency&gt;&lt;br /&gt;  &lt;dependency&gt;&lt;br /&gt;   &lt;groupid&gt;sun-jaxb&lt;/groupid&gt;&lt;br /&gt;   &lt;artifactid&gt;jaxb-impl&lt;/artifactid&gt;&lt;br /&gt;   &lt;version&gt;2.1.9&lt;/version&gt;&lt;br /&gt;  &lt;/dependency&gt;  &lt;br /&gt;  &lt;dependency&gt;&lt;br /&gt;   &lt;groupid&gt;apache-xerces&lt;/groupid&gt;&lt;br /&gt;   &lt;artifactid&gt;xercesImpl&lt;/artifactid&gt;&lt;br /&gt;   &lt;version&gt;2.9.1&lt;/version&gt;&lt;br /&gt;  &lt;/dependency&gt;&lt;br /&gt;  &lt;dependency&gt;&lt;br /&gt;   &lt;artifactid&gt;cglib&lt;/artifactid&gt;&lt;br /&gt;   &lt;groupid&gt;cglib&lt;/groupid&gt;&lt;br /&gt;   &lt;version&gt;2.1_3&lt;/version&gt;&lt;br /&gt;   &lt;exclusions&gt;&lt;br /&gt;    &lt;exclusion&gt;&lt;br /&gt;     &lt;groupid&gt;asm&lt;/groupid&gt;&lt;br /&gt;     &lt;artifactid&gt;asm&lt;/artifactid&gt;&lt;br /&gt;    &lt;/exclusion&gt;&lt;br /&gt;   &lt;/exclusions&gt;&lt;br /&gt;  &lt;/dependency&gt;&lt;br /&gt;  &lt;dependency&gt;&lt;br /&gt;   &lt;groupid&gt;asm&lt;/groupid&gt;&lt;br /&gt;   &lt;artifactid&gt;asm&lt;/artifactid&gt;&lt;br /&gt;   &lt;version&gt;1.5.3&lt;/version&gt;&lt;br /&gt;  &lt;/dependency&gt;   &lt;br /&gt; &lt;/dependencies&gt;&lt;br /&gt;&lt;/dependencymanagement&gt;&lt;br /&gt;   &lt;!-- Compiling the dependencies. --&gt;&lt;br /&gt;&lt;dependencies&gt;&lt;br /&gt; &lt;dependency&gt;&lt;br /&gt;  &lt;groupid&gt;commons-beanutils&lt;/groupid&gt;&lt;br /&gt;  &lt;artifactid&gt;commons-beanutils&lt;/artifactid&gt;&lt;br /&gt; &lt;/dependency&gt;&lt;br /&gt; &lt;dependency&gt;&lt;br /&gt;  &lt;groupid&gt;commons-collections&lt;/groupid&gt;&lt;br /&gt;  &lt;artifactid&gt;commons-collections&lt;/artifactid&gt;&lt;br /&gt; &lt;/dependency&gt;&lt;br /&gt; &lt;dependency&gt;&lt;br /&gt;  &lt;groupid&gt;commons-digester&lt;/groupid&gt;&lt;br /&gt;  &lt;artifactid&gt;commons-digester&lt;/artifactid&gt;&lt;br /&gt; &lt;/dependency&gt;&lt;br /&gt; &lt;dependency&gt;&lt;br /&gt;  &lt;groupid&gt;commons-logging&lt;/groupid&gt;&lt;br /&gt;  &lt;artifactid&gt;commons-logging&lt;/artifactid&gt;&lt;br /&gt;  &lt;scope&gt;provided&lt;/scope&gt;&lt;br /&gt; &lt;/dependency&gt;&lt;br /&gt; &lt;dependency&gt;&lt;br /&gt;  &lt;groupid&gt;javax.faces&lt;/groupid&gt;&lt;br /&gt;  &lt;artifactid&gt;jsf-api&lt;/artifactid&gt;&lt;br /&gt; &lt;/dependency&gt;&lt;br /&gt; &lt;dependency&gt;&lt;br /&gt;  &lt;groupid&gt;javax.faces&lt;/groupid&gt;&lt;br /&gt;  &lt;artifactid&gt;jsf-impl&lt;/artifactid&gt;&lt;br /&gt; &lt;/dependency&gt; &lt;br /&gt; &lt;dependency&gt;&lt;br /&gt;  &lt;groupid&gt;javax.el&lt;/groupid&gt;&lt;br /&gt;  &lt;artifactid&gt;el-ri&lt;/artifactid&gt;&lt;br /&gt; &lt;/dependency&gt;&lt;br /&gt; &lt;dependency&gt;&lt;br /&gt;  &lt;groupid&gt;javax.el&lt;/groupid&gt;&lt;br /&gt;  &lt;artifactid&gt;el-api&lt;/artifactid&gt;&lt;br /&gt; &lt;/dependency&gt; &lt;br /&gt; &lt;dependency&gt;&lt;br /&gt;  &lt;groupid&gt;javax.portlet&lt;/groupid&gt;&lt;br /&gt;  &lt;artifactid&gt;portlet-api&lt;/artifactid&gt;&lt;br /&gt;  &lt;scope&gt;provided&lt;/scope&gt;&lt;br /&gt; &lt;/dependency&gt;&lt;br /&gt; &lt;dependency&gt;&lt;br /&gt;  &lt;groupid&gt;sun-jaxb&lt;/groupid&gt;&lt;br /&gt;  &lt;artifactid&gt;jaxb-api&lt;/artifactid&gt;&lt;br /&gt; &lt;/dependency&gt;&lt;br /&gt; &lt;dependency&gt;&lt;br /&gt;  &lt;groupid&gt;sun-jaxb&lt;/groupid&gt;&lt;br /&gt;  &lt;artifactid&gt;jaxb-impl&lt;/artifactid&gt;&lt;br /&gt; &lt;/dependency&gt;&lt;br /&gt; &lt;dependency&gt;&lt;br /&gt;  &lt;artifactid&gt;cglib&lt;/artifactid&gt;&lt;br /&gt;  &lt;groupid&gt;cglib&lt;/groupid&gt;&lt;br /&gt; &lt;/dependency&gt;&lt;br /&gt; &lt;dependency&gt;&lt;br /&gt;  &lt;groupid&gt;asm&lt;/groupid&gt;&lt;br /&gt;  &lt;artifactid&gt;asm&lt;/artifactid&gt;&lt;br /&gt; &lt;/dependency&gt;&lt;br /&gt; &lt;dependency&gt;&lt;br /&gt;  &lt;groupid&gt;apache-xerces&lt;/groupid&gt;&lt;br /&gt;  &lt;artifactid&gt;xercesImpl&lt;/artifactid&gt;&lt;br /&gt; &lt;/dependency&gt;&lt;br /&gt; &lt;dependency&gt;&lt;br /&gt;  &lt;artifactid&gt;commons-httpclient&lt;/artifactid&gt;&lt;br /&gt;  &lt;groupid&gt;commons-httpclient&lt;/groupid&gt;&lt;br /&gt; &lt;/dependency&gt; &lt;br /&gt; &lt;!-- JBoss Portlet Bridge --&gt;&lt;br /&gt; &lt;dependency&gt;&lt;br /&gt;  &lt;groupid&gt;org.jboss.portletbridge&lt;/groupid&gt;&lt;br /&gt;  &lt;artifactid&gt;portletbridge-api&lt;/artifactid&gt;&lt;br /&gt; &lt;/dependency&gt;&lt;br /&gt; &lt;dependency&gt;&lt;br /&gt;  &lt;groupid&gt;org.jboss.portletbridge&lt;/groupid&gt;&lt;br /&gt;  &lt;artifactid&gt;portletbridge-impl&lt;/artifactid&gt;&lt;br /&gt; &lt;/dependency&gt;&lt;br /&gt; &lt;!-- RichFaces Facelets dependencies --&gt;&lt;br /&gt; &lt;dependency&gt;&lt;br /&gt;  &lt;groupid&gt;com.sun.facelets&lt;/groupid&gt;&lt;br /&gt;  &lt;artifactid&gt;jsf-facelets&lt;/artifactid&gt;&lt;br /&gt; &lt;/dependency&gt;&lt;br /&gt; &lt;dependency&gt;&lt;br /&gt;  &lt;groupid&gt;org.richfaces.ui&lt;/groupid&gt;&lt;br /&gt;  &lt;artifactid&gt;richfaces-ui&lt;/artifactid&gt;&lt;br /&gt; &lt;/dependency&gt;&lt;br /&gt;&lt;/dependencies&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;properties&gt;&lt;br /&gt; &lt;jsf.version&gt;1.2_12&lt;/jsf.version&gt;&lt;br /&gt; &lt;richfaces.version&gt;3.3.1.GA&lt;/richfaces.version&gt;&lt;br /&gt; &lt;portletbridge.version&gt;1.0.0.CR2&lt;/portletbridge.version&gt;&lt;br /&gt;&lt;/properties&gt;&lt;br /&gt;&lt;/project&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;NOTE: Some of the dependencies might be included in the Dependency Management section, but not in the dependency. This is due to copy paste reasons. Just ignore, so will Maven do as well.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9079494833044939711-4981444194141050803?l=random-thoughts-vortex.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://random-thoughts-vortex.blogspot.com/feeds/4981444194141050803/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://random-thoughts-vortex.blogspot.com/2009/08/maven-dependency-management-for-running.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9079494833044939711/posts/default/4981444194141050803'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9079494833044939711/posts/default/4981444194141050803'/><link rel='alternate' type='text/html' href='http://random-thoughts-vortex.blogspot.com/2009/08/maven-dependency-management-for-running.html' title='Maven Dependency Management for running RichFaces project on WebSphere 6.1'/><author><name>agema-makedonin</name><uri>http://www.blogger.com/profile/17141246309473354181</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_ofsKG4Jlu5I/SyoTaP7ijYI/AAAAAAAAA_c/ddPpEY159H4/S220/phpMJlNct_c3AM.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9079494833044939711.post-9201900412065708278</id><published>2009-07-29T05:47:00.000-07:00</published><updated>2009-07-29T07:57:38.655-07:00</updated><title type='text'>Maven Profile- Dynamic compilation for different target platforms</title><content type='html'>Have you ever had the case where you have one project that has to be deployed to different servers? You certainly know that different servers include different JAR files. You certainly know that the configuration files are not necessary the same. This can give you a lot of headache, it can also make you maintain two different project just cause the configuration.&lt;br /&gt;&lt;br /&gt;Well I recently had similar problems. Had to maintain the same project that should be deployed to JBoss and WebSphere. To keep the long story short, Maven gave me the perfect opportunity to do this.&lt;br /&gt;&lt;br /&gt;Let us assume that your Maven project looks similar to this:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;+main-project&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;|&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;|--+ web-app-project&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;|    |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;|    |-+src/main/java&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;|    |-+src/main/webapp&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;|    |   |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;|    |   +WEB-INF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;|    |    |--&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;+web.xml&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;|    |   |--+faces-config.xml&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;|    |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;|    +pom.xml&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;+ pom.xml&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;As you may know&lt;/span&gt;&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;&lt;span&gt;the main-project pom.xml is where you keep your dependency management. In the dependency management you enter artifact id and group id of the JAR file you want to be inluded and it's version. Usually, you can define the scope of the JAR here. There are several of such scopes. The compile scope is default and means that your JAR will be included in your application. The other common scope is the provided scope. It tells maven, that this JAR should not be included in your final product, and the application will find it either on the server or it's runtime. This dependency management in your main pom.xml should look something like this:&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&lt;dependencymanagement&gt;&lt;br /&gt;   &lt;dependencies&gt;&lt;br /&gt;    &lt;dependency&gt;&lt;br /&gt;      &lt;groupid&gt;javax.faces&lt;/groupid&gt;&lt;br /&gt;      &lt;artifactid&gt;jsf-impl&lt;/artifactid&gt;&lt;br /&gt;      &lt;version&gt;${jsf.version}&lt;/version&gt;&lt;br /&gt;     &lt;/dependency&gt;&lt;br /&gt;&lt;!-- Other dependency's in your project --&gt;&lt;br /&gt;   &lt;/dependencies&gt;&lt;br /&gt;&lt;/dependencymanagement&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The dependency management tag will tell maven which JAR files and it's versions are needed in your project. But this won't make this Jars be yet included in your project. To indeed include them, you should put the same dependency's with out version between separate dependencies tag.&lt;br /&gt;&lt;br /&gt;This you can do either in the main-project pom.xml or in the web-app-project pom.xml. I would suggest the later one, which will make Maven put those Jars under the WEB-INF/lib folder.&lt;br /&gt;&lt;br /&gt;Your web-app-project pom.xml could than include those dependencies as follow:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&lt;dependencies&gt;&lt;br /&gt;   &lt;dependency&gt;&lt;br /&gt;     &lt;groupid&gt;javax.faces&lt;/groupid&gt;&lt;br /&gt;      &lt;artifactid&gt;jsf-impl&lt;/artifactid&gt;&lt;br /&gt;    &lt;/dependency&gt;&lt;br /&gt;&lt;!-- Other dependency's in your project --&gt;&lt;br /&gt;&lt;/dependencies&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Notice that the dependency management tag is missing in this part of the configuration.&lt;br /&gt;&lt;br /&gt;I must admit that this is little error prone code, but if you keep it nice and clear, it will allow you to manage your dependencies very easy, and if you store your project in a SVN Repository, you will have no need to store the Jar files into the repository.&lt;br /&gt;&lt;br /&gt;Thus far, we have gone through basic maven configuration. You certainly are interested how all those Jar files can be managed for different servers.&lt;br /&gt;&lt;br /&gt;The answer is maven profiles. Every maven profile needs unique profile id. Let's start with the maven command line that will call certain profile.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(204, 102, 0);"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style="color: rgb(204, 102, 0);"&gt;&lt;span style="font-weight: bold;"&gt;mvn -Pprofileid clean install&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;The accent is set to the parameter -P followed with the profile id. It is important to understand that there is no space between the parameter and the id. If you execute this maven command at this point having the above configuration, the profile will be ignored and the project will be compiled normally.&lt;br /&gt;&lt;br /&gt;To add a profile for certain project, you can do this in your web-app-project pom.xml as follows:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&lt;profiles&gt;&lt;br /&gt;  &lt;profile&gt;&lt;br /&gt;    &lt;id&gt;websphere&lt;/id&gt;&lt;br /&gt;  &lt;/profile&gt;&lt;br /&gt;&lt;/profiles&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This defines the new profile with id websphere. It can be called as follows:&lt;br /&gt;&lt;span style="color: rgb(204, 102, 0);"&gt;&lt;/span&gt;&lt;blockquote style="font-weight: bold;"&gt;&lt;span style="color: rgb(204, 102, 0);"&gt;mvn -Pwebsphere clean install&lt;/span&gt;&lt;/blockquote&gt;As you correctly assumed this is a empty profile, thus won't do any difference. But before we go on and add our WebSphere dependencies, remove the previous dependencies we added above.  Now adding the WebSphere dependencies is only a trivial task, and is done as follow:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&lt;profiles&gt;&lt;br /&gt;   &lt;profile&gt;&lt;br /&gt;     &lt;id&gt;websphere&lt;/id&gt;&lt;br /&gt;     &lt;dependencies&gt;&lt;br /&gt;       &lt;dependency&gt;&lt;br /&gt;          &lt;groupid&gt;javax.faces&lt;/groupid&gt;&lt;br /&gt;          &lt;artifactid&gt;jsf-impl&lt;/artifactid&gt;&lt;br /&gt;       &lt;/dependency&gt;&lt;br /&gt;&lt;!-- Other dependency's in your WebSphere project --&gt;&lt;br /&gt;     &lt;/dependencies&gt;&lt;br /&gt;   &lt;/profile&gt;&lt;br /&gt;&lt;/profiles&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;As you can see, no mysterious thing happened here. Actually, you can use about any of the normal maven tags inside profile.&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&lt;project&gt;&lt;br /&gt;&lt;profiles&gt;&lt;br /&gt;&lt;profile&gt;&lt;br /&gt;&lt;build&gt;&lt;br /&gt;&lt;defaultgoal&gt;...&lt;/defaultgoal&gt;&lt;br /&gt;&lt;finalname&gt;...&lt;/finalname&gt;&lt;br /&gt;&lt;resources&gt;...&lt;/resources&gt;&lt;br /&gt;&lt;testresources&gt;...&lt;/testresources&gt;&lt;br /&gt;&lt;plugins&gt;...&lt;/plugins&gt;&lt;br /&gt;&lt;/build&gt;&lt;br /&gt;&lt;reporting&gt;...&lt;/reporting&gt;&lt;br /&gt;&lt;modules&gt;...&lt;/modules&gt;&lt;br /&gt;&lt;dependencies&gt;...&lt;/dependencies&gt;&lt;br /&gt;&lt;dependencymanagement&gt;...&lt;/dependencymanagement&gt;&lt;br /&gt;&lt;distributionmanagement&gt;...&lt;/distributionmanagement&gt;&lt;br /&gt;&lt;repositories&gt;...&lt;/repositories&gt;&lt;br /&gt;&lt;pluginrepositories&gt;...&lt;/pluginrepositories&gt;&lt;br /&gt;&lt;properties&gt;...&lt;/properties&gt;&lt;br /&gt;&lt;/profile&gt;&lt;br /&gt;&lt;/profiles&gt;&lt;br /&gt;&lt;/project&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;You can see more &lt;a href="http://www.sonatype.com/books/maven-book/reference/profiles-sect-maven-profiles.html"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Now that we have managed the dependencies for WebSphere, we would also like to alter different configuration files at compile time. This files can be various XML files, such as web.xml or faces-config.xml.  Why is this necessary will be shown on simple example on the web.xml file configuring the RichFaces for WebSphere and JBoss.&lt;br /&gt;&lt;br /&gt;In &lt;a href="http://random-thoughts-vortex.blogspot.com/2009/07/porting-richfaces-portlets-in-websphere.html"&gt;WebSphere &lt;/a&gt;you configure the RichFaces mapping as follow:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&lt;filter-mapping&gt;&lt;br /&gt;   &lt;filter-name&gt;richfaces&lt;/filter-name&gt;&lt;br /&gt;     &lt;url-mapping&gt;/*&lt;/url-mapping&gt;&lt;br /&gt;     &lt;dispatcher&gt;REQUEST&lt;/dispatcher&gt;&lt;br /&gt;     &lt;dispatcher&gt;FORWARD&lt;/dispatcher&gt;&lt;br /&gt;     &lt;dispatcher&gt;INCLUDE&lt;/dispatcher&gt;&lt;br /&gt;     &lt;dispatcher&gt;ERROR&lt;/dispatcher&gt;&lt;br /&gt;&lt;/filter-mapping&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In JBoss you don't configure the RichFaces filter through URL mapping, but through the Faces Servlet name, like this:&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&lt;filter-mapping&gt;&lt;br /&gt;  &lt;filter-name&gt;richfaces&lt;/filter-name&gt;&lt;br /&gt;  &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;&lt;br /&gt;  &lt;dispatcher&gt;REQUEST&lt;/dispatcher&gt;&lt;br /&gt;  &lt;dispatcher&gt;FORWARD&lt;/dispatcher&gt;&lt;br /&gt;  &lt;dispatcher&gt;INCLUDE&lt;/dispatcher&gt;&lt;br /&gt;  &lt;dispatcher&gt;ERROR&lt;/dispatcher&gt;&lt;br /&gt;&lt;/filter-mapping&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;As you see, this is very conflicting. While the WebSphere configuration will also work for JBoss, still you will need additional configuration, to get RichFaces running on WebSphere as follow:&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&lt;filter-mapping&gt;&lt;br /&gt;  &lt;filter-name&gt;richfaces&lt;/filter-name&gt;&lt;br /&gt;  &lt;url-pattern&gt;/faces/rfRes/*&lt;/url-pattern&gt;&lt;br /&gt;  &lt;dispatcher&gt;REQUEST&lt;/dispatcher&gt;&lt;br /&gt;  &lt;dispatcher&gt;FORWARD&lt;/dispatcher&gt;&lt;br /&gt;  &lt;dispatcher&gt;INCLUDE&lt;/dispatcher&gt;&lt;br /&gt;  &lt;dispatcher&gt;ERROR&lt;/dispatcher&gt;&lt;br /&gt;&lt;/filter-mapping&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;So, the both mappings did not work for me on JBoss Portal, thus had problem to maintain the configuration of RichFaces for both servers in the same Project.&lt;br /&gt;Luckily, Maven gives the opportunity to filter resources of all kind. Here we need to filter the web resources, thus can be done in few steps:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;In your web-app-project add new directory named conf&lt;/li&gt;&lt;li&gt;In this directory you create new properties file named something like websphere.properties&lt;/li&gt;&lt;li&gt;Add new property such as &lt;span style="font-style: italic;"&gt;&lt;span style="font-weight: bold;"&gt;richfaces.servlet.name.mapping=&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;Add another property such as &lt;span style="font-style: italic;"&gt;&lt;span style="font-weight: bold;"&gt;richfaces.url.mapping=&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;pre name="code" class="xml"&gt;&lt;url-mapping&gt;/*&lt;/url-mapping&gt;&lt;/pre&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;Please notice that this properties are added in the websphere.properties file. To have JBoss profile filtering, you need another property file called for example jboss.properties. Inside this file, you have to define the same properties and assign them different values.&lt;br /&gt;Also notice that the url mapping is not needed for WebSphere RichFaces configuration, thus the property is assigned no value, which will result in empty line in the web.xml file.&lt;br /&gt;&lt;br /&gt;Now that we have this properties which define different patterns or configuration tags. As you assumed, this won't do anything. Now we will have to tell maven that he needs to take this property files and filter our web.xml. this is done as follow:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&lt;profiles&gt;&lt;br /&gt;  &lt;profile&gt;&lt;br /&gt;     &lt;id&gt;websphere&lt;/id&gt;&lt;br /&gt;     &lt;build&gt;&lt;br /&gt;        &lt;plugins&gt;&lt;br /&gt;          &lt;plugin&gt;&lt;br /&gt;             &lt;groupid&gt;org.apache.maven.plugins&lt;/groupid&gt;&lt;br /&gt;             &lt;artifactid&gt;maven-war-plugin&lt;/artifactid&gt;&lt;br /&gt;             &lt;configuration&gt;&lt;br /&gt;                &lt;webresources&gt;&lt;br /&gt;                    &lt;webresource&gt;&lt;br /&gt;                       &lt;directory&gt;&lt;br /&gt;                         ${basedir}/src/main/webapp/WEB-INF&lt;br /&gt;                       &lt;/directory&gt;&lt;br /&gt;                       &lt;targetpath&gt;WEB-INF&lt;/targetpath&gt;&lt;br /&gt;                       &lt;filtering&gt;true&lt;/filtering&gt;&lt;br /&gt;                     &lt;/webresource&gt;&lt;br /&gt;                  &lt;/webresources&gt;&lt;br /&gt;              &lt;/configuration&gt;&lt;br /&gt;           &lt;/plugin&gt;&lt;br /&gt;         &lt;/plugins&gt;&lt;br /&gt;         &lt;filters&gt;&lt;br /&gt;           &lt;filter&gt;${basedir}/src/conf/jboss-portal.properties&lt;/filter&gt;&lt;br /&gt;         &lt;/filters&gt;&lt;br /&gt;   &lt;/build&gt;&lt;br /&gt;   &lt;dependencies&gt;&lt;br /&gt;     &lt;dependency&gt;&lt;br /&gt;       &lt;groupid&gt;javax.faces&lt;/groupid&gt;&lt;br /&gt;       &lt;artifactid&gt;jsf-impl&lt;/artifactid&gt;&lt;br /&gt;     &lt;/dependency&gt;&lt;br /&gt; &lt;!-- Other dependency's in your WebSphere project --&gt;&lt;br /&gt;   &lt;/dependencies&gt;&lt;br /&gt;  &lt;/profile&gt;&lt;br /&gt;&lt;/profiles&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Here we add new maven plug in for this profile to the standard build. This plug in is the maven war plug in which enables filtering of the WEB-INF content of an web app. With the directory tag, we tell the plug in which directory should be filtered and set the filtering on true.&lt;br /&gt;&lt;br /&gt;In order to add the values assigned to the properties in the websphere.properties file in to the web.xml, the following changes are made in to the web.xml file:&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;   &lt;filter-mapping&gt;&lt;br /&gt;      &lt;filter-name&gt;richfaces&lt;/filter-name&gt;  &lt;br /&gt;      ${richfaces.servlet.name.mapping}       &lt;br /&gt;      ${richfaces.url.mapping}&lt;br /&gt;      &lt;dispatcher&gt;REQUEST&lt;/dispatcher&gt;&lt;br /&gt;      &lt;dispatcher&gt;FORWARD&lt;/dispatcher&gt;&lt;br /&gt;      &lt;dispatcher&gt;INCLUDE&lt;/dispatcher&gt;&lt;br /&gt;      &lt;dispatcher&gt;ERROR&lt;/dispatcher&gt;     &lt;br /&gt;  &lt;/filter-mapping&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;At compile time, the properties will be replaced with their values, so the out coming file will result in what you preconfigured in your websphere.properties file.&lt;br /&gt;&lt;br /&gt;So that is all about it. One needs time to get around this, but once one understands it, it is easy and clean.&lt;br /&gt;I hope this helps.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9079494833044939711-9201900412065708278?l=random-thoughts-vortex.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://random-thoughts-vortex.blogspot.com/feeds/9201900412065708278/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://random-thoughts-vortex.blogspot.com/2009/07/maven-profile-dynamic-compilation-for.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9079494833044939711/posts/default/9201900412065708278'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9079494833044939711/posts/default/9201900412065708278'/><link rel='alternate' type='text/html' href='http://random-thoughts-vortex.blogspot.com/2009/07/maven-profile-dynamic-compilation-for.html' title='Maven Profile- Dynamic compilation for different target platforms'/><author><name>agema-makedonin</name><uri>http://www.blogger.com/profile/17141246309473354181</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_ofsKG4Jlu5I/SyoTaP7ijYI/AAAAAAAAA_c/ddPpEY159H4/S220/phpMJlNct_c3AM.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9079494833044939711.post-8655814157429665687</id><published>2009-07-14T05:11:00.000-07:00</published><updated>2009-07-29T01:26:25.238-07:00</updated><title type='text'>Porting RichFaces Portlets in WebSphere 6.1 Portal</title><content type='html'>This was painful week of trying to get the rich faces to get work in WebSphere Portal 6.1 running on the WebSphereAS 6.1. I used fully functional RichFaces 3.3.0.GA enabled Portlets (JSR 286) which work fine in JBoss Portal 2.7.1 with JBoss Bridge 1.0.0.CR2, JSF 1.2_12.&lt;br /&gt;&lt;br /&gt;When deploying this Portlets on WPS, they got started, but running the Portlets always failed. The problem was closely related to RichFaces and it's filter and how the Mapping of the Resources URL was built.&lt;br /&gt;&lt;br /&gt;The following Exception was trhrown:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;Rendering View[/myportlet/view.xhtml]&lt;br /&gt;javax.faces.FacesException: Resources framework is not initialised, check web.xml for Filter configuration&lt;br /&gt;at org.ajax4jsf.resource.ResourceBuilderImpl.getWebXml(ResourceBuilderImpl.java:116)&lt;br /&gt;at org.ajax4jsf.resource.ResourceBuilderImpl.getUri(ResourceBuilderImpl.java:323)&lt;br /&gt;at org.jboss.portletbridge.richfaces.PortalResourceBuilder.getUri(PortalResourceBuilder.java:29)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;In short it tells that the Filter resources are not properly installed in the web.xml.&lt;br /&gt;&lt;br /&gt;I traced the org.ajax4jsf.resource.ResourceBuilderImpl.getWebXm method and on the place where this exception is thrown, it appears that the WebXml Object is null.&lt;br /&gt;&lt;br /&gt;I read &lt;a href="http://mail-archives.apache.org/mod_mbox/myfaces-users/200807.mbox/"&gt;here &lt;/a&gt;that the Ajax4Jsf Filter is not running in WebSphere.&lt;br /&gt;&lt;br /&gt;I started playing with the filter mapping in the web.xml. Depending on the Filter Mapping I used in the web.xml, I either get the Portlet to render the Standart JSF with out RichFaces components or I get the above message.&lt;br /&gt;&lt;br /&gt;When the Portlet renders the Standard JSF, I looked in to the source code of the page and I see the rich faces panels etc. printed out to XML/JS but the components are not loaded or rendered.&lt;br /&gt;I noticed that the Java Script links are possibly not loading, cause they look in my opinion not correct.&lt;br /&gt;For example, in the Source code I could see:&lt;br /&gt;&lt;br /&gt;which I tried to download this way:&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;http://  &lt;/span&gt;localhost&lt;span style="color: rgb(51, 102, 255);"&gt;:8080/&lt;/span&gt;wps&lt;span style="color: rgb(51, 102, 255);"&gt;/&lt;/span&gt;myappcontextpath&lt;span style="color: rgb(51, 102, 255);"&gt;/&lt;/span&gt;rfResorg&lt;span style="color: rgb(51, 102, 255);"&gt;/&lt;/span&gt;richfaces&lt;span style="color: rgb(51, 102, 255);"&gt;/&lt;/span&gt;renderkit&lt;span style="color: rgb(51, 102, 255);"&gt;/html/scripts/&lt;/span&gt;utils&lt;span style="color: rgb(51, 102, 255);"&gt;.&lt;/span&gt;js which always returned:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;Error 404: SRVE0190E: File not found: /myappcontextpath/rfResorg/richfaces/renderkit/html/scripts/utils.js&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;I initially thought that the part:&lt;span style="color: rgb(255, 0, 0);"&gt;/&lt;/span&gt;rfResorg&lt;span style="color: rgb(255, 0, 0);"&gt;/&lt;/span&gt; should be more like:&lt;span style="color: rgb(255, 0, 0);"&gt; /&lt;/span&gt;rfRes&lt;span style="color: rgb(255, 0, 0);"&gt;/org/ &lt;/span&gt;and the following bug in the &lt;a href="https://jira.jboss.org/jira/browse/RF-7189?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel"&gt;jboss jira&lt;/a&gt; gave me additional thoughts on the URLs.&lt;br /&gt;&lt;br /&gt;I still ain't clear if this was the root cause of the problem, but with additional configuration games, I actually got it to work.&lt;br /&gt;&lt;br /&gt;This is how the AJAX4JSF Filter Configuration in the web.xml now looks:&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&lt;filter&gt;&lt;br /&gt;&lt;filter-name&gt;richfaces&lt;/filter-name&gt;&lt;br /&gt;&lt;filter-class&gt;org.ajax4jsf.Filter&lt;/filter-class&gt;&lt;br /&gt;&lt;/filter&gt;&lt;br /&gt;&lt;filter-mapping&gt;&lt;br /&gt;&lt;filter-name&gt;richfaces&lt;/filter-name&gt;&lt;br /&gt;&lt;url-pattern&gt;/*&lt;/url-pattern&gt;&lt;br /&gt;&lt;dispatcher&gt;REQUEST&lt;/dispatcher&gt;&lt;br /&gt;&lt;dispatcher&gt;FORWARD&lt;/dispatcher&gt;&lt;br /&gt;&lt;dispatcher&gt;INCLUDE&lt;/dispatcher&gt;&lt;br /&gt;&lt;dispatcher&gt;ERROR&lt;/dispatcher&gt;&lt;br /&gt;&lt;/filter-mapping&gt;&lt;br /&gt;&lt;filter-mapping&gt;&lt;br /&gt;&lt;filter-name&gt;richfaces&lt;/filter-name&gt;&lt;br /&gt;&lt;url-pattern&gt;/faces/rfRes/*&lt;/url-pattern&gt;      &lt;br /&gt;&lt;dispatcher&gt;REQUEST&lt;/dispatcher&gt;&lt;br /&gt;&lt;dispatcher&gt;FORWARD&lt;/dispatcher&gt;&lt;br /&gt;&lt;dispatcher&gt;INCLUDE&lt;/dispatcher&gt;&lt;br /&gt;&lt;dispatcher&gt;ERROR&lt;/dispatcher&gt;&lt;br /&gt;&lt;/filter-mapping&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;I added one General mapping for every URL and one to get the Resources through the Faces Servlet. Don't ask me why this works, to me it looks weird enough.&lt;br /&gt;&lt;br /&gt;This is not the whole pie. Additionally to this, I had to add the following factory in the faces-config.xml:&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&lt;factory&gt;&lt;br /&gt;&lt;faces-context-factory&gt;&lt;br /&gt;org.jboss.portletbridge.context.FacesContextFactoryImpl&lt;br /&gt;&lt;/faces-context-factory&gt;&lt;br /&gt;&lt;/factory&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;So that was it all about. I don't know if this might work on another configuration or even WebSphere Portal, but for now it works on mine.&lt;br /&gt;&lt;br /&gt;One more important issue:  set the Classloading policy as application classes loaded first. This will make sure that your classes in your WEB-INF/lib/*  Directory will be loaded first.&lt;br /&gt;&lt;br /&gt;This way, you can run JSF 1.2_12 on your WPS 6.1&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0); font-weight: bold;"&gt;Update&lt;/span&gt;:&lt;br /&gt;&lt;br /&gt;It appears that this issue is caused due to a Class loading problems in WPS. According to some sources, WPS loads the Filters and Servlets with different class loaders. This results in an Exception when the Filter Mapping is configured as followed&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&lt;filter-mapping&gt;&lt;br /&gt; &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;&lt;br /&gt;&lt;/filter-mapping&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In this case, only the ULR based mapping as shown above will do, since the Servlet instance is not known to the Filter instance.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9079494833044939711-8655814157429665687?l=random-thoughts-vortex.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://random-thoughts-vortex.blogspot.com/feeds/8655814157429665687/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://random-thoughts-vortex.blogspot.com/2009/07/porting-richfaces-portlets-in-websphere.html#comment-form' title='18 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9079494833044939711/posts/default/8655814157429665687'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9079494833044939711/posts/default/8655814157429665687'/><link rel='alternate' type='text/html' href='http://random-thoughts-vortex.blogspot.com/2009/07/porting-richfaces-portlets-in-websphere.html' title='Porting RichFaces Portlets in WebSphere 6.1 Portal'/><author><name>agema-makedonin</name><uri>http://www.blogger.com/profile/17141246309473354181</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_ofsKG4Jlu5I/SyoTaP7ijYI/AAAAAAAAA_c/ddPpEY159H4/S220/phpMJlNct_c3AM.jpg'/></author><thr:total>18</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9079494833044939711.post-2112063786284348062</id><published>2009-05-29T06:40:00.001-07:00</published><updated>2009-07-07T02:52:46.397-07:00</updated><title type='text'>RichFaces tree - dynamic update of tree model</title><content type='html'>The previous &lt;a href="http://random-thoughts-vortex.blogspot.com/2009/05/richfaces-tree-dynamic-loading.html"&gt;RidhFaces simple tree example&lt;/a&gt; allows you to render tree data which are output at one render time. But what if your tree data model is so large, so that you can't render it all at once. Instead you have to update your tree model at run time on user request?&lt;br /&gt;&lt;br /&gt;Rich faces provides a listener called change expand listener. In case the user selects certain node in your tree, this listener will be called and here you can update your tree model. In the following section I will show how this is done. Let's first see how this listener is bound to a tree component:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&lt;rich:tree id="TreeId"&gt;&lt;br /&gt;&lt;rich:treenode id="treeNodeId" changeexpandlistener="#{myBackingBean.processExpansion}"&gt;&lt;br /&gt;&lt;/rich:treenode&gt;&lt;br /&gt;&lt;/rich:tree&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Please notice that I left all other tree property's intentionally. As you can see, this property will call the assigned method where you can handle your tree model. Let us look into the method closely and see how we can update our tree model.&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;&lt;br /&gt;import org.richfaces.event.NodeExpandedEvent;&lt;br /&gt;&lt;br /&gt;public class MyBackingBean{&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;* The tree expand expand listener method.&lt;br /&gt;*/&lt;br /&gt;public void processExpansion(NodeExpandedEvent nodeExpandedEvent){&lt;br /&gt;// get the source or the component who fired this event.&lt;br /&gt;Object source = nodeExpandedEvent.getSource();&lt;br /&gt;if (source instanceof HtmlTreeNode) {&lt;br /&gt;    // It should be a html tree node, if yes get&lt;br /&gt;    // the ui tree which contains this node.&lt;br /&gt;    UITree tree = ((HtmlTreeNode) source).getUITree();&lt;br /&gt;// avoid null pointer exceptions even though not needed. but safety first ;-)&lt;br /&gt;if (tree == null) {&lt;br /&gt; return;&lt;br /&gt;}&lt;br /&gt; // get the row key i.e. id of the given node.&lt;br /&gt;  Object rowKey = tree.getRowKey();&lt;br /&gt;     // get the model node of this node.&lt;br /&gt;     TreeNode selectedTreeModelNode =  tree.getModelTreeNode(rowKey);&lt;br /&gt;     if(null != selectedTreeModelNode){&lt;br /&gt;        // add the children nodes.&lt;br /&gt;        addChildrenNodes(selectedTreeModelNode);&lt;br /&gt;     }&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;/**&lt;br /&gt;* Method for adding children nodes to a given tree model node.&lt;br /&gt;*/&lt;br /&gt;public void addChildrenNodes(TreeNode node){&lt;br /&gt; //process your node somehow. For this example I add only one node.&lt;br /&gt; TreeNodeImpl newNode = new TreeNodeImpl();&lt;br /&gt; newNode.setData("My New Node");&lt;br /&gt; newNode.setParent(node);&lt;br /&gt; node.addChild("rowKey", newNode);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;So every time user clicks the icon for expanding nodes, this listener will be called and the tree model will be updated. When the response will be rendered, the updated tree model will be rendered out, including your newly added node(s).&lt;br /&gt;&lt;br /&gt;The same process can be done while the user selects particular node of the tree. When the user selects particular node, a RichFaces will look for queued Select node listeners to be called. Such listener can be registered is a Select Node Listener.&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&lt;rich:tree id="TreeId" nodeselectlistener="#{myBackingBean.selectNode}"&gt;&lt;br /&gt;&lt;rich:treenode id="treeNodeId" changeexpandlistener="#{myBackingBean.processExpansion}"&gt;&lt;br /&gt;&lt;/rich:treenode&gt;&lt;br /&gt;&lt;/rich:tree&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;To queue select node listener to the tree, you can use the nodeSelectListener property. Than you can create new public listener method in your backing bean as follow:&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;&lt;br /&gt;import org.richfaces.event.NodeSelectedEvent;&lt;br /&gt;&lt;br /&gt;public class MyBackingBean{&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;* The select node listener method.&lt;br /&gt;*/&lt;br /&gt;public void selectNode(NodeSelectedEvent event){&lt;br /&gt;   // get the component that fired this event.&lt;br /&gt;   UIComponent component = event.getComponent();&lt;br /&gt;   if (component instanceof HtmlTree) {&lt;br /&gt;     // if a rich faces html tree (it is sometimes also a ui tree)&lt;br /&gt;     //get the row key of selected node.&lt;br /&gt;     Object rowKey = ((HtmlTree) component).getRowKey();&lt;br /&gt;     //pull the model tree node out of ther.&lt;br /&gt;     TreeNode selectedTreeModelNode = ((HtmlTree) component).getModelTreeNode(rowKey);&lt;br /&gt;     if(null != selectedTreeModelNode){&lt;br /&gt;        // add the children to the model.&lt;br /&gt;        addChildrenNodes(selectedTreeModelNode);&lt;br /&gt;     }&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;You should notice that the same method for adding children to the model is called as in previous example for expanding the node. Now that we covered how we can update our tree model, we could decide that after selecting a node and updating it's model we would like to expand the node. To do this, there are few way's. The safest and preferable way would be through the tree state saving property. Let's look into it closer:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&lt;rich:tree id="TreeId" nodeselectlistener="#{myBackingBean.selectNode}" componentstate="#{myBackingBean.treeState}"&gt;&lt;br /&gt;&lt;rich:treenode id="treeNodeId" changeexpandlistener="#{myBackingBean.processExpansion}"&gt;&lt;br /&gt;&lt;/rich:treenode&gt;&lt;br /&gt;&lt;/rich:tree&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In the backing bean, you should create new property called &lt;span style="font-weight: bold;"&gt;tree state.&lt;/span&gt; This should look something like this:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;* Getters and Setters added.&lt;br /&gt;*/&lt;br /&gt;public class MyBackingBean{&lt;br /&gt;&lt;br /&gt;private org.richfaces.component.state.TreeState treeState;&lt;br /&gt;&lt;br /&gt;public void setTreeState(org.richfaces.component.state.TreeState treeState) {&lt;br /&gt;this.treeState = treeState;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public org.richfaces.component.state.TreeState getTreeState() {&lt;br /&gt;return treeState;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Now that we added the Getters and Setters for this property, we could add this line to our select node listener method:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;&lt;br /&gt;import org.richfaces.event.NodeSelectedEvent;&lt;br /&gt;&lt;br /&gt;public class MyBackingBean{&lt;br /&gt;&lt;br /&gt;public void selectNode(NodeSelectedEvent event) throws Exception {&lt;br /&gt;&lt;br /&gt;   // ... same as in the previous section&lt;br /&gt;       if(null != selectedTreeModelNode){&lt;br /&gt;        //....  as in previous section&lt;br /&gt;         // queue the node to be expanded.&lt;br /&gt;         getTreeState().expandNode((UITree) tree,&lt;br /&gt;                                  (TreeRowKey) rowKey);&lt;br /&gt;     }&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The tree state instance will be consulted at render time of the tree. It contains map's where the state of the nodes is saved. Expanded nodes have own map where the row key's are queued for expanded rendering. The method expand node of the tree state class queue's the row key of the given node to be rendered as expanded.&lt;br /&gt;&lt;br /&gt;As you see, RichFaces is very flexible and provides methods for dynamic extending of the tree structure, avoiding to render the whole content of the tree at the beginning.&lt;br /&gt;&lt;br /&gt;Pity that they don't have good tutorials on their components.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9079494833044939711-2112063786284348062?l=random-thoughts-vortex.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://random-thoughts-vortex.blogspot.com/feeds/2112063786284348062/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://random-thoughts-vortex.blogspot.com/2009/05/richfaces-tree-dynamic-update-of-tree.html#comment-form' title='29 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9079494833044939711/posts/default/2112063786284348062'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9079494833044939711/posts/default/2112063786284348062'/><link rel='alternate' type='text/html' href='http://random-thoughts-vortex.blogspot.com/2009/05/richfaces-tree-dynamic-update-of-tree.html' title='RichFaces tree - dynamic update of tree model'/><author><name>agema-makedonin</name><uri>http://www.blogger.com/profile/17141246309473354181</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_ofsKG4Jlu5I/SyoTaP7ijYI/AAAAAAAAA_c/ddPpEY159H4/S220/phpMJlNct_c3AM.jpg'/></author><thr:total>29</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9079494833044939711.post-2067003095551845459</id><published>2009-05-28T05:00:00.000-07:00</published><updated>2009-05-28T06:35:28.887-07:00</updated><title type='text'>Richfaces Tree - simple case</title><content type='html'>&lt;span style="font-weight: bold;font-size:130%;" &gt;RichFaces Tree basics&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;RichFaces framework is providing a convenient approach for rendering trees in a browser. Information on the RichFaces tree component are found &lt;a href="http://livedemo.exadel.com/richfaces-demo/richfaces/tree.jsf;jsessionid=D6F77CDD8D18B7F53DB348B2B279249A?c=tree&amp;amp;tab=usage"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;There are few steps to be taken, when implementing a tree. These are:&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Creating your tree model class, which will hold the data that should be rendered by the tree.&lt;/li&gt;&lt;li&gt;You have to include the RichFaces tree tag in your form, weather JSP or XHTML.&lt;/li&gt;&lt;li&gt;Bind your tree model class with the tree tag using the JSF Expression language.&lt;/li&gt;&lt;/ol&gt;This tree steps are not that unfamiliar to any JSF developer. So let's look closely to them.&lt;br /&gt;&lt;br /&gt;Let us start with step one and discuss the model class. Good way to start coding your model class is to extend the &lt;span style="font-weight: bold;"&gt;org.richfaces.model.TreeNode&lt;/span&gt; Interface provided by RichFaces. This interface is implementing all important methods needed by the tree to render your data.  Another convinient way of providing your model for a tree is to use the RichFaces implementation  &lt;span style="font-weight: bold;"&gt;org.richfaces.model.TreeNodeImpl&lt;/span&gt; of the above mentioned interface.&lt;br /&gt;&lt;br /&gt;This is really the basic and most likely all that one need for a simple RichFaces tree.&lt;br /&gt;&lt;br /&gt;Let us examine how a tree can be implemented as a set of objects!?&lt;br /&gt;&lt;br /&gt;As a entry point we need a root node. Each root node have this attributes:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Root node has no parent.&lt;/li&gt;&lt;li&gt;Root node has one or many children.&lt;/li&gt;&lt;li&gt;Root node has a name and id.&lt;/li&gt;&lt;li&gt;Root node must not have a name.&lt;/li&gt;&lt;li&gt;Root node is also a folder.&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;So for construction our tree model , we need a root node. This can be done by instantiating the TreeNodeImpl class this way:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;public class TreeModel {&lt;br /&gt;private  org.richfaces.model.TreeNodeImpl root;&lt;br /&gt;&lt;br /&gt;// GETTER and SETTER&lt;br /&gt;&lt;br /&gt;//Constructor&lt;br /&gt;public TreeModel(){&lt;br /&gt;root = new org.richfaces.model.TreeNodeImpl();&lt;br /&gt; root.setParent(null);&lt;br /&gt; root.setData("Name of my Root Node");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;That ain't that hard, don't you think?&lt;br /&gt;Now that we have the root node, we can fill it with it's content or children nodes this way:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;public class TreeModel{&lt;br /&gt;&lt;br /&gt;public List treeContent;&lt;br /&gt;public void propagateTree(){&lt;br /&gt;&lt;br /&gt;for(Iterator it = treeContent.iterator(); it.hasNext();){&lt;br /&gt;  TreeNodeImpl node = new TreeNodeImpl();&lt;br /&gt;  NameIdPair pair = (NameIdPair) it.next();&lt;br /&gt;  node.setData(pair.getName());&lt;br /&gt;  node.setParent(root);&lt;br /&gt;  root.addChild(pair.getId(),node);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The class NameIdPair is only a data object contain two fields, name and id and it's getter and setter methods. The data in the list can be retrieved from a data base or any content management system.&lt;br /&gt;&lt;br /&gt;In this case, the root node will become will become one level nodes, dependent on how many entries were saved in the list.&lt;br /&gt;&lt;br /&gt;Now that we have our simple model, we need a tree that will render it.&lt;br /&gt;&lt;br /&gt;The following is convenient way how to use the tree tag:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&lt;rich:tree id="TreeId" &lt;br /&gt;rerender="selectedNode"&lt;br /&gt;ajaxsubmitselection="true" switchtype="ajax" &lt;br /&gt;treenodevar="TreeNodeVar"&lt;br /&gt;value="#{treeDataProvider.rootNode}" &lt;br /&gt;var="treeItem" ajaxkeys="#{null}" &lt;br /&gt;nodeface="node"&gt;&lt;br /&gt;&lt;br /&gt; &lt;rich:treenode id="nodeID" type="explorerNode" &lt;br /&gt;iconleaf="/icons/folder.png" icon="/icons/folder.png"&gt;&lt;br /&gt;  &lt;h:outputtext id="NodeId" value="#{treeItem}"&gt;&lt;br /&gt; &lt;/h:outputtext&gt;&lt;br /&gt;&lt;/rich:treenode&gt;&lt;br /&gt;&lt;/rich:tree&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;As you can see, the tag is very simple. The following points are worth mentioning:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;The root node we propagated and filled with other nodes is bound to the value property of the tree. The tree tag will dynamically load the root node and will render it and it's content.&lt;/li&gt;&lt;li&gt;RichFaces tree tag provides three operating modes of rendering: server, ajax, client. The most convenient way is the ajax mode, which will update the tree with ajax and let you select a node with the help of ajax. The client mode is only good for small trees as the one in our example. It will render the whole content with java script to your brower. If you choice is the server mode, you will have to find a way how to pos a request to the server, so that your selection or model update take place.&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9079494833044939711-2067003095551845459?l=random-thoughts-vortex.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://random-thoughts-vortex.blogspot.com/feeds/2067003095551845459/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://random-thoughts-vortex.blogspot.com/2009/05/richfaces-tree-dynamic-loading.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9079494833044939711/posts/default/2067003095551845459'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9079494833044939711/posts/default/2067003095551845459'/><link rel='alternate' type='text/html' href='http://random-thoughts-vortex.blogspot.com/2009/05/richfaces-tree-dynamic-loading.html' title='Richfaces Tree - simple case'/><author><name>agema-makedonin</name><uri>http://www.blogger.com/profile/17141246309473354181</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_ofsKG4Jlu5I/SyoTaP7ijYI/AAAAAAAAA_c/ddPpEY159H4/S220/phpMJlNct_c3AM.jpg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9079494833044939711.post-2507227589126068336</id><published>2009-04-09T04:56:00.000-07:00</published><updated>2009-04-09T05:23:53.806-07:00</updated><title type='text'>The facet thing</title><content type='html'>I have been looking for this in the Web my self, and could not find any real help. &lt;br /&gt;&lt;br /&gt;Creating JSF components in dynamic way can bring you some troubles. Many JSF components, when using XHTML or JSP require Facets to render part of it's own body or content. Examples are Header of RichFaces panel or the like.&lt;br /&gt;&lt;br /&gt;When creating dynamically a RichFaces panel for example, you will ran in to a problem if you want to create a header for your panel.  To ilustrate this, let's look in to the way you create a RichFaces Panel when using the RichFaces tags:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&lt;rich:panel&gt;&lt;br /&gt;   &lt;f:facet name="header"&gt;&lt;br /&gt;          &lt;h:outputtext value="My Header"&gt;&lt;br /&gt;   &lt;/h:outputtext&gt;&lt;br /&gt;&lt;/f:facet&gt;&lt;br /&gt;&lt;/rich:panel&gt;&lt;/pre&gt;&lt;br /&gt;As you may noticed, the problem one run on when creating this code in pure Java would be the Facet tag. If you look in to the JSF documentation, you will probably find the &lt;b&gt;javax.faces.webapp.FacetTag&lt;/b&gt; which you might think of using it. But when creating a new instance of this class, you will certainly wonder how to use it, since this tag has nothing to do with JSF directly.&lt;br /&gt;There is workaround for the following problem. Let us look in to the Java code on how to produce the same code from the above xml source:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt; HtmlPanel panel = (HtmlPanel)&lt;br /&gt;   FacesContext.getCurrentInstance().&lt;br /&gt;                    getApplication().&lt;br /&gt;                    createComponent(HtmlPanel.COMPONENT_TYPE);&lt;br /&gt; HtmlOutputText text= (HtmlOutputText )&lt;br /&gt;   FacesContext.getCurrentInstance().&lt;br /&gt;                    getApplication().&lt;br /&gt;                    createComponent(HtmlOutputText .COMPONENT_TYPE);&lt;br /&gt;  &lt;br /&gt; text.setValue("My Header");&lt;br /&gt;&lt;br /&gt; // now we will add the text to the panel's header&lt;br /&gt;&lt;br /&gt; panel.getFacets().put("header",text);&lt;br /&gt; &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;As you see, that's all there it is to it. Every container component (correct me if I am wrong) in JSF has a Map of it's Facets. According to the JSF specification, the Facet (Tag) can contain only one UIComponent. So if you want more component's in your header, such as Text and Image at a time, you should wrap this components with one Html Panel Group instance and add it to your Facet Map.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9079494833044939711-2507227589126068336?l=random-thoughts-vortex.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://random-thoughts-vortex.blogspot.com/feeds/2507227589126068336/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://random-thoughts-vortex.blogspot.com/2009/04/facet-thing.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9079494833044939711/posts/default/2507227589126068336'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9079494833044939711/posts/default/2507227589126068336'/><link rel='alternate' type='text/html' href='http://random-thoughts-vortex.blogspot.com/2009/04/facet-thing.html' title='The facet thing'/><author><name>agema-makedonin</name><uri>http://www.blogger.com/profile/17141246309473354181</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_ofsKG4Jlu5I/SyoTaP7ijYI/AAAAAAAAA_c/ddPpEY159H4/S220/phpMJlNct_c3AM.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9079494833044939711.post-1136629800207761638</id><published>2009-04-01T00:49:00.000-07:00</published><updated>2009-04-09T05:05:45.463-07:00</updated><title type='text'>Creating dynamic listener method binding</title><content type='html'>If you are JSF developer, you are most probably familiar with the following scenario:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&lt;!-- For action Method bind to the JSF navigation facility, or an Action Listener        that takes an object of ActionEvent as attribute. --&gt;&lt;br /&gt;&lt;h:commandbutton action="myBean.action" actionlistener="myBean.actionListener"&gt;&lt;br /&gt;&lt;/h:commandbutton&gt;&lt;br /&gt;&lt;br /&gt;&lt;!-- Or for value change listener which takes an object of ValueChangeEvent as attribute --&gt;&lt;br /&gt;&lt;h:inputtext valuechangelistener="myBean.valueChangeListener"&gt;&lt;br /&gt;&lt;/h:inputtext&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The my bean instance should be created by the MyBean class which should include the following three methods:&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;public class MyBean{&lt;br /&gt;&lt;br /&gt;public String action(){&lt;br /&gt;// do something and return a string for the JSF navigation facility&lt;br /&gt;&lt;br /&gt;return "navigateToPage2";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void actionListener(ActionEvent event){&lt;br /&gt;&lt;br /&gt;UIComponent component = event.getComponent();&lt;br /&gt;// do something with or with out the component.&lt;br /&gt;// the same view in JSF will be reloaded after&lt;br /&gt;// this method returns.&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void valueChangeListener(ValueChangeEvent event){&lt;br /&gt;  UIComponent component = event.getComponent();&lt;br /&gt;// do something with or with out the component.&lt;br /&gt;// the same view in JSF will be reloaded after&lt;br /&gt;// this method returns.&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Sometimes, there are cases, where you have to do the binding for your self instead letting JSF bind your components with your listener methods via XML.&lt;br /&gt;&lt;br /&gt;It these case, you should do, what JSF will do for you. From the JSF Context, you can get a handle to the Expression Language Factory or short referred as EL.&lt;br /&gt;&lt;br /&gt;The expression language works similarly as the Reflection API of Sun Java SE. The main difference (at least for me) is that you can use the EL expression to bind your components to certain bean instances and methods.&lt;br /&gt;&lt;br /&gt;To get a grip of the EL handle, you can use the following approach:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;FacesContext ctx = FacesContext.getCurrentInstance();&lt;br /&gt;Application app = ctx.getApplication();&lt;br /&gt;ExpressionFactory el = app.getExpressionFactory();&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Instead writing this code, you can use the inline call of the EL expression as follows:&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;ExpressionFactory el = FacesContext.getCurrentInstance().&lt;br /&gt;                     getApplication().&lt;br /&gt;                     getExpressionFactory();&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In end effect, it is all the same for Java. It only saves you few lines of code.&lt;br /&gt;&lt;br /&gt;Now that we have the grip of the handle for the EL, we can use it to create dynamic binding of component's and bean methods.&lt;br /&gt;&lt;br /&gt;I will reproduce the same code from above with the command button and the text input. One should keep in mind that one can do this basically with every single JSF component.&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;public HtmlCommandButton createMyButton(){&lt;br /&gt;HtmlCommandButton button = FacesContext.getCurrentInstance().getApplication().&lt;br /&gt;createComponent(HtmlCommandButton.COMPONENT_TYPE );&lt;br /&gt;&lt;br /&gt;//create the EL binding for the action method with return type String&lt;br /&gt;MethodExpression action= FacesContext.getCurrentInstance().&lt;br /&gt;                           getApplication().getExpressionFactory().&lt;br /&gt;createMethodExpression(FacesContext.getCurrentInstance().getELContext(),&lt;br /&gt;#{myBean.action}, String.class, new Class[]{});&lt;br /&gt;&lt;br /&gt;//create the EL binding for the action listener method with return type void&lt;br /&gt;// and argument of ActionEvent type&lt;br /&gt;MethodExpression actionListener= FacesContext.getCurrentInstance().&lt;br /&gt;                           getApplication().getExpressionFactory().&lt;br /&gt;createMethodExpression(FacesContext.getCurrentInstance().getELContext(),&lt;br /&gt;#{myBean.action}, null, new Class[]{ActionEvent.class});&lt;br /&gt;&lt;br /&gt;//bind them to the button component.&lt;br /&gt;button.setActionExpression(action);&lt;br /&gt;// add the listener to the action&lt;br /&gt;button.addActionListener(new MethodExpressionActionListener(actionListener));&lt;br /&gt;&lt;br /&gt;return button;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;What is important to notice, is that when creating the action method EL with return type String the createMethodExpression method of the EL factory takes four arguments:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;The faces context&lt;br /&gt;&lt;/li&gt;&lt;li&gt;The String which represents the EL expression which should be used for binding&lt;/li&gt;&lt;li&gt;The return type of String class&lt;/li&gt;&lt;li&gt;The argument's of the method, which in this case are none to be passed.&lt;/li&gt;&lt;/ol&gt;The same goes for the creation of the action listener EL expression, where as the return type is set to null and the only argument passed is of type ActionEvent class.&lt;br /&gt;&lt;br /&gt;The last thing to do is to save this method expressions expression in the map of the JSF component for later use. This goes only for the action method with return type of String. To add the EL expression for listener, you have to wrap the Method expression with the MethodExpressionActionListener class. In doing so, you add this expression to the component via UIComponent.addActionListener(ActionEvent); method.&lt;br /&gt;&lt;br /&gt;The next thing to do is to create the text input component with it's value change listener binding.&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;public HtmlInputText createMyInput(){&lt;br /&gt;HtmlInputText input = FacesContext.getCurrentInstance().getApplication().&lt;br /&gt;                       createComponent(HtmlInputText.COMPONENT_TYPE );&lt;br /&gt;// create the value change listener&lt;br /&gt;MethodExpression valueChange=&lt;br /&gt;FacesContext.getCurrentInstance().getApplication().getExpressionFactory().&lt;br /&gt;createMethodExpression(FacesContext.getCurrentInstance().getELContext(),&lt;br /&gt;#{myBean.valueChangeListener}, null, new Class[]{ValueChangeEvent.class});&lt;br /&gt;&lt;br /&gt;//add the listener to the component&lt;br /&gt;input.addValueChangeListener(new MethodExpressionValueChangeListener(valueChange));&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;As you can see, this procedure is the same as if you create action event. The only difference is the argument of the method,which is of type ValueChangeEvent class.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9079494833044939711-1136629800207761638?l=random-thoughts-vortex.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://random-thoughts-vortex.blogspot.com/feeds/1136629800207761638/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://random-thoughts-vortex.blogspot.com/2009/04/creating-dynamic-listener-method.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9079494833044939711/posts/default/1136629800207761638'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9079494833044939711/posts/default/1136629800207761638'/><link rel='alternate' type='text/html' href='http://random-thoughts-vortex.blogspot.com/2009/04/creating-dynamic-listener-method.html' title='Creating dynamic listener method binding'/><author><name>agema-makedonin</name><uri>http://www.blogger.com/profile/17141246309473354181</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_ofsKG4Jlu5I/SyoTaP7ijYI/AAAAAAAAA_c/ddPpEY159H4/S220/phpMJlNct_c3AM.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9079494833044939711.post-5788148245222997503</id><published>2009-03-24T06:00:00.000-07:00</published><updated>2009-03-24T06:32:34.342-07:00</updated><title type='text'>Create Spring beans dynamically</title><content type='html'>Spring XML declared beans can be wired building your business structure. The problem with this approach is that these beans are loaded on the start up, when the Spring Context is created, which does not leave much of playground to modify or change beans at run time. How ever Spring offers opportunity to load beans in the Spring context on run time when beans are needed, and populate them at need.&lt;br /&gt;For doing this, we need the Spring Application context. For this to accomplish, one can declare one dedicated Spring context bean, which will implement the &lt;span style="font-weight:bold;"&gt;ApplicationContextAware &lt;/span&gt; and &lt;span style="font-weight:bold;"&gt;BeanFactoryPostProcessor&lt;/span&gt; interfaces.  This should look something like this:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;  public class MyContextWrapper implements ApplicationContextAware,&lt;br /&gt;                                           BeanFactoryPostProcessor {&lt;br /&gt;&lt;br /&gt;   private ApplicationContext appContext;&lt;br /&gt;   private ConfigurableListableBeanFactory factory;&lt;br /&gt;&lt;br /&gt;   public void postProcessBeanFactory(ConfigurableListableBeanFactory factory)&lt;br /&gt;                                                        throws BeansException {&lt;br /&gt;         this.factory = factory;&lt;br /&gt;   }&lt;br /&gt;   public void setApplicationContext(ApplicationContext c)&lt;br /&gt;                                                throws BeansException {&lt;br /&gt;         this.appContext = c;   &lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   //setters and getters&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The &lt;span style="font-weight:bold;"&gt;postProcessBeanFactory&lt;/span&gt; will be executed after reading the configuration files of the spring context. Here one can do other configurations and bean loading, or save the factory for later use.&lt;br /&gt;The Spring application context can be used for later dynamic bean retrieval or other purposes.&lt;br /&gt;&lt;br /&gt;For this approach to work, one should let spring load this bean in to it's context by declaring the bean in the XML configuration file as follow:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;  &lt;bean id="appContext" class="my.package.MyContextWrapper" &gt;&lt;br /&gt;  &lt;/bean&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Now this bean can be loaded in any other bean of the application via referencing it:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;  &lt;bean id="myBeanFactory" class="my.package.MyBeanFactory"&gt;&lt;br /&gt;     &lt;property name="springContext" ref="appContext"&gt;&lt;br /&gt;     &lt;/property&gt;&lt;br /&gt;  &lt;/bean&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Now that we have the grip of the Spring context and it's factory, we can create beans dynamically. For this purpose, we can use the &lt;span style="font-weight:bold;"&gt;GenericBeanDefinition&lt;/span&gt; which allows to load bean definitions as follows:&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;      BeanDefinitionRegistry registry = ((BeanDefinitionRegistry )factory);&lt;br /&gt;       &lt;br /&gt;      GenericBeanDefinition beanDefinition = new GenericBeanDefinition();&lt;br /&gt;      beanDefinition.setBeanClass(MyBeanClass.class);&lt;br /&gt;      beanDefinition.setLazyInit(false);&lt;br /&gt;      beanDefinition.setAbstract(false);&lt;br /&gt;      beanDefinition.setAutowireCandidate(true);&lt;br /&gt;      beanDefinition.setScope("session");&lt;br /&gt;     &lt;br /&gt;      registry.registerBeanDefinition("dynamicBean",beanDefinition);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;As one can see, this bean is created in the session scope and will be stored in the session of the user. The property auto wire candidate tells spring if dependency's of the bean such as setter's or getter's or constructor argument's should be handled automatically by Spring. The property lay init tells Spring if this bean should be instantiated when needed.&lt;br /&gt;&lt;br /&gt;To get a handle of Spring bean, one can use the Spring application context as follows:&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;Object bean= &lt;br /&gt;    getApplicationContext().getBean("dynamicBean");&lt;br /&gt; if(bean instanceof MyBeanClass){&lt;br /&gt;    MyBeanClass myBean = (MyBeanClass) bean;&lt;br /&gt;&lt;br /&gt;   // do with the bean what ever you have to do.&lt;br /&gt; } &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;As you can see, the dynamic bean creation in Spring is no big deal.It is easy to use, an certainly handy in many situations.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9079494833044939711-5788148245222997503?l=random-thoughts-vortex.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://random-thoughts-vortex.blogspot.com/feeds/5788148245222997503/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://random-thoughts-vortex.blogspot.com/2009/03/create-dynamically-spring-beans.html#comment-form' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9079494833044939711/posts/default/5788148245222997503'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9079494833044939711/posts/default/5788148245222997503'/><link rel='alternate' type='text/html' href='http://random-thoughts-vortex.blogspot.com/2009/03/create-dynamically-spring-beans.html' title='Create Spring beans dynamically'/><author><name>agema-makedonin</name><uri>http://www.blogger.com/profile/17141246309473354181</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_ofsKG4Jlu5I/SyoTaP7ijYI/AAAAAAAAA_c/ddPpEY159H4/S220/phpMJlNct_c3AM.jpg'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9079494833044939711.post-8293255507911618357</id><published>2009-03-19T12:56:00.000-07:00</published><updated>2009-03-19T14:21:44.973-07:00</updated><title type='text'>JSR 286 IPC with JSF</title><content type='html'>In case you are portlets developer, you know what JSR 286 is.  It is the holy grail for the portlets which should enable the portlets to communicate with each others. At least you would think it is the holy grail, until you read the specs and look upon the Suns minimalistic examples.&lt;br /&gt;It seems to me, this spec is out for it's own sake, and forwards the developers in the ice age of pure html, which is unthinkable for someone who has got used to API's such as JSF or Struts. Vendors as JBoss or ICEFaces have yet to deliver a bridge which will support JSR 286 with an AJAX push.&lt;br /&gt;&lt;br /&gt;The sad news is that JSR 286 works only with out AJAX push, and you have to do some work around to get the grips of it in JSF Portal environment.&lt;br /&gt;&lt;br /&gt;The first thing to do is to define the event you want to publish. This is done in the &lt;span style="font-weight: bold;"&gt;portlet.xml&lt;/span&gt;. There are three declaration there:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;One Global declaration of your event&lt;/li&gt;&lt;li&gt;Supported publishing event for your pulbishing portlet&lt;/li&gt;&lt;li&gt;Supported processing event for our consumer portlet&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;The global event declaration looks as follow:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&lt;event-definition&gt;&lt;br /&gt;&lt;qname x="http:mycomp.com/myevent"&gt;x:EventName&lt;/qname&gt;&lt;br /&gt;    &lt;value-type&gt;java.lang.String&lt;/value-type&gt;&lt;br /&gt;&lt;/event-definition&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In the Publishing portlet, put the following:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&lt;supported-publishing-event&gt;&lt;br /&gt;&lt;qname x="http://www.mycomp.com/myevent"&gt;x:EventName&lt;/qname&gt;&lt;br /&gt;&lt;/supported-publishing-event&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;And atlast, in the consumer portlet:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&lt;supported-processing-event&gt;&lt;br /&gt;&lt;qname x="http://www.mycomp.com/myevent"&gt;x:EventName&lt;/qname&gt;&lt;br /&gt;&lt;/supported-processing-event&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Now that you have configured your event that it is only a simple String, you should set it. This can be done in two way's:&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Either extend javax.portlet.faces.GenericFacesPortlet and override the&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;public void processAction(ActionRequest request, ActionResponse);&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;Or set the event in one of your Faces action methods.&lt;/li&gt;&lt;/ol&gt;If you prefer the first way, than you have to think that your to pass your full class name in the portlet.xml for portlet instantiation which would look like this:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&lt;portlet-class&gt;org.mycomp.IPCPublisher&lt;br /&gt;&lt;/portlet-class&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;If you prefer the JSF action method way, than your portlet.xml will look as usual:&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&lt;portlet-class&gt;javax.portlet.faces.GenericFacesPortlet&lt;br /&gt;  &lt;/portlet-class&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In you decide to override the method of the GenericFacesPortlet, than you will set the event similar to this:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;public void processAction(ActionRequest request, ActionResponse response)&lt;br /&gt;throws PortletException,IOException {&lt;br /&gt;&lt;br /&gt;   QName qname = new QName("http://www.mycomp.com/myevent" , "EventName");&lt;br /&gt;   response.setEvent(qname, "Hallo IPC Communication.");&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;If you decide you would like to publish this event from inside of your JSF action method, you can do that as follow:&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;  public void publishIPCEvent(ActionEvent event){&lt;br /&gt;   Object response = FacesContext.getCurrentInstance()&lt;br /&gt;            .getExternalContext()&lt;br /&gt;           .getResponse();&lt;br /&gt;&lt;br /&gt;   if(response instanceof ActionResponse){&lt;br /&gt;     ActionResponse aResponse = (ActionResponse)response;&lt;br /&gt;      QName qname = new QName("http://www.mycomp.com/myevent" , "EventName");&lt;br /&gt;        aResponse.setEvent(qname, "Hallo IPC Communication.");&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This method will be called as usual in JSF:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;   &lt;h:commandButton actionListener="myBean.publishIPCEvent"&gt;&lt;br /&gt;   &lt;/h:commandButton&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;What is left is to read out this event in the Consumer portlet. &lt;br /&gt;You should extend the Generic Faces Portlet and override the processEvent method. By doing that, don't forget to put the class definition in the portlet.xml as follow:&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;   &lt;portlet-class&gt;org.mycomp.IPCConsumer&lt;/portlet-class&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Override the method as follow:&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;public void processEvent(EventRequest request, EventResponse response) {&lt;br /&gt;   Event event = request.getEvent();&lt;br /&gt;   if(event.getName().equals("EventName")){&lt;br /&gt;     String ipc = event.getValue();&lt;br /&gt;     response.getPortletSession().setAttribute("ipc",ipc);&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;As you can see, I read out the event and compare it's name if it is my event I want to handle. Than I read it's value and set it in the portlet session as attribute.&lt;br /&gt;&lt;br /&gt;To get this value inside of JSF, you should do something like this:&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt; Object ipc = FacesContext.getCurrentInstance()&lt;br /&gt;  .getExternalContext().getSession(false)&lt;br /&gt;   .getAttribute("ipc);&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Some say that one can annotate the certain method, which should be responsible for processing the event. This should look something like this:&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;@ProcessEvent(qname="{http://www.mycomp.com/myevent}EventName")&lt;br /&gt; public void myEventProcessingMethod(EventRequest request, EventResponse response){&lt;br /&gt;    Event event = request.getEvent();&lt;br /&gt;   if(event.getName().equals("EventName")){&lt;br /&gt;     String ipc = event.getValue();&lt;br /&gt;     response.getPortletSession().setAttribute("ipc",ipc);&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;But this method annotation did not work for me inside of JSF. The same should work with &lt;span style="font-weight:bold;"&gt;java.util.HashMap&lt;/span&gt; instead of java.lang.String as well.&lt;br /&gt;&lt;br /&gt;Anyways, this IPC approach is not that straightforward as some would like it to be, but it fullfils it's purpose.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9079494833044939711-8293255507911618357?l=random-thoughts-vortex.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://random-thoughts-vortex.blogspot.com/feeds/8293255507911618357/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://random-thoughts-vortex.blogspot.com/2009/03/jsr-286-ipc-with-faces.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9079494833044939711/posts/default/8293255507911618357'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9079494833044939711/posts/default/8293255507911618357'/><link rel='alternate' type='text/html' href='http://random-thoughts-vortex.blogspot.com/2009/03/jsr-286-ipc-with-faces.html' title='JSR 286 IPC with JSF'/><author><name>agema-makedonin</name><uri>http://www.blogger.com/profile/17141246309473354181</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_ofsKG4Jlu5I/SyoTaP7ijYI/AAAAAAAAA_c/ddPpEY159H4/S220/phpMJlNct_c3AM.jpg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9079494833044939711.post-7294825536190999981</id><published>2009-03-17T13:31:00.000-07:00</published><updated>2009-03-17T14:03:22.975-07:00</updated><title type='text'>Create your JSF componenst with out JSP or Facelets Tags</title><content type='html'>It is personal reference. Some love XML Syntax, some try to save them from the XML Jungle. JSF is a framework that allows you to create components dynamically. The JSF Tags are only option.&lt;br /&gt;&lt;br /&gt;If you prefer to create your compnents without JSP or Facelets, and you don't want to envent the weel again, you can define your JSF Panel Grid in your JSP or Facelet as follow:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&lt;h:panelgrid id="dynamic" binding="#{myBean.panelGrid}"&gt;&lt;br /&gt;&lt;/h:panelgrid&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Define the bean in Spring config file as follow:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&lt;bean id="myBean" class="org.mypackage.MyBean" scope="session" method="init"&gt;&lt;br /&gt;&lt;/bean&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This bean holds a instance of the JSF HtmlPanelGrid which renders the JSF Panel Grid for you. The JSF components should be added to the Panel Grid with it's public method &lt;span style="font-weight: bold;"&gt;getChildren().add(Object o);&lt;/span&gt;. Here is the example:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;package org.mypackage;&lt;br /&gt;&lt;br /&gt;import javax.faces.application.Application;&lt;br /&gt;import javax.faces.component.html.HtmlOutputText;&lt;br /&gt;import javax.faces.component.html.HtmlPanelGrid;&lt;br /&gt;import javax.faces.context.FacesContext;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public class MyBean {&lt;br /&gt;&lt;br /&gt;private HtmlPanelGrid panelGrid;&lt;br /&gt;&lt;br /&gt;public MyBean(){&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;public void init(){&lt;br /&gt;&lt;br /&gt;Application application = FacesContext.getCurrentInstance().getApplication();&lt;br /&gt;setPanelGrid((HtmlPanelGrid) application.createComponent(HtmlPanelGrid.COMPONENT_TYPE));&lt;br /&gt;&lt;br /&gt;HtmlOutputText text = (HtmlOutputText) application.createComponent(HtmlOutputText.COMPONENT_TYPE);&lt;br /&gt;&lt;br /&gt;text.setValue("Hallo JSF with out Tags.");&lt;br /&gt;&lt;br /&gt;getPanelGrid().getChildren().add(text);&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;public void setPanelGrid(HtmlPanelGrid panelGrid) {&lt;br /&gt;this.panelGrid = panelGrid;&lt;br /&gt;}&lt;br /&gt;public HtmlPanelGrid getPanelGrid() {&lt;br /&gt;return panelGrid;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;In line 16 is the public method which will be ivoked by Spring after instantiation of the Bean.&lt;/li&gt;&lt;li&gt;Line 18 gets an instance of the current application.&lt;/li&gt;&lt;li&gt;On line 19 we create an instance of HtmlOutputText with the help of the method &lt;span style="font-weight: bold;"&gt;createComponent  &lt;/span&gt;which takes String as argument. Every JSF Component defines public static field COMPONENT_TYPE which returns the type of the component to be created.&lt;/li&gt;&lt;li&gt;On line 21 a instance of HtmlOutputText is created in the same way as the HtmlOutputText.&lt;/li&gt;&lt;li&gt;In line 23 we set the value of the output text.&lt;/li&gt;&lt;li&gt;In line 25 we set the output text component as child of the Panel Grid.&lt;/li&gt;&lt;/ol&gt;On the end of the day, when JSF try's to render the Panel Grid with the ID dynamic in the JSP or Facelets, the Property &lt;span style="font-weight: bold;"&gt;panelGrid &lt;/span&gt;of the backing bean will be called and our instance would be copied and rendered.&lt;br /&gt;&lt;br /&gt;In this way, we can create whole views or parts of it, as if we program in pure Java.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9079494833044939711-7294825536190999981?l=random-thoughts-vortex.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://random-thoughts-vortex.blogspot.com/feeds/7294825536190999981/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://random-thoughts-vortex.blogspot.com/2009/03/create-your-jsf-componenst-with-out-jsp.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9079494833044939711/posts/default/7294825536190999981'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9079494833044939711/posts/default/7294825536190999981'/><link rel='alternate' type='text/html' href='http://random-thoughts-vortex.blogspot.com/2009/03/create-your-jsf-componenst-with-out-jsp.html' title='Create your JSF componenst with out JSP or Facelets Tags'/><author><name>agema-makedonin</name><uri>http://www.blogger.com/profile/17141246309473354181</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_ofsKG4Jlu5I/SyoTaP7ijYI/AAAAAAAAA_c/ddPpEY159H4/S220/phpMJlNct_c3AM.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9079494833044939711.post-7818632222867541196</id><published>2009-03-16T12:40:00.000-07:00</published><updated>2009-03-17T13:31:14.146-07:00</updated><title type='text'>Basic RichFaces Project with Spring</title><content type='html'>To create basic RichFaces enabled project, you can run the following maven command provided by JBoss.&lt;br /&gt;&lt;pre name="code" class="xml"&gt;mvn archetype:generate&lt;br /&gt;-DarchetypeGroupId=org.jboss.portletbridge.archetypes&lt;br /&gt;-DarchetypeArtifactId=richfaces-basic&lt;br /&gt;-DarchetypeVersion=1.0.0.B6&lt;br /&gt;-DgroupId=org.whatever.project&lt;br /&gt;-DartifactId=myprojectname&lt;br /&gt;-DarchetypeRepository=http://repository.jboss.org/maven2/&lt;br /&gt;&lt;/pre&gt;Make sure that you use the proper version of the Portlet Bridge of Jboss. Read more &lt;a href="http://www.jboss.org/files/portletbridge/docs/1.0.0.B3/en/html_single/index.html#gettingstarted"&gt;here&lt;/a&gt;&lt;br /&gt;To enable Spring to manage your JSF Beans you should add this context arguments to your &lt;span style="font-weight: bold;"&gt;web.xml&lt;/span&gt;&lt;br /&gt;&lt;!-- Spring Framework Context loader responsible&lt;br /&gt; for Spring bean factory etc. --&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&lt;listener&gt;&lt;br /&gt;  &lt;listener-class&gt;&lt;br /&gt;    org.springframework.web.context.ContextLoaderListener&lt;br /&gt;  &lt;/listener-class&gt;&lt;br /&gt;&lt;/listener&gt;&lt;br /&gt;&lt;br /&gt;&lt;listener&gt;&lt;br /&gt;  &lt;listener-class&gt;&lt;br /&gt;   org.springframework.web.context.request.RequestContextListener&lt;br /&gt;  &lt;/listener-class&gt;&lt;br /&gt;&lt;/listener&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This are the listeners which enables Spring to load it's context and create the beans, and to process Request from JSF to Spring and preserve the session.&lt;br /&gt;&lt;br /&gt;Inside of &lt;span style="font-weight: bold;"&gt;faces-config.xml&lt;/span&gt; :    &lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&lt;application&gt;&lt;br /&gt;&lt;variable-resolver&gt;&lt;br /&gt;          org.springframework.web.jsf.DelegatingVariableResolver&lt;br /&gt;    &lt;/variable-resolver&gt;&lt;br /&gt;&lt;/application&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This delegates the JSF Variable resolver to look up for EL Expressions defined beans in Spring. In other words, it replaces the standard JSF EL resolver.&lt;br /&gt;&lt;br /&gt;Now you would be able to define your JSF Beans in Spring as follows:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;&lt;br /&gt;&lt;beans xmlns="http://www.springframework.org/schema/beans"&lt;br /&gt; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:osgi="http://www.springframework.org/schema/osgi"&lt;br /&gt; xsi:schemaLocation="http://www.springframework.org/schema/beans   &lt;br /&gt;       http://www.springframework.org/schema/beans/spring-beans.xsd"&gt;&lt;br /&gt;       &lt;br /&gt;       &lt;bean id="halloWorldBean" class="org.project.hello.world.DataProvider"&gt;&lt;br /&gt;       &lt;/bean&gt;&lt;br /&gt;   &lt;br /&gt;&lt;/beans&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This bean can be used with your JSF Tag as usual:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;   &lt;h:outputText value="#{halloWorldBean.yourProperty}"&gt;&lt;/h:outputText&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In deed simple.&lt;br /&gt;&lt;br /&gt;Here is the full web.xml:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;br /&gt;&lt;web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" &lt;br /&gt;                xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;&lt;br /&gt;&lt;br /&gt; &lt;context-param&gt;&lt;br /&gt;   &lt;param-name&gt;javax.faces.STATE_SAVING_METHOD&lt;/param-name&gt;&lt;br /&gt;   &lt;param-value&gt;server&lt;/param-value&gt;&lt;br /&gt;&lt;/context-param&gt; &lt;br /&gt;&lt;br /&gt;&lt;!-- &lt;br /&gt;  &lt;context-param&gt;&lt;br /&gt;      &lt;param-name&gt;org.ajax4jsf.VIEW_HANDLERS&lt;/param-name&gt;&lt;br /&gt;      &lt;param-value&gt;org.jboss.portletbridge.application.FaceletPortletViewHandler&lt;/param-value&gt;&lt;br /&gt;   &lt;/context-param&gt;&lt;br /&gt;    --&gt;&lt;br /&gt;   &lt;context-param&gt;&lt;br /&gt;      &lt;param-name&gt;javax.portlet.faces.renderPolicy&lt;/param-name&gt;&lt;br /&gt;      &lt;param-value&gt;ALWAYS_DELEGATE&lt;/param-value&gt;&lt;br /&gt;   &lt;/context-param&gt;&lt;br /&gt;&lt;br /&gt;   &lt;context-param&gt;&lt;br /&gt;      &lt;param-name&gt;org.ajax4jsf.RESOURCE_URI_PREFIX&lt;/param-name&gt;&lt;br /&gt;      &lt;param-value&gt;rfRes&lt;/param-value&gt;&lt;br /&gt;   &lt;/context-param&gt;&lt;br /&gt;&lt;br /&gt;   &lt;context-param&gt;&lt;br /&gt;      &lt;param-name&gt;org.richfaces.LoadStyleStrategy&lt;/param-name&gt;&lt;br /&gt;      &lt;param-value&gt;NONE&lt;/param-value&gt;&lt;br /&gt;   &lt;/context-param&gt;&lt;br /&gt;   &lt;br /&gt;      &lt;context-param&gt;&lt;br /&gt;      &lt;param-name&gt;org.richfaces.LoadScriptStrategy&lt;/param-name&gt;&lt;br /&gt;      &lt;param-value&gt;NONE&lt;/param-value&gt;&lt;br /&gt;   &lt;/context-param&gt;&lt;br /&gt;&lt;br /&gt;   &lt;context-param&gt;&lt;br /&gt;      &lt;param-name&gt;org.ajax4jsf.COMPRESS_SCRIPT&lt;/param-name&gt;&lt;br /&gt;      &lt;param-value&gt;true&lt;/param-value&gt;&lt;br /&gt;   &lt;/context-param&gt;&lt;br /&gt;&lt;!--&lt;br /&gt;&lt;context-param&gt;&lt;br /&gt;   &lt;param-name&gt;org.richfaces.SKIN&lt;/param-name&gt;&lt;br /&gt;   &lt;param-value&gt;blueSky&lt;/param-value&gt;&lt;br /&gt;&lt;/context-param&gt;&lt;br /&gt;--&gt;&lt;br /&gt;&lt;context-param&gt;&lt;br /&gt;      &lt;param-name&gt;org.richfaces.CONTROL_SKINNING&lt;/param-name&gt;&lt;br /&gt;      &lt;param-value&gt;enable&lt;/param-value&gt;&lt;br /&gt;&lt;/context-param&gt;&lt;br /&gt;&lt;br /&gt; &lt;context-param&gt;&lt;br /&gt;  &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;&lt;br /&gt;  &lt;param-value&gt;classpath:spring-context.xml&lt;/param-value&gt;&lt;br /&gt; &lt;/context-param&gt;&lt;br /&gt;&lt;br /&gt; &lt;filter&gt;    &lt;br /&gt;  &lt;display-name&gt;RichFaces Filter&lt;/display-name&gt; &lt;br /&gt;   &lt;filter-name&gt;richfaces&lt;/filter-name&gt;   &lt;br /&gt;   &lt;filter-class&gt;org.ajax4jsf.Filter&lt;/filter-class&gt; &lt;br /&gt;&lt;/filter&gt; &lt;br /&gt;&lt;br /&gt;&lt;filter-mapping&gt;       &lt;br /&gt;   &lt;filter-name&gt;richfaces&lt;/filter-name&gt; &lt;br /&gt;   &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;&lt;br /&gt;   &lt;dispatcher&gt;REQUEST&lt;/dispatcher&gt;&lt;br /&gt;   &lt;dispatcher&gt;FORWARD&lt;/dispatcher&gt;&lt;br /&gt;   &lt;dispatcher&gt;INCLUDE&lt;/dispatcher&gt;&lt;br /&gt;&lt;/filter-mapping&gt;&lt;br /&gt;  &lt;br /&gt;&lt;listener&gt;&lt;br /&gt;   &lt;listener-class&gt;com.sun.faces.config.ConfigureListener&lt;/listener-class&gt;&lt;br /&gt;&lt;/listener&gt;  &lt;br /&gt; &lt;!--&lt;br /&gt;        Spring Framework Context loader responsible for Spring bean factory&lt;br /&gt;        etc. --&gt;&lt;br /&gt; &lt;listener&gt;&lt;br /&gt;  &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;&lt;br /&gt; &lt;/listener&gt;&lt;br /&gt; &lt;!--    This listener is needed to delegate Request to Spring framework so&lt;br /&gt;        that Spring can add the request scope and session scope. --&gt;&lt;br /&gt; &lt;listener&gt;&lt;br /&gt;  &lt;listener-class&gt;org.springframework.web.context.request.RequestContextListener&lt;/listener-class&gt;&lt;br /&gt; &lt;/listener&gt;&lt;br /&gt; &lt;br /&gt;&lt;!-- Faces Servlet --&gt;&lt;br /&gt;&lt;br /&gt;&lt;servlet&gt;&lt;br /&gt;   &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;&lt;br /&gt;   &lt;servlet-class&gt;javax.faces.webapp.FacesServlet&lt;/servlet-class&gt;&lt;br /&gt;   &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;&lt;br /&gt;&lt;/servlet&gt;&lt;br /&gt;&lt;br /&gt;&lt;!-- Faces Servlet Mapping --&gt;&lt;br /&gt;&lt;servlet-mapping&gt;&lt;br /&gt;   &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;&lt;br /&gt;   &lt;url-pattern&gt;/faces/*&lt;/url-pattern&gt;&lt;br /&gt;&lt;/servlet-mapping&gt;&lt;br /&gt;&lt;servlet-mapping&gt;&lt;br /&gt;   &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;&lt;br /&gt;   &lt;url-pattern&gt;*.jsf&lt;/url-pattern&gt;&lt;br /&gt;&lt;/servlet-mapping&gt;&lt;br /&gt;&lt;br /&gt;   &lt;servlet-mapping&gt;&lt;br /&gt;      &lt;servlet-name&gt;FacesServlet&lt;/servlet-name&gt;&lt;br /&gt;      &lt;url-pattern&gt;*.mk&lt;/url-pattern&gt;&lt;br /&gt;   &lt;/servlet-mapping&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; &lt;session-config&gt;&lt;br /&gt;  &lt;session-timeout&gt;10&lt;/session-timeout&gt;&lt;br /&gt; &lt;/session-config&gt;&lt;br /&gt; &lt;!--&lt;br /&gt;            This security constraint illustrates how JSP pages with JavaServer&lt;br /&gt;            Faces components can be protected from being accessed without going&lt;br /&gt;            through the Faces Servlet. The security constraint ensures that the&lt;br /&gt;            Faces Servlet will be used or the pages will not be processed.&lt;br /&gt;        --&gt;&lt;br /&gt; &lt;security-constraint&gt;&lt;br /&gt;  &lt;display-name&gt;Restrict access to JSP pages&lt;/display-name&gt;&lt;br /&gt;  &lt;web-resource-collection&gt;&lt;br /&gt;   &lt;web-resource-name&gt;Restrict access to JSP pages&lt;/web-resource-name&gt;&lt;br /&gt;     &lt;url-pattern&gt;&lt;/url-pattern&gt;&lt;br /&gt;  &lt;/web-resource-collection&gt;&lt;br /&gt;  &lt;auth-constraint&gt;&lt;br /&gt;   &lt;description&gt;With no roles defined, no access granted&lt;/description&gt;&lt;br /&gt;  &lt;/auth-constraint&gt;&lt;br /&gt; &lt;/security-constraint&gt;&lt;br /&gt; &lt;login-config&gt;&lt;br /&gt;  &lt;auth-method&gt;BASIC&lt;/auth-method&gt;&lt;br /&gt; &lt;/login-config&gt;&lt;br /&gt;&lt;br /&gt;&lt;/web-app&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9079494833044939711-7818632222867541196?l=random-thoughts-vortex.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://random-thoughts-vortex.blogspot.com/feeds/7818632222867541196/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://random-thoughts-vortex.blogspot.com/2009/03/basic-richfaces-project-with-spring.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9079494833044939711/posts/default/7818632222867541196'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9079494833044939711/posts/default/7818632222867541196'/><link rel='alternate' type='text/html' href='http://random-thoughts-vortex.blogspot.com/2009/03/basic-richfaces-project-with-spring.html' title='Basic RichFaces Project with Spring'/><author><name>agema-makedonin</name><uri>http://www.blogger.com/profile/17141246309473354181</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_ofsKG4Jlu5I/SyoTaP7ijYI/AAAAAAAAA_c/ddPpEY159H4/S220/phpMJlNct_c3AM.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9079494833044939711.post-8907520628097754359</id><published>2009-03-15T03:46:00.000-07:00</published><updated>2009-03-15T05:02:01.051-07:00</updated><title type='text'>Adding Spring to the project</title><content type='html'>Spring is generally highly rated for it's IoC capabilities. It gained it's popularity while developers had hard times with EJB 2.0 Specs.&lt;br /&gt;&lt;br /&gt;Since Spring can be needed in more sub-project or modules, it is only reasonable to create a central place in your project to implement your Spring code. Create a Maven module as described in the revious post. It should look similar to this:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_ofsKG4Jlu5I/Sbzh1uzo3kI/AAAAAAAAA4M/nQqy2r1cRdc/s1600-h/spring.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 315px; height: 183px;" src="http://1.bp.blogspot.com/_ofsKG4Jlu5I/Sbzh1uzo3kI/AAAAAAAAA4M/nQqy2r1cRdc/s400/spring.png" alt="" id="BLOGGER_PHOTO_ID_5313369973604277826" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;The Spring configuration files should be placed inside of the &lt;span style="font-weight: bold;"&gt;src/main/resources&lt;/span&gt; folder.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_ofsKG4Jlu5I/SbziRVQ7X5I/AAAAAAAAA4U/n6OFUDEcIqw/s1600-h/src.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 221px; height: 72px;" src="http://3.bp.blogspot.com/_ofsKG4Jlu5I/SbziRVQ7X5I/AAAAAAAAA4U/n6OFUDEcIqw/s400/src.png" alt="" id="BLOGGER_PHOTO_ID_5313370447784140690" border="0" /&gt;&lt;/a&gt;The main Spring configuration file is named &lt;span style="font-weight: bold;"&gt;applicationContext.xml&lt;/span&gt; by default. How ever this is not mandatory. You can name it hwat ever you like. I called it  &lt;span style="font-weight: bold;"&gt;spring-context.xml&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;If you are using the Sprng for web app or portlets, you can tell Spring where to find your custom configuration file with the following entry in your &lt;span style="font-weight: bold;"&gt;web.xml&lt;/span&gt; descriptor:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_ofsKG4Jlu5I/SbzryrFNXnI/AAAAAAAAA4c/JsEDkPgng3Y/s1600-h/context-web.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 63px;" src="http://2.bp.blogspot.com/_ofsKG4Jlu5I/SbzryrFNXnI/AAAAAAAAA4c/JsEDkPgng3Y/s400/context-web.png" alt="" id="BLOGGER_PHOTO_ID_5313380916180901490" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Now that you have the basic structure for your Spring, you should add the Module in to the main Project &lt;span style="font-weight: bold;"&gt;pom.xml&lt;/span&gt; :&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_ofsKG4Jlu5I/Sbzs2yjqYRI/AAAAAAAAA4k/yDywgmFIi1I/s1600-h/module.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 23px;" src="http://4.bp.blogspot.com/_ofsKG4Jlu5I/Sbzs2yjqYRI/AAAAAAAAA4k/yDywgmFIi1I/s400/module.png" alt="" id="BLOGGER_PHOTO_ID_5313382086418784530" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;and add it as dependency to be available in other projects:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_ofsKG4Jlu5I/SbztESl0EGI/AAAAAAAAA4s/Z0IoBlL9P9Y/s1600-h/dependency.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 102px;" src="http://4.bp.blogspot.com/_ofsKG4Jlu5I/SbztESl0EGI/AAAAAAAAA4s/Z0IoBlL9P9Y/s400/dependency.png" alt="" id="BLOGGER_PHOTO_ID_5313382318356041826" border="0" /&gt;&lt;/a&gt;Now that the Spring module is configured and available as dependency for other modules, you can bind it in other &lt;span style="font-weight: bold;"&gt;modules &lt;/span&gt;by adding the dependency in their &lt;span style="font-weight: bold;"&gt;pom.xml&lt;/span&gt; as follows:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_ofsKG4Jlu5I/SbztuZv_k4I/AAAAAAAAA40/rVv4WGgNvyU/s1600-h/dep.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 393px; height: 77px;" src="http://3.bp.blogspot.com/_ofsKG4Jlu5I/SbztuZv_k4I/AAAAAAAAA40/rVv4WGgNvyU/s400/dep.png" alt="" id="BLOGGER_PHOTO_ID_5313383041832293250" border="0" /&gt;&lt;/a&gt;As you can notice, the dependency in other modules pom.xml is added without the version tag. In this way, the versioning of the project dependency's is handled central in the main project &lt;span style="font-weight: bold;"&gt;pom.xml&lt;/span&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9079494833044939711-8907520628097754359?l=random-thoughts-vortex.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://random-thoughts-vortex.blogspot.com/feeds/8907520628097754359/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://random-thoughts-vortex.blogspot.com/2009/03/adding-spring-to-project.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9079494833044939711/posts/default/8907520628097754359'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9079494833044939711/posts/default/8907520628097754359'/><link rel='alternate' type='text/html' href='http://random-thoughts-vortex.blogspot.com/2009/03/adding-spring-to-project.html' title='Adding Spring to the project'/><author><name>agema-makedonin</name><uri>http://www.blogger.com/profile/17141246309473354181</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_ofsKG4Jlu5I/SyoTaP7ijYI/AAAAAAAAA_c/ddPpEY159H4/S220/phpMJlNct_c3AM.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_ofsKG4Jlu5I/Sbzh1uzo3kI/AAAAAAAAA4M/nQqy2r1cRdc/s72-c/spring.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9079494833044939711.post-4979189781315880593</id><published>2009-03-14T14:07:00.000-07:00</published><updated>2009-03-14T15:16:02.060-07:00</updated><title type='text'>Maven project architecture</title><content type='html'>Maven alows the developer to manage Enterprise projects in a modular way. This keep the project in order when it grows in time.&lt;br /&gt;&lt;br /&gt;To create new Maven project, you can click&lt;span style="font-weight: bold;"&gt; File&gt;New Project&lt;/span&gt; and select&lt;span style="font-weight: bold;"&gt; Maven Project&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_ofsKG4Jlu5I/Sbwd1b64x9I/AAAAAAAAA20/idCLBKF9hl0/s1600-h/maven+new.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 381px;" src="http://4.bp.blogspot.com/_ofsKG4Jlu5I/Sbwd1b64x9I/AAAAAAAAA20/idCLBKF9hl0/s400/maven+new.png" alt="" id="BLOGGER_PHOTO_ID_5313154464255363026" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;By selecting &lt;span style="font-weight: bold;"&gt;Next &lt;/span&gt;the following dialog will show up:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_ofsKG4Jlu5I/SbwcywqCnSI/AAAAAAAAA2s/J02LKlqDsnc/s1600-h/new+maven+project+1.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 385px; height: 400px;" src="http://4.bp.blogspot.com/_ofsKG4Jlu5I/SbwcywqCnSI/AAAAAAAAA2s/J02LKlqDsnc/s400/new+maven+project+1.png" alt="" id="BLOGGER_PHOTO_ID_5313153318770613538" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Click finish. What is important to note is the packaging of the project. It is set on &lt;span style="font-weight: bold;"&gt;POM&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Next, in the workspace will show the new project. You can than create&lt;span style="font-weight: bold;"&gt; new Folder&lt;/span&gt; and name it &lt;span style="font-weight: bold;"&gt;modules&lt;/span&gt; and underneath this folder you can create other folders that will include your modules or component projects. Your project should look similar to the following:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_ofsKG4Jlu5I/SbwheiUTpZI/AAAAAAAAA28/Fa8xHsjC3h4/s1600-h/maven-project.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 318px; height: 272px;" src="http://4.bp.blogspot.com/_ofsKG4Jlu5I/SbwheiUTpZI/AAAAAAAAA28/Fa8xHsjC3h4/s400/maven-project.png" alt="" id="BLOGGER_PHOTO_ID_5313158468882113938" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Clicking the &lt;span style="font-weight: bold;"&gt;pom.xml&lt;/span&gt; should produce the following code:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_ofsKG4Jlu5I/SbwiX0LuRXI/AAAAAAAAA3E/MXYMpd9gov0/s1600-h/pom1.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 113px;" src="http://4.bp.blogspot.com/_ofsKG4Jlu5I/SbwiX0LuRXI/AAAAAAAAA3E/MXYMpd9gov0/s400/pom1.png" alt="" id="BLOGGER_PHOTO_ID_5313159452930491762" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;To create new Module Project, you should click &lt;span style="font-weight: bold;"&gt;File &gt; New Project&lt;/span&gt; and select &lt;span style="font-weight: bold;"&gt;Maven Module&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_ofsKG4Jlu5I/SbwjcgvpL9I/AAAAAAAAA3M/pZpqItqmuwE/s1600-h/maven-module.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 387px; height: 400px;" src="http://2.bp.blogspot.com/_ofsKG4Jlu5I/SbwjcgvpL9I/AAAAAAAAA3M/pZpqItqmuwE/s400/maven-module.png" alt="" id="BLOGGER_PHOTO_ID_5313160633123418066" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;If your main project was not authomatically selected as parent Project, you should click &lt;span style="font-weight: bold;"&gt;Browse&lt;/span&gt; and select it from the work space. Click Next.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_ofsKG4Jlu5I/SbwkXdMWExI/AAAAAAAAA3U/ss3HclTXV1Q/s1600-h/maven-module-new.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 387px; height: 400px;" src="http://2.bp.blogspot.com/_ofsKG4Jlu5I/SbwkXdMWExI/AAAAAAAAA3U/ss3HclTXV1Q/s400/maven-module-new.png" alt="" id="BLOGGER_PHOTO_ID_5313161645782340370" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Click finish. The Project will appear in your work space and looks like this:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_ofsKG4Jlu5I/SbwlHEJM-KI/AAAAAAAAA3c/Ugu02bz1sOA/s1600-h/next.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 234px; height: 182px;" src="http://3.bp.blogspot.com/_ofsKG4Jlu5I/SbwlHEJM-KI/AAAAAAAAA3c/Ugu02bz1sOA/s400/next.png" alt="" id="BLOGGER_PHOTO_ID_5313162463691995298" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Close the project, and remove it from the work space. But make sure you don't delete it. Go on your hard disk, where your wrk space is, and copy the new created project in the folder of your main project. After this, it should look something like this:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_ofsKG4Jlu5I/Sbwnt70cH_I/AAAAAAAAA3k/tCoTKKn2Yng/s1600-h/module-created.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 326px; height: 253px;" src="http://2.bp.blogspot.com/_ofsKG4Jlu5I/Sbwnt70cH_I/AAAAAAAAA3k/tCoTKKn2Yng/s400/module-created.png" alt="" id="BLOGGER_PHOTO_ID_5313165330495578098" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;All we have to do, is to tell maven where to find the new &lt;span style="font-weight: bold;"&gt;Module&lt;/span&gt;. If you open the main project pom.xml, you will notice that Eclipse added your module as follows:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_ofsKG4Jlu5I/Sbwoequ3_bI/AAAAAAAAA3s/u3bSwvXSjeM/s1600-h/pom.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 167px;" src="http://4.bp.blogspot.com/_ofsKG4Jlu5I/Sbwoequ3_bI/AAAAAAAAA3s/u3bSwvXSjeM/s400/pom.png" alt="" id="BLOGGER_PHOTO_ID_5313166167722425778" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Change the entry in to tag &lt;span style="font-weight: bold;"&gt;&lt;module&gt;&lt;/module&gt;&lt;/span&gt; as follows:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_ofsKG4Jlu5I/SbwpgKGc2gI/AAAAAAAAA30/xYo__8wfLa4/s1600-h/altered.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 65px;" src="http://3.bp.blogspot.com/_ofsKG4Jlu5I/SbwpgKGc2gI/AAAAAAAAA30/xYo__8wfLa4/s400/altered.png" alt="" id="BLOGGER_PHOTO_ID_5313167292834306562" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;The last but not the least is to add the module as a dependency in the main project, so that other sub project- modules can import it as dependency.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_ofsKG4Jlu5I/Sbwq4Zf6_VI/AAAAAAAAA38/vrBd_CzuVtE/s1600-h/dependency.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 105px;" src="http://2.bp.blogspot.com/_ofsKG4Jlu5I/Sbwq4Zf6_VI/AAAAAAAAA38/vrBd_CzuVtE/s400/dependency.png" alt="" id="BLOGGER_PHOTO_ID_5313168808796159314" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;In your command console, navigate to the folder of your main project and execute the following maven command:&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(204, 0, 0);"&gt;mvn -X clean install&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If everything goes well, maven will end with the following message:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_ofsKG4Jlu5I/Sbwsj-3RKWI/AAAAAAAAA4E/n5_rbKUE_b8/s1600-h/console.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 93px;" src="http://3.bp.blogspot.com/_ofsKG4Jlu5I/Sbwsj-3RKWI/AAAAAAAAA4E/n5_rbKUE_b8/s400/console.png" alt="" id="BLOGGER_PHOTO_ID_5313170657072195938" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9079494833044939711-4979189781315880593?l=random-thoughts-vortex.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://random-thoughts-vortex.blogspot.com/feeds/4979189781315880593/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://random-thoughts-vortex.blogspot.com/2009/03/maven-project-architecture.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9079494833044939711/posts/default/4979189781315880593'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9079494833044939711/posts/default/4979189781315880593'/><link rel='alternate' type='text/html' href='http://random-thoughts-vortex.blogspot.com/2009/03/maven-project-architecture.html' title='Maven project architecture'/><author><name>agema-makedonin</name><uri>http://www.blogger.com/profile/17141246309473354181</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_ofsKG4Jlu5I/SyoTaP7ijYI/AAAAAAAAA_c/ddPpEY159H4/S220/phpMJlNct_c3AM.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_ofsKG4Jlu5I/Sbwd1b64x9I/AAAAAAAAA20/idCLBKF9hl0/s72-c/maven+new.png' height='72' width='72'/><thr:total>0</thr:total></entry></feed>
