JAVASCRIPT/ JQuery Page Redirection
|
Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts
Monday, April 27, 2015
JAVASCRIPT/ JQuery Page Redirection
Labels:
javascript,
jquery,
page,
redirection,
window. loation,
window.location
Friday, October 18, 2013
To make JSP compatible with IE8 or IE 9
Add the following code to the javascript block.
Happy Coding !!
#if ($browserSniffer.getMajorVersion($request) < 9) <meta http-equiv="X-UA-Compatible" content="IE=8" /> #else <meta http-equiv="X-UA-Compatible" content="IE=9" /> #endthis will make the jsp compatible with IE 8 or IE 9
Happy Coding !!
Labels:
block,
browser,
comapatibile,
compatible with IE8 or IE 9,
ie8,
ie9,
internet explorer,
issue,
javascript,
jsp,
liferay,
script
Wednesday, July 24, 2013
Form re submission of/on Page Reload Errror
The property 'action-url-redirect' must be added to the liferay-portlet.xml file. This will not allow the form to be re submitted once the page is refreshed after a form submission is already done.
By default the property is false and thus the form resubmission occurs
By default the property is false and thus the form resubmission occurs
Labels:
custom,
duplicate,
error,
form,
form submission error,
javascript,
liferay,
liferay error,
portal,
portlet,
ProcessAction,
submission,
User,
validation
Friday, July 19, 2013
Running liferay script on control Panel Script console
Liferay has a script console at the Control Panel. It is accessible to the Liferay administrator. In the Script console Liferay API code , and other various
code can be run seamlessly.
The script console is located at
ContolPanel --> Server --> Server Administration.
Here are few examples of codes run in the console and screenshot of the output. Most of the codes were run here by selecting the Language as "Groovy".
Example 1. Get list of users
Language : Groovy
code:
import com.liferay.portal.service.UserLocalServiceUtil;
userCount = UserLocalServiceUtil.getUsersCount();
users = UserLocalServiceUtil.getUsers(0, userCount);
count=0;
for (user in users) {
count++;
println(count+". User: " + user.getFullName());
}

Example 2. Get list of roles supported be the portal.
Language : Groovy
code:
import com.liferay.portal.service.RoleLocalServiceUtil;
roleCount =RoleLocalServiceUtil.getRolesCount();
roles=RoleLocalServiceUtil.getRoles(0,roleCount );
for(role in roles){
println("Role Name: " + role.getName());
}
Example 3. Get number of users in the portal . (using Javascript as language default script)
Language : Javascript
code:
number = Packages.com.liferay.portal.service.UserLocalServiceUtil.getUsersCount();
out.println(number);
The script console is located at
ContolPanel --> Server --> Server Administration.
Here are few examples of codes run in the console and screenshot of the output. Most of the codes were run here by selecting the Language as "Groovy".
Example 1. Get list of users
Language : Groovy
code:
import com.liferay.portal.service.UserLocalServiceUtil;
userCount = UserLocalServiceUtil.getUsersCount();
users = UserLocalServiceUtil.getUsers(0, userCount);
count=0;
for (user in users) {
count++;
println(count+". User: " + user.getFullName());
}

