[jboss-user] [JBoss Portal] - Re: 2 identical portlets in the same page
portal_man
do-not-reply at jboss.com
Thu Mar 22 09:37:13 EDT 2007
Here, you got the code of the processAction of the weather portlet.
public void processAction(ActionRequest request, ActionResponse response) throws PortletException
| {
| String newZip = request.getParameter("newzip");
|
| if(null != newZip)
| {
| PortletPreferences prefs = request.getPreferences();
| try
| {
| prefs.setValue("RssXml", RSS_URL_PREFIX + newZip);
| prefs.store();
| }
| catch(Exception e)
| {
| e.printStackTrace();
| }
| }
| response.setRenderParameter("newzip", RSS_URL_PREFIX + newZip);
| response.setPortletMode(PortletMode.VIEW);
| }
Here, you got the code of the processAction of my portlet.
public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException, UnavailableException
| {
| PortletMode portletmode = request.getPortletMode();
| if(PortletMode.EDIT.equals(portletmode))
| {
| // récupération du nombre sélectionné dans la listbox
| // mise en session, pour l'édition
| // mise en variable locale pour l'affichage
|
| String tempNamespace = request.getParameter("namespace");
| if (tempNamespace.equals(namespace))
| {
| nbFlux = request.getParameter("nbFlux");
| request.getPortletSession().setAttribute(namespace+"nbFlux",nbFlux);
|
| if (request.getParameter("details") == null) {
| details = "false";
| request.getPortletSession().setAttribute(namespace+"details","false");
| }
| else {
| details = "true";
| request.getPortletSession().setAttribute(namespace+"details","true");
| }
| response.setPortletMode(PortletMode.VIEW);
| }
| }
| }
The purpose of nbFlux is to fix the numbers of lines we take in the rss feeds. The problem is, when we got two instance of the portlet, setting this nbFlux in one portlet set the variables in the two.
That the reason of the use of namespace (to knew in which portlet we are). But, because of ActionResponse can give access to the value of the namespace we are obliged to use a global variable.
The problem is this variable is share between the two portlets. Its value is given by the last portlet which accessed it.
There is no solution.
(I can easily show two different xml feeds, but it's impossible to show the first one with 12 lines and the second with 9).
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4030633#4030633
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4030633
More information about the jboss-user
mailing list