Package com.mycompany

Source Code of com.mycompany.ListBookmarksAction

package com.mycompany;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.portlet.PortletPreferences;

import org.apache.struts2.dispatcher.DefaultActionSupport;
import org.apache.struts2.portlet.interceptor.PortletPreferencesAware;

import com.mycompany.domain.Bookmark;

public class ListBookmarksAction extends DefaultActionSupport implements PortletPreferencesAware {
     private List<Bookmark> bookmarks = new ArrayList<Bookmark>();
     private PortletPreferences portletPreferences;

     public List<Bookmark> getBookmarks() {
        return bookmarks;
     }

     public void setPortletPreferences(PortletPreferences portletPreferences) {
        this.portletPreferences = portletPreferences;
     }

     @Override
     public String execute() throws Exception {
        // For simplicity, we'll assume that only bookmarks are stored in the preferences.
        Map<String, String[]> preferencesMap = portletPreferences.getMap();
        for(Map.Entry<String, String[]> entry : preferencesMap.entrySet()) {
           bookmarks.add(new Bookmark(entry.getKey(), entry.getValue()[0]));
        }
        return SUCCESS;
     }
  }
TOP

Related Classes of com.mycompany.ListBookmarksAction

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.