Example 2. Get list of roles supported be the portal.
Language : Groovy
code:
import com.liferay.portal.service.RoleLocalServiceUtil;
roleCount =RoleLocalServiceUtil.getRolesCount();
roles=RoleLocalServiceUtil.getRoles(0,roleCount );
for(role in roles){
println("Role Name: " + role.getName());
}
Example 3. Get number of users in the portal . (using Javascript as language default script)
Language : Javascript
code:
number = Packages.com.liferay.portal.service.UserLocalServiceUtil.getUsersCount();
out.println(number);
Tuesday, July 16, 2013
How to get the current logged in user in liferay
There are more than one way to do this. Let's look at some of the options available.
- User user = (User) request.getAttribute(WebKeys.USER);
The User class is the Liferay's model User class. - ThemeDisplay td = (ThemeDisplay) request.getAttribute( WebKeys.THEME_DISPLAY );
User user = td.getUser();
This ' ThemeDisplay 'class can be used to get various information about the portal page,user and theme. Classes ThemeDisplay, User and WebKeys are available in portal-service.jar - User currentUser = PortalUtil.getUser( request );
The 'PortalUtil' has various utility functions , which come handy during Liferay Programming. This is also a part of the Portal-service.jar. - LiferayFacesContext liferayFacesContext = LiferayFacesContext.getInstance();
User currentUser=liferayFacesContext.getUser();
The class 'PortalFacesContext' has been renamed to 'LiferayFacesContext'.This class exists in order to assist with migrating old JSF 1.2 based projects from the legacy PortletFaces-Tools project to the new LiferayFaces project.
Hope It helps you in your portal programming. Happy Coding :)
Labels:
CurrentUser,
facelets,
fragments,
getUser(),
icefaces,
java,
java2us,
javascript,
jboss,
jcp,
jsr-168,
liferay,
list of portal severs,
pluto,
portals,
Portlet Lifecycle,
portlets,
portlets portal servers,
User
Friday, July 16, 2010
Add Javascript to Ice Faces or Facelets
There are several ways to add JavaScript code to an ice faces page. One of which is explained here.The "Direct to Dom" (akaD2D) rendering of icefaces makes it difficult to add javascript or any other code to it.
Q. Where to add the code? .
Ans. The answer is to put the < script type="text/javascript"> just code after the < ice:root> between < html> < head> .add the javascript in the similar way as you add it in jsp/html. then close the tag and at the end before closing the root (i.e < /ice:root> ) add the < /html> tag.
Q. How to call an icefaces componet?
Ans. Use the formname:componentid format to use it in the javascript function.
Q. How to use the body onload thing without using body tag.
Ans. The answer lies in using the window event.
Here is an example which makes everything clear
< jsp:root version="2.0" f="http://java.sun.com/jsf/core" h="http://java.sun.com/jsf/html" ice="http://www.icesoft.com/icefaces/component" jsp="http://java.sun.com/JSP/Page">
< f:view>
< script type="text/javascript>
function setFocusOnLogin(){ document.getElementById("icefaces_formaname:icefaces_component_id").focus(); }//its used to call the icefaces component's focus event
window.attachEvent("onload", setFocusOnLogin);//like body onload , its called on page load < /script>
< ice:portlet>
< ice:form id="icefaces_formaname">
< ice:inputtext id="icefaces_component_id" size="10">
< /ice:inputtext>
< /ice:form>
< /ice:portlet>
< /f:view>
< /jsp:root>
Hope you get it. For any concerns feel free to post a comment.
Q. Where to add the code? .
Ans. The answer is to put the < script type="text/javascript"> just code after the < ice:root> between < html> < head> .add the javascript in the similar way as you add it in jsp/html. then close the tag and at the end before closing the root (i.e < /ice:root> ) add the < /html> tag.
Q. How to call an icefaces componet?
Ans. Use the formname:componentid format to use it in the javascript function.
Q. How to use the body onload thing without using body tag.
Ans. The answer lies in using the window event.
Here is an example which makes everything clear
< jsp:root version="2.0" f="http://java.sun.com/jsf/core" h="http://java.sun.com/jsf/html" ice="http://www.icesoft.com/icefaces/component" jsp="http://java.sun.com/JSP/Page">
< f:view>
< script type="text/javascript>
function setFocusOnLogin(){ document.getElementById("icefaces_formaname:icefaces_component_id").focus(); }//its used to call the icefaces component's focus event
window.attachEvent("onload", setFocusOnLogin);//like body onload , its called on page load < /script>
< ice:portlet>
< ice:form id="icefaces_formaname">
< ice:inputtext id="icefaces_component_id" size="10">
< /ice:inputtext>
< /ice:form>
< /ice:portlet>
< /f:view>
< /jsp:root>
Hope you get it. For any concerns feel free to post a comment.
Labels:
facelets,
icefaces,
javascript,
liferay,
portlets,
portlets portal servers,
webspace
Subscribe to:
Posts (Atom)