Monday, July 20, 2009
Email Validation
function email(str) {
var at="@"
var dot="."
var lat=str.indexOf(at)
var lstr=str.length
var ldot=str.indexOf(dot)
if (str.indexOf(at)==-1){
alert("Invalid E-mail ID")
return false
}
if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
alert("Invalid E-mail ID")
return false
}
if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
alert("Invalid E-mail ID")
return false
}
if (str.indexOf(at,(lat+1))!=-1){
alert("Invalid E-mail ID")
return false
}
if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
alert("Invalid E-mail ID")
return false
}
if (str.indexOf(dot,(lat+2))==-1){
alert("Invalid E-mail ID")
return false
}
if (str.indexOf(" ")!=-1){
alert("Invalid E-mail ID")
return false
}
return true
}
</script>
Simple Struts Portlet
--------------------
<portlet>
<portlet-name>EXT_3</portlet-name>
<display-name>Library Portlet</display-name>
<portlet-class>com.liferay.portlet.StrutsPortlet</portlet-class>
<init-param>
<name>view-action</name>
<value>/ext/library/view</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
</supports>
<resource-bundle>com.liferay.portlet.StrutsResourceBundle</resource-bundle>
<security-role-ref>
<role-name>power-user</role-name>
</security-role-ref>
<security-role-ref>
<role-name>user</role-name>
</security-role-ref>
</portlet>
2) liferay-portlet-ext.xml
----------------------------
<portlet>
<portlet-name>EXT_3</portlet-name>
<struts-path>ext/library</struts-path>
<use-default-template>false</use-default-template>
</portlet>
3) liferay-display.xml
------------------------
add
<portlet id="EXT_3" />
inside
<category name="category.example">
4) struts-config.xml
----------------------
<action path="/ext/library/view" forward="portlet.ext.library.view" />
5) tiles-defs.xml
-------------------
<definition name="portlet.ext.library" extends="portlet" />
<definition name="portlet.ext.library.view" extends="portlet.ext.library">
<put name="portlet_content" value="/portlet/ext/library/view.jsp" />
</definition>
(create the following two jsp files under "/ext/ext-web/docroot/html/portlet/ext/library")
6. init.jsp
-------------
<%@ include file="/html/portlet/init.jsp" %>
Add commonly used variables and declarations here!
7. view.jsp
-------------
<%@ include file="/html/portlet/ext/library/init.jsp" %>
Simple Struts Portlet!
8 Language-ext.properties
---------------------------
Add a new entry in the above file,
javax.portlet.title.EXT_3=Library Portlet
Basic JSP Portlet
~~~~~~~~~~~~~~~~~~~
[the xml files are located under "ext/ext-web/docroot/WEB-INF"]
1.1. portlet-ext.xml
--------------------
(insert the below content)
<portlet>
<portlet-name>EXT_2</portlet-name>
<display-name>JSP Portlet Introduction</display-name>
<portlet-class>com.liferay.util.bridges.jsp.JSPPortlet</portlet-class>
<init-param>
<name>view-jsp</name>
<value>/html/portlet/ext/jsp_portlet/view.jsp </value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
</supports>
<resource-bundle>com.liferay.portlet.StrutsResourceBundle</resource-bundle>
<security-role-ref>
<role-name>power-user </role-name>
</security-role-ref>
<security-role-ref>
<role-name>user</role-name>
</security-role-ref>
</portlet>
1.2. liferay-portlet-ext.xml
----------------------------
(insert the below content)
<portlet>
<portlet-name>EXT_2</portlet-name>
</portlet>
1.3. liferay-display.xml
------------------------
(insert the below content)
<category name="category.example">
<portlet id="EXT_2">
</category>
1.4. view.jsp
-------------
(create this file under "ext/ext-web/docroot/html/portlet/ext/jsp_portlet"
and enter the below contents)
Welcome to simple Basic JSP Portlet
Note: after this step do "ant deploy" from "ext-web"
1.5 Language-ext.properties
---------------------------
(under /ext/ext-impl/src/content)
Add two new entries in the above file,
javax.portlet.title.EXT_2=JSP Portlet
category.example=Example
Note: after this step do "ant deploy" from "ext-impl"
Writing Dynamic Query using Hibernate API's
=======
in AddBookAction.java:
if (Validator.isNull(cmd)) {
BookLocalServiceUtil.create(bookTitle);
} else {
List
if (cmd.equals("find")) {
results = BookLocalServiceUtil.findBooks(bookTitle);
} else {
DetachedCriteria dCriteria = DetachedCriteria.forClass(Book.class);
dCriteria.add(Restrictions.like("title", "%" + bookTitle + "%"));
DynamicQuery dynamicQuery = new DynamicQueryImpl(dCriteria);
results = (List)BookLocalServiceUtil.dynamicQuery(dynamicQuery);
}
req.setAttribute("results", results);
req.setAttribute("cmd", cmd);
}
2:
=======
in view.jsp
Add for 'search' button
findBook('search');" />
Note: the findBook JS function is now accepting a parameter, do changes to this function and also to the "Find Book" button.
3:
=======
in Success.jsp update this
if (Validator.isNotNull(cmd)) {
books = (List)request.getAttribute("results");
} else {
books = BookLocalServiceUtil.getAllBooks();
}
4 :
========
ant deploy from ext-impl,
ant deploy from ext-web,
restart tomcat
Websites Developed by Liferay
http://www.paninicomics.it/web/guest/home
http://www.connexion.sg/web/guest/home
http://www.axxonet.net/web/guest/home
http://www.myoffice24x7.com/web/guest/home
http://www.mathforamerica.org/home
http://www.myjv.com/web/public/home
http://www.b-informed.de/web/guest/yapta
http://www.toyotahitel.hu/finanszirozas
http://www.afromix.info/web/news/
http://www.k4k.hu/nyitolap
http://www.euroleasing.hu/index
http://www.unisalento.it/web/guest/home_page
http://www.mebtel.net/pub/guest/home
http://www.netbiscuits.com/home
http://www.betavine.net/bvportal/home.html
http://www.kokkolaweather.fi/web/guest/home
http://www.ruralpovertyportal.org/web/guest/home
http://www.casagrandeaz.gov/web/guest/home
http://www.orshalom.org/web/guest/home
http://www.ntk.hu/web/guest/home
http://www.jsonlive.com/web/guest/jsonhome
http://www.soapractice.com/web/guest/home
http://207.210.217.14/web/guest/home
http://www.cise09.org/web/guest/home
http://www.xml-intl.com/web/guest/home
http://www.youthpeer.org/web/guest/home
https://teaming.dss.state.la.us/web/guest/home
http://p-learnet.univ-lille1.fr/web/guest/home
http://nfig.hd.free.fr/web/guest/home
http://www.lingresource.com/web/guest/home
http://www.skillsconnect.gov.sg/web/guest/home
http://developer.tandberg.com/web/guest/home
http://pennstatehershey.org/web/guest/home
http://learninglab.etwinning.net/web/guest/home
http://apps.zanox.com/web/guest/home
http://www.idmunit.org/web/guest/home
http://www.amishitayal.com/web/guest/home
http://www.benetton.com/portal/web/guest/home
http://www.centurioncargo.com/web/guest/home
http://www.sidsa.com/web/guest/home
http://www.icareus.com/web/guest/home
http://www.mybizsites.com/web/guest/home
http://ac.utm.my/web/guest/main
http://www.techweb.com/web/guest/home
http://www.mypic32.com/web/guest/home
http://gmoss.jrc.it/web/guest/home
http://www.nimbleartists.com/web/guest/home
https://www.skywayperspectives.org/portal/web/guest/home
http://www.nimbleartists.com/web/guest/home
http://wi2bc8.bwl.uni-mannheim.de/web/guest/home
http://www.ignouforum.com/web/guest/home
http://www.newedgegroup.com/web/guest/home
http://www.geoportal.org/web/guest/home
http://suhakam.org.my/web/guest/home
http://www.etiagarwal.com/web/guest/home
http://www.bankrakyat.com.my/web/guest/home
http://www.in4ama.org/web/guest/home
http://www.vivektayal.com/web/guest/home
http://www.uengine.org/web/guest/home
http://www.mdks.gov.my/web/guest/home
http://www.apolytrosis.gr/web/guest/home
http://einstein.mangala-server.com/liferay/web/guest/home