KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portlets > wsrp > UIProducers


1 /*
2 * Copyright 2001-2004 The eXo platform SARL All rights reserved.
3 * Please look at license.txt in info directory for more license detail.
4 */

5
6 package org.exoplatform.portlets.wsrp;
7
8 import java.util.*;
9 import java.io.IOException JavaDoc;
10 import java.io.Writer JavaDoc ;
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 /*
18  * A part of the business logic of this portlet was taken from the WSRP4J project
19  * @author Tuan Nguyne
20  * tuan08@users.sourceforge.net
21  * Tue, Feb 24, 2004 @ 14:35
22  */

23 public class UIProducers {
24   private Log log_ ;
25   private List uiProducers_ ;
26   
27   public UIProducers(ProducerRegistry pregistry, Log log) throws Exception JavaDoc {
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 JavaDoc {
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 JavaDoc {
49     String JavaDoc action = request.getParameter("action") ;
50     String JavaDoc 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 JavaDoc 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