Thursday, December 27, 2012

Popup in liferay using AUI

Below code is used to show a popup using AUI:

<portlet:renderURL var="somePageURL" windowState="<%= LiferayWindowState.EXCLUSIVE.toString() %>">
  <portlet:param name="jspPage" value="/jsp/some/page.jsp"/>
  <portlet:param name="redirect" value="<%= currentURL %>"/>
 <script type="text/javascript">
function showPopup() {
  AUI().use('aui-dialog', 'aui-io', 'event', 'event-custom', function(A) {
    var dialog = new A.Dialog({
            title: 'Popup Title',
            centered: true,
            draggable: true,
            modal: true
        }).plug(A.Plugin.IO, {uri: '<%= somePageURL %>'}).render();
Cheers, Ujjwal Soni

Create tab using AUI in liferay 6.1

You can create tabs in Liferay 6.1 using AUI as below ::

AUI().ready('aui-tabs', function(A) {
 var tabs = new A.TabView(
   boundingBox: '#demo',
   items: [
     content: 'This my content 1',
     label: 'Tab 1'
     content: 'This my content 2',
     label: 'Tab 2'
     content: 'This my content 3',
     label: 'Tab 3'

Ujjwal Soni 

Private Session XML Attribute in Liferay

Difference between Private Session = True & Private Session = false

1) Private Session = True

This is the default setting, in which each WAR has its own session. The session within each WAR is private, and nothing is shared between individual WARs. Portlets and Servlet within the same WAR file will be able to share the session, because they are in the same context. So far, this conforms to the Servlet spec.
Liferay provides an additional functionality under this setting. As the official FAQ states, it also allows shared (namespaced) attributes set by the portal to be visible from portlets. Any session attribute with the configured prefix (e.g. LIFERAY_SHARED_) will be copied over and be visible by the portlets, hence granting private portlets read-access to session attributes set by the portal.

2) Private Session = False

All portlets under this setting will share the same session, and also share this same session with the portal. This is the easiest way for portlets in individual WAR files to communicate with each other.
However, the downside to this is that servlets in these WAR files will not be able to communicate with the portlets at all. (This is a question often raised in the forums, and one I struggled with for a while to figure out). The most convenient way to think of this is that portlets with this setting use the portal session, and have no access to the WAR session.

So, to summarize ::
  • Non-private portlets read and write to the Portal session.
  • Private portlets write to their own WAR session.
  • Private portlets try to read from their own WAR session first, then looks up any shared attributes copied from the Portal session.
  • Servlets only have access to the WAR session, and cannot directly access the Portal session. In order to read shared session attributes, servlets need a private portlet in the same WAR file to copy it for them. Or you can configure your servlet to use the portal session by using Liferay's PortalDelegateServlet mechanism.
I hope this has helped you in your understanding of Liferay’s session sharing mechanism.


Ujjwal Soni

Liferay Session Sharing


I had a requirement for sharing session information from Liferay Portal to Servlet deployed in same Liferay server. so, i developed Liferay portlet which callsPortalSession setParameter method and i store a string value to it. In my servlet, i use request.getSession().getParameter("NAME").

But, unfortunately, i got null value there. (Please note that servlet was a plain servlet and does not contain any liferay code in that war). After doing some reserarching, i found below evidence to achive this ::


For Portlets who will share (i.e setAttribute() ) session attributes(s) need to add following entry in liferay-portlet.xml



By default “LIFERAY_SHARED_”  prefix is used for sharing session attribute to other WARs.  It can be customized with in ‘s session.shared.attributes value.

portletSession.setAttribute( "LIFERAY_SHARED_myVar",value,PortletSession.APPLICATION_SCOPE);

Other portlet(s)  in different WAR  can access it as below :

portletSession.getAttribute( "LIFERAY_SHARED_myVar",PortletSession.APPLICATION_SCOPE);

by implementing above code, i was able to get value stored in one portlet in other portlet which are deployed in different war files.

Now, i added a servlet in portlet where i was getting value from session.

I added below entry in liferay-portlet.xml


and i added below code in my portlet

Object value=portletSession.getAttribute( "LIFERAY_SHARED_myVar",PortletSession.APPLICATION_SCOPE);

 request.getSession().setAttribute("NAME", value);

Now, in my servlet, i was able to get value of NAME session attribute as below ::

Object valueFromSession=request.getSession().getAttribute("NAME");

For knowing more on Private Session xml attribute, refer my next blog post.


Ujjwal Soni

Monday, December 24, 2012

Experience with Liferay

Hello Everyone,

I would just like to share my experience on my first project with Liferay. I have used themes, layouts and Struts 1.2 along with Hibernate 3.2 with this project, the integration of all these 3 was quite complex but once you have cracked it down, it becomes easy.

I found liferay quite easy and managable. Conversion of existing struts/spring framework projects is quite easy.


Ujjwal Soni

Liferay vis-a-vis Other Portal Frameworks


Liferay vs. Closed Source Portals
�Innovation - In its 9th year of development, Liferay boasts a history of innovation among both commercial and open source products.
�Low TCO - Liferay provides the lowest total cost of ownership with ZERO license fees under the MIT license.
�High ROI - Use your existing IT investment. There is no application server agenda and no pressure to pay for tools Develop portlets with a full featured IDE like Eclipse, Netbeans, and JBuilder or with lightweight editor like EditPlus, VI, and Emacs.
�Freedom & Flexibility - Open source means the code is in your hands. If you want to customize it, you can. If there are security flaws, the community can participate in fixing it quickly.
�Security - There is actually less risk in going with a sustained open source product than in going with a commercial vendor. Vendors can go out of business. Vendors can merge and render your product dead in the water. A sustained open source product like Liferay Portal has an active community around it that works together.

Liferay vs. Open Source Portals
�Market Leadership - Liferay is the leader in downloads among all open source Java portals.
�Principle - Not all open source licenses are created equal. Some require modifications to be contributed if you choose to sell or distribute your product. Some still charge a license fee for commercial use.
�Maturity - Liferay has one of the most mature and active open source communities as evidenced by the active forums.
�Stability - Aside from the impressive community, there is a real company behind the product driving product development.


Ujjwal Soni

Friday, December 7, 2012

Linq Javascript Cheat Sheets


Below URL's contain really useful references for linq and javascript.

Linq Cheat Sheet

Javascript Cheat Sheet


Ujjwal Soni


J2EE Project Development Best Practises

I am adding something from my own experiences (although its more of a compilation of development best practises, you might find it useful to keep them in mind while designing your application):
  • There is no one-size-fits-all design
  • Try to keep application as light weight as possible.
  • Use Maven to manage dependencies
    • Don't rely excessively on IDE. Make sure your project builds without IDE (If you are using maven, It will :) Try to open you project with Netbeans and Eclipse, both.
  • For the technologies mentioned above, appfuse makes a good starting point.
  • Design your database/entities first
  • Use libraries sensibly and judiciously. Do NOT overuse them.
  • Dont forget to write JUnit/TestNG (at least forservice layer)
  • Test application on all major browsers (not just your favorite one :)
  • Determine how many total users and how many concurrent users your web app will have.
    • Then decide whether you need caching or not.
    • you will use app server clustering or not.
  • Select the application server based on its capabilities and more importantly 'your needs'
  • Avoid using any app-server specific api
  • Use JPA interfaces/annotations even if using hibernate as JPA implementation
  • Be extra cautious while mapping relationships in entities. Decide which properties and relationships will load lazily and which will load eagerly
  • Keep application security in mind while designing the app. Spring security is excellent choice.
  • Never abuse HttpSession. Dont store too much in it.
  • Keep entities Serializable. Enforce developers to use toString(), hashCode() and equals()
  • Dont Forget to use version controlling from Day 1
  • Dont just assume that spring/hibernate/spring-mvc will be best choice for you. create small proof of concepts with atleast 3 to 4 options.
  • Try to automate integration/build/deploy with CI tools like Hudson
  • Check and Tune SQL generated by Hibernate (time to time)
  • do not let business logic creep into view layer. hate jsp scriptlets? Consider Velocity/Freemarker. JSP is not the only option.
  • externalize the environment specific configuration by using Spring's PropertyPlaceholderConfigurator.
  • If possible, try to integrate with existing User Authentication mechanism (Like LDAP/ OpenID) rather than writing your own. This will save you from reinventing the wheel and your users from remembering yet another set of username and password. 
There are several things you'll need for architecture design documents. Not an easy task but props on taking the opportunity. Since this is such a large question, hopefully these links can get you started and you can refine questions after getting your feet wet.
The methodology you use will affect what tasks you take on first. Waterfall is a popular but outdated methodology. A newer methodology is Agile that has several faces. My favorite is Scrum Agile for developing software of any size.
Diagrams are one of the most powerful ways to represent the system as a whole and as individual components. The type of diagrams you create depend on the system. There are usually a Structure Diagrams, Behavior Diagrams, Interaction Diagrams and tons of others. These diagrams show the pieces of the system as a whole, each components physical layout and/or logical layout, communication flow, procedure flow, etc..
Documentation is just like it sounds, documents and documents that have Project Descriptions, Scope, User Cases, Sequence Diagrams, and any other document that describes the project or pieces of the project.

Peruse the Agile Modeling site which pushes for "just enough" modeling. They have some great guidelines including a full "agile modeling process" from requirements gathering to design/development.
As for tools, I love Visual Paradigm. It's relatively inexpensive (compared to other tools). There are a variety of free modeling tools (google is your friend), but none compare to Visual Paradigm, and for bit that it costs, it's well worth it. If my employer didn't pony up the cash for it, I would buy it myself... :)

If there are any additions, you can add it in comments section.


Ujjwal Soni
best-it-exam-    | for-our-work-    | hottst-on-sale-    | it-sale-    | tast-dumps-us-    | test-king-number-    | pass-do-it-    | just-do-it-    | pass-with-us-    | passresults-everything-    | passtutor-our-dumps-    | realtests-us-exam-    | latest-update-source-for-    | cbtnuggets-sale-exam    | experts-revised-exam    | certguide-sale-exam    | test4actual-sale-exam    | get-well-prepared-    | certkiller-sale-exam    | buy-discount-dumps    | how-to-get-prepared-for-the    | in-an-easy-way    | brain-dumps-sale    | with-pass-exam-guarantee    | accurate-study-material    | at-first-try    | 100%-successful-rate    | get-certification-easily    | material-provider-exam    | real-exam-practice    | with-pass-score-guarantee    | certification-material-provider    | for-certification-professionals    | get-your-certification-successfully    | 100%-Pass-Rate    | in-pdf-file    | practice-exam-for    | it-study-guides    | study-material-sku    | study-guide-pdf    | prep-guide-demo    | certification-material-id    | actual-tests-demo    | brain-demos-test    | best-pdf-download    | our-certification-material    | best-practice-test    | leading-provider-on    | this-course-is-about    | the-most-reliable    | high-pass-rate-of    | money-back-guarantee    | high-pass-rate-demo    | recenty-updated-key    | only-for-students-free-download    | courseware-plus-kit-for    | accurate-answers-of    | the-most-reliable-id    | provide-training-for    | welcome-to-buy    | material-for-success-pass    | provide-free-support    | best-book-for-pass    | accuracy-of-the-answers    | pass-guarantee-id    | pass-exam-key    |    |    |