package com.in.BH.utils; import java.util.ArrayList; import java.util.List; import javax.portlet.PortletRequest; import javax.servlet.http.HttpServletRequest; import com.bowstreet.webapp.WebAppAccess; public class PortletPreferance { PortletRequest portletRequest = null; public void setPrefrenaces(WebAppAccess webAppAccess , String url, String width , String height) { System.out.println("In the setPrefrenaces method"); try{ //PortletRequest pr = (PortletRequest)webAppAccess.getRequestData(); HttpServletRequest request = webAppAccess.getHttpServletRequest(); portletRequest = (PortletRequest) request.getAttribute(com.bowstreet.adapters.Constants.PORTLET_REQUEST); javax.portlet.PortletPreferences preferences = portletRequest.getPreferences(); //Storing the Edit parameters in the preferences Object preferences.setValue("url",url ); preferences.setValue("width",width ); preferences.setValue("height",height ); preferences.store(); }catch(Exception err) { err.printStackTrace(); System.out.println("Exception occured in the setPrefrenaces method"); } } public List getPrefrenaces(WebAppAccess webAppAccess) { System.out.println("In the getPrefrenaces method"); HttpServletRequest request = webAppAccess.getHttpServletRequest(); portletRequest = (PortletRequest) request.getAttribute(com.bowstreet.adapters.Constants.PORTLET_REQUEST); javax.portlet.PortletPreferences preferences = portletRequest.getPreferences(); String url = preferences.getValue("url","http://www.google.co.in"); String width =preferences.getValue("width","600"); String height= preferences.getValue("height","600"); List listobj= new ArrayList(); listobj.add(url); listobj.add(width); listobj.add(height); return listobj; } public static void main(String args[]) { System.out.println("I am in the main now"); } }