Saturday, October 2, 2010

What is the difference between partial and render in Zend PHP?

A view script can be rendered in Zend using partial and render method. Every view script rendered by the view object, will have the entire variable scope of the script preceeding it. This will lead to some unwanted issues, when you want to re-use the script multiple times, or if you want to manipulate the variables, which will lead to other issues for the later scripts.
For example, you have a shared view script which is used to display the Ads in your index page, based on the position variable. Suppose in your index page, you are calling the Ads script in the top as well as bottom of your page, by using the render method and you have your position variable initialized to some value through controller and sticked on to the view, the the same value will be in scope throughout the script for the Ads call for both top and bottom, unless it is changed everytime before the shared Ads call is rendered, which will create some awkward issues in displaying the Ads. To overcome this issue
Enters partial: The big difference between rendering the script using partial and render is that, partial will have its own variable scope, it doesn't see any variables associated to the view, it only see the variable passed to it directly. As an example take the following

$this->Ads('/shared/viewAd.phtml', array('position' => "top", 'groupId' => '1223'));

Friday, September 10, 2010

How to bring MyComputer Icon in desktop in Windows 7

To bring the MyComput Icon in desktop in Windows7. Click the Start menu, and then right click on the "Computer". Click on the "Show on Desktop" item in the menu, and your computer icon will be back on the desktop.

Wednesday, August 25, 2010

Exception in thread "main" java.lang.NoClassDefFoundError: javax.persistence.Cacheable

When you are working with Hibernate using the Annotations, you will get the following exceptions
Exception in thread "main" java.lang.NoClassDefFoundError:javax.persistence.Cacheable 
even though you have added the required libraries that comes with the Hibernate distribution final 3.5 as well as ejb3-persistence.jar.
The reason for this javax.persistence.Cacheable is part of JPA 2.0 specification. To overcome this issue, you need to add the following JAR file hibernate-jpa-2.0-api-1.0.0.Final.jar, which will be available under /lib/jpa directory in Hibernate distribution.

Happy programming

Initial SessionFactory creation java.lang.NoSuchMethodException

When you have the default libraries provided by the Hibernate 3.5 (hibernate-annotations.jar)and also have the ebj3-persistence.jar to support the annotation feature, you will be end up with the following exception on runtime
Initial SessionFactory creation java.lang.NoSuchMethodException: org.hibernate.validator.ClassValidator.(java.lang.Class, java.util.ResourceBundle, org.hibernate.validator.MessageInterpolator, java.util.Map, org.hibernate.annotations.common.reflection.ReflectionManager)
This is because of the incompatible types, if you are using the EJB based Annotations feature just, remove the hibernate-annotations.jar from your library. This will resolve the above runtime exceptions.

Saturday, August 14, 2010 Address already in use: JVM_Bind 8009

In most of our development machines, we would have installed so many things for our practice purpose, which will create hell of issues, on the port number. So many of you, have encountered the following exceptions, when starting our server Address already in use: JVM_Bind 8009.
How to figure out which application is occupying my port
In Windows
1. In MS-DOS, send command "netstat -ao". You can get network information for all processes.

2. Find out the one using port 8009, get the PID.
3. Find out the process with the PID you just got from windows task manager and shut it down. (By default the Task Manager doesn't show the PID. You have to add it from the menu View Select columns)
4. That's it, restart your server