taylor 2002/09/23 11:56:22 Modified: src/java/org/apache/jetspeed/modules/actions/portlets CustomizeSetAction.java Log: Fixed bug to handle category filtering. Removed the code to reuse the portlet list and the allportlets list from the session. The portlet list is still stored in the session, however it is used only by maintainUserSelections() method. The userSelectionMap is updated on filtering, or when previous/next are clicked. On clicking apply all the entries in the userSelectionMap are committed.Added start parameter to the url after doFilterCategory is called as otherwise the session variables are cleared. Revision Changes Path 1.30 +38 -12 jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/CustomizeSetAction.java Index: CustomizeSetAction.java =================================================================== RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/CustomizeSetAction.java,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- CustomizeSetAction.java 17 Sep 2002 00:23:22 -0000 1.29 +++ CustomizeSetAction.java 23 Sep 2002 18:56:22 -0000 1.30 @@ -134,6 +134,7 @@ private static final String USER_SELECTIONS = "session.portlets.user.selections"; private static final String UI_PORTLETS_SELECTED = "portletsSelected"; private static final String PORTLET_LIST = "session.portlets.list"; + private static final String ALL_PORTLET_LIST = "session.all.portlets.list"; private static final String PORTLET_LIST_PAGE_SIZE = "session.portlets.page.size"; /** @@ -282,6 +283,7 @@ int start = rundata.getParameters().getInt("start", -1); if (start < 0) { + //System.out.println("Clearing session variables"); start = 0; PortletSessionState.clearAttribute(rundata,USER_SELECTIONS); PortletSessionState.clearAttribute(rundata,PORTLET_LIST); @@ -558,6 +560,8 @@ { int end = Math.min(start + size, portlets.size()); int pnames_index = 0; + //Go through all the portlets on this page and figure out which ones have been + //checked and which ones unchecked and accordingly update the userSelectionMap for (int portlet_index = start; portlet_index < end; portlet_index++) { PortletEntry entry = (PortletEntry)portlets.get(portlet_index); @@ -565,7 +569,7 @@ pnames_index < pnames.length && pnames[pnames_index].equals(entry.getName())) { - userSelections.put(entry.getName(), String.valueOf(portlet_index)); + userSelections.put(entry.getName(), entry); pnames_index++; } else @@ -574,9 +578,8 @@ } } PortletSessionState.setAttribute(rundata,USER_SELECTIONS,userSelections); - - Iterator it = userSelections.keySet().iterator(); /* + Iterator it = userSelections.keySet().iterator(); System.out.print("User Selections: "); while (it.hasNext()) { @@ -584,7 +587,6 @@ } System.out.println("\n"); */ - } else { @@ -887,13 +889,19 @@ // Create a list of all available portlets public static List buildPortletList(RunData data, PortletSet set, String mediaType, List allPortlets) { + /* Can not use this as filtering of category requires us to rebuild the portlet + list and the allPortlets list each time. List list = (List)PortletSessionState.getAttribute(data,PORTLET_LIST,null); if (list != null) - { - return list; + { + allPortlets = (List)PortletSessionState.getAttribute(data,ALL_PORTLET_LIST,null); + if (allPortlets != null) + { + return list; + } } - - list = new ArrayList(); + */ + List list = new ArrayList(); String mime = ((JetspeedRunData) data).getCapability() .getPreferredType() @@ -964,7 +972,8 @@ return t1.compareTo(t2); } }); - + //this is used only by maintainUserSelection - which does not need the + //portlet list to be regenrated PortletSessionState.setAttribute(data,PORTLET_LIST,list); return list; } @@ -1108,10 +1117,27 @@ /** * Adds a filter over the available portlets list based on category */ - public void doFiltercategory(RunData rundata, Context context) + public void doFiltercategory(RunData rundata, Context context) throws Exception { String filterCat = rundata.getParameters().getString("filter_category", "All Portlets"); - rundata.getUser().setTemp("filter_category", filterCat); + PortletSessionState.setAttribute(rundata, "filter_category", filterCat); + maintainUserSelections(rundata); + + String mtype = rundata.getParameters().getString("mtype", null); + JetspeedLink link = JetspeedLinkFactory.getInstance(rundata); + DynamicURI duri = null; + if (mtype == null) + { + duri = link.setTemplate("Customize").addQueryData("start", "0"); + } + else + { + duri = link.setTemplate("Customize").addQueryData("start", "0").addQueryData("mtype",mtype); + } + JetspeedLinkFactory.putInstance(link); + rundata.setRedirectURI(duri.toString()); + return; + }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>