1 5 6 package org.exoplatform.portlets.wsrp; 7 8 import java.util.*; 9 import java.io.IOException ; 10 import java.io.Writer ; 11 import javax.portlet.* ; 12 import javax.portlet.PortletSession; 13 14 import org.apache.commons.logging.Log; 15 import org.exoplatform.services.wsrp.WSRPConstants; 16 import org.exoplatform.services.wsrp.consumer.*; 17 23 public class UIProducers { 24 private Log log_ ; 25 private List uiProducers_ ; 26 27 public UIProducers(ProducerRegistry pregistry, Log log) throws Exception { 28 log_ = log ; 29 Iterator i = pregistry.getAllProducers() ; 30 uiProducers_ = new ArrayList() ; 31 boolean visible = true ; 32 while (i.hasNext()) { 33 Producer producer = (Producer) i.next() ; 34 UIProducer uiProducer = new UIProducer(producer, log) ; 35 uiProducers_.add(uiProducer) ; 36 uiProducer.setVisible(visible) ; 37 visible = false ; 38 } 39 } 40 41 public void render(RenderRequest request, RenderResponse response, ResourceBundle res) throws Exception { 42 for (int i = 0 ; i < uiProducers_.size(); i++) { 43 UIProducer uiProducer = (UIProducer) uiProducers_.get(i) ; 44 uiProducer.render(request, response, res) ; 45 } 46 } 47 48 public void processAction(ActionRequest request, ActionResponse response) throws Exception { 49 String action = request.getParameter("action") ; 50 String producerId = request.getParameter("producerId") ; 51 if ("selectProducer".equals(action)) { 52 for (int i = 0 ; i < uiProducers_.size(); i++) { 53 UIProducer uiProducer = (UIProducer) uiProducers_.get(i) ; 54 if(uiProducer.getId().equals(producerId)) { 55 uiProducer.setVisible(!uiProducer.isVisible()) ; 56 } 57 } 58 } 59 60 if ("selectPortlet".equals(action)) { 61 String portletHandle = request.getParameter("portletHandle") ; 62 PortletPreferences prefs = request.getPreferences() ; 63 prefs.setValue(WSRPConstants.WSRP_PRODUCER_ID , producerId) ; 64 prefs.setValue(WSRPConstants.WSRP_PORTLET_HANDLE , portletHandle) ; 65 prefs.setValue(WSRPConstants.WSRP_PARENT_HANDLE , portletHandle) ; 66 prefs.store() ; 67 } 68 } 69 } 70 | Popular Tags |