Total Pageviews

Monday, November 29, 2010

Difference between a Java interface and a Java abstract class?

Hello every one,
There are few points that I think distinguishes Java interface from a Java Abstract Class. have a look -
1. Methods of a Java interface are implicitly abstract and cannot have implementations. A Java abstract class can have instance methods that implements a default behavior.
2. Variables declared in a Java interface is by default final. A Java abstract class may contain non-final variables.
3. Members of a Java interface are public by default. A Java abstract class can have the usual flavors of class members like private, protected, etc..
4. Java interface should be implemented using keyword “implements”; A Java abstract class should be extended using keyword “extends”.
5. An interface can extend another Java interface only, an abstract class can extend another Java class and implement multiple Java interfaces.
6. A Java class can implement multiple interfaces but it can extend only one abstract class.
7. Interface is absolutely abstract and cannot be instantiated; A Java abstract class also cannot be instantiated, but can be invoked if a main() exists.
8. In comparison with java abstract classes, java interfaces are slow as it requires extra indirection.

Wednesday, November 24, 2010

User Registration (create account) Portlet customization

The registration or create account portlet in Liferay portal can be customized to add/remove some of its field without any coding.

This blog explain some of these customization properties which developers can add them in portal-ext to change the behavior of user registration portlet.

users.screen.name.always.autogenerate - If you do not want your users to provide screen name, you can use this property hide screen name text field. The default value is false. If it is changed to true, the screen name field will not appear on the registration page and screen name will be auto generated by the portal.

login.create.account.allow.custom.password - The default registration portlet in Liferay doesn't provide option of password selection to user. If this property is set to true, the registration screen will show password fields to user and user can provide password of his/her choice.

field.enable.com.liferay.portal.model.Contact.male - If your site is not interested in knowing the gender of the user, you can remove gender selection from the page by setting false value of this property.

field.enable.com.liferay.portal.model.Contact.birthday - Last configuration is for birth date field. You can remove bith date selection by setting false value to this property.
captcha.check.portal.create_account - This propery can be used to tell whether or not to use captcha checks for the account creation.

users.email.address.required - Set this to false if you want to be able to create users without an email address. An email address will be automatically assigned to a user based on the property "users.email.address.auto.suffix". If user is entering his email id, the system will not generate a new one. Usually, setting this property to false will make sense when you don't want user to use email address for login.

Sunday, November 21, 2010

Security Questions customization

I've seen various time people asking for disabling security question and creating custom questions. That's why I am writing this post. However its quite easy.


For disabling the queries, we have to set the following properties false in portal-ext.properties
users.reminder.queries.enabled=false

When you press the drop down list box of security questions, a entry is shown -"write my own question", that can be disabled by setting the following property false in portal-ext.properties as follows:
users.reminder.queries.custom.question.enabled=false

However, if you wish to display your own custom question in the drop down list box, that's a bit tricky, but not too difficult at all. One important thing to note about this - they are not stored in an any database table, but in language_en.properties (and in other locales) file, and whose key is provided in the portal.properties file's following property:
users.reminder.queries.questions= <list of question keys>
Now, for creating your own question, you have to create a (or more) question(s) with unique key(s), and list those keys as the value os above mentioned property in portal-ext.properties file.

Don't forget to add your custom language-ext.properties file in you stack in ext-impl/src/content, so that it can also be overridden. In the same way, you can create property file for all other supported locales too.

see the following example:

portal-ext.properties
users.reminder.queries.questions= question-1,question-2

Language-ext.properties
question-1=this is the first question
question-2=this is the second question
question-3=this is the third question


Disabling Terms and Condition
set the following property false in the portal-ext.properties for disabling terms and condition:
terms.of.use.required=false