Bhiya error for today 2/6/15
console:-
Type mismatch: cannot convert from javax.portlet.PortletPreferences to com.liferay.portal.model.PortletPreferences
The method getValues(String, String[]) is undefined for the type PortletPreferences
code:-
package com.liferay.docs.guestbook.portlet;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;
import javax.portlet.ReadOnlyException;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.portlet.ValidatorException;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.model.PortletPreferences;
import com.liferay.util.bridges.mvc.MVCPortlet;
import com.sun.xml.internal.fastinfoset.util.DuplicateAttributeVerifier.Entry;
/**
* Portlet implementation class GuestbookPortlet
*/
public class GuestbookPortlet extends MVCPortlet {
public void addEntry(ActionRequest request, ActionResponse response){
try {
PortletPreferences prefs = request.getPreferences();
String[] guestbookEntries = prefs.getValues("guestbook-entries", new String[1]);
ArrayList<String> entries = new ArrayList<String>();
if(guestbookEntries !=null){
entries = new ArrayList<String>(Arrays.asList(prefs.getValues("guestbook-entries", new String[1])));
}
String userName = ParamUtil.getString(request, "name");
String message = ParamUtil.getString(request, message);
String entry = userName = "^" + message;
entries.add(entry);
String[] array = entries.toArray(new String[entries.size()]);
prefs.setValues("guestbook-entries", array);
try {
prefs.store();
} catch (IOException){
Logger.getLogger(GuestbookPortlet.class.getName()).log(Level.SEVERE, null, ex);
} catch (ValidatorException ex) {
Logger.getLogger(GuestbookPortlet.class.getName()).log(Level.SEVERE, null, ex);
}
}catch (ReadOnlyException ex) {
Logger.getLogger(GuestbookPortlet.class.getName()).log(Level.SEVERE, null, ex);
}
}
@Override
public void render (RenderRequest renderRequest, RenderResponse renderResponse)
throws PortletException, IOException {
PortletPreferences prefs = renderRequest.getPreferences();
String[] guestbookEntries = prefs.getValues("guestbook-entries", new String[1]);
if (guestbookEntries != null) {
List<Entry> entries = parseEntries(guestbookEntries);
renderRequest.setAttribute("entries", entries);
}
super.render(renderRequest, renderResponse);
}
private List<Entry> parseEntries (String[] guestbookEntries){
ArrayList<Entry> entries = new ArrayList();
for (String entry : guestbookEntries) {
String[] parts = entry.split("\\^", 2);
Entry gbEntry = new Entry(parts[0], parts[1]);
entries.add(gbEntry);
}
}
}
****************************************************************************
https://www.liferay.com/community/forums/-/message_boards/view_message/10757014
http://www.scalsys.com/blog/multiple-file-upload-in-liferay/
http://liferaypower.blogspot.in/2013/06/custom-portlet-for-file-upload-in.html
http://michi-path.blogspot.in/2013/02/file-upload-using-serveresource-ajax.html
http://vivekliferayblogspote.blogspot.in/2013/12/liferay-61-multiple-image-upload.html
http://parasjain.net/2014/06/03/multiple-file-uploads-in-liferay/
https://portalhub.wordpress.com/2012/05/20/spring-mvc-portlet-file-upload-and-download/
http://lauraliparulo.altervista.org/liferay-upload-file-portlet-working-example-with-upload-progress-bar/
___________________
http://www.liferay.com/community/forums/-/message_boards/message/23460142
https://github.com/liferay/liferay-portal/blob/master/portal-web/docroot/html/portlet/document_library/upload_multiple_file_entries.jsp
http://datefield.blogspot.in/2011/02/liferay-6-ajaxupload-and-swfupload.html
https://www.google.co.in/?gfe_rd=cr&ei=Yx9oVb6QGc708wex9oDYDg&gws_rd=ssl#q=uploadRequest.getFile%28%22file%22%29+liferay&start=50
>
https://www.liferay.com/community/forums/-/message_boards/message/13224298
console:-
Type mismatch: cannot convert from javax.portlet.PortletPreferences to com.liferay.portal.model.PortletPreferences
The method getValues(String, String[]) is undefined for the type PortletPreferences
code:-
package com.liferay.docs.guestbook.portlet;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;
import javax.portlet.ReadOnlyException;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.portlet.ValidatorException;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.model.PortletPreferences;
import com.liferay.util.bridges.mvc.MVCPortlet;
import com.sun.xml.internal.fastinfoset.util.DuplicateAttributeVerifier.Entry;
/**
* Portlet implementation class GuestbookPortlet
*/
public class GuestbookPortlet extends MVCPortlet {
public void addEntry(ActionRequest request, ActionResponse response){
try {
PortletPreferences prefs = request.getPreferences();
String[] guestbookEntries = prefs.getValues("guestbook-entries", new String[1]);
ArrayList<String> entries = new ArrayList<String>();
if(guestbookEntries !=null){
entries = new ArrayList<String>(Arrays.asList(prefs.getValues("guestbook-entries", new String[1])));
}
String userName = ParamUtil.getString(request, "name");
String message = ParamUtil.getString(request, message);
String entry = userName = "^" + message;
entries.add(entry);
String[] array = entries.toArray(new String[entries.size()]);
prefs.setValues("guestbook-entries", array);
try {
prefs.store();
} catch (IOException){
Logger.getLogger(GuestbookPortlet.class.getName()).log(Level.SEVERE, null, ex);
} catch (ValidatorException ex) {
Logger.getLogger(GuestbookPortlet.class.getName()).log(Level.SEVERE, null, ex);
}
}catch (ReadOnlyException ex) {
Logger.getLogger(GuestbookPortlet.class.getName()).log(Level.SEVERE, null, ex);
}
}
@Override
public void render (RenderRequest renderRequest, RenderResponse renderResponse)
throws PortletException, IOException {
PortletPreferences prefs = renderRequest.getPreferences();
String[] guestbookEntries = prefs.getValues("guestbook-entries", new String[1]);
if (guestbookEntries != null) {
List<Entry> entries = parseEntries(guestbookEntries);
renderRequest.setAttribute("entries", entries);
}
super.render(renderRequest, renderResponse);
}
private List<Entry> parseEntries (String[] guestbookEntries){
ArrayList<Entry> entries = new ArrayList();
for (String entry : guestbookEntries) {
String[] parts = entry.split("\\^", 2);
Entry gbEntry = new Entry(parts[0], parts[1]);
entries.add(gbEntry);
}
}
}
****************************************************************************
https://www.liferay.com/community/forums/-/message_boards/view_message/10757014
http://www.scalsys.com/blog/multiple-file-upload-in-liferay/
http://liferaypower.blogspot.in/2013/06/custom-portlet-for-file-upload-in.html
http://michi-path.blogspot.in/2013/02/file-upload-using-serveresource-ajax.html
http://vivekliferayblogspote.blogspot.in/2013/12/liferay-61-multiple-image-upload.html
http://parasjain.net/2014/06/03/multiple-file-uploads-in-liferay/
https://portalhub.wordpress.com/2012/05/20/spring-mvc-portlet-file-upload-and-download/
http://lauraliparulo.altervista.org/liferay-upload-file-portlet-working-example-with-upload-progress-bar/
___________________
http://www.liferay.com/community/forums/-/message_boards/message/23460142
https://github.com/liferay/liferay-portal/blob/master/portal-web/docroot/html/portlet/document_library/upload_multiple_file_entries.jsp
http://datefield.blogspot.in/2011/02/liferay-6-ajaxupload-and-swfupload.html
https://www.google.co.in/?gfe_rd=cr&ei=Yx9oVb6QGc708wex9oDYDg&gws_rd=ssl#q=uploadRequest.getFile%28%22file%22%29+liferay&start=50
>
https://www.liferay.com/community/forums/-/message_boards/message/13224298
Change import com.liferay.portal.model.PortletPreferences;
ReplyDeleteto import javax.portlet.PortletPreferences;