Author: emuckenhuber
Date: 2007-11-14 06:03:32 -0500 (Wed, 14 Nov 2007)
New Revision: 8921
Added:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/AbstractWidgetPortlet.java
Removed:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/WidgetPortlet.java
Modified:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/netvibes/NetvibesProviderTestCase.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/netvibes/NetvibesWidgetRenderTestCase.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/AbstractWidgetProvider.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/WidgetProvider.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/GGWidget.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/GGWidgetPortlet.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/NetvibesWidgetPortlet.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/provider/NetvibesJSONInfoBuilder.java
branches/JBoss_Portal_Branch_2_6/widget/src/resources/portal-widget-war/WEB-INF/jsp/edit_content.jsp
Log:
JBPORTAL-1573: widget query result pagination
JBPORTAL-1613: more shared widget portlet information
Modified:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/netvibes/NetvibesProviderTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/netvibes/NetvibesProviderTestCase.java 2007-11-14
10:04:44 UTC (rev 8920)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/netvibes/NetvibesProviderTestCase.java 2007-11-14
11:03:32 UTC (rev 8921)
@@ -22,8 +22,6 @@
******************************************************************************/
package org.jboss.portal.test.widget.netvibes;
-import java.util.HashMap;
-
import junit.framework.TestCase;
import org.jboss.portal.widget.Widget;
Modified:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/netvibes/NetvibesWidgetRenderTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/netvibes/NetvibesWidgetRenderTestCase.java 2007-11-14
10:04:44 UTC (rev 8920)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/test/widget/netvibes/NetvibesWidgetRenderTestCase.java 2007-11-14
11:03:32 UTC (rev 8921)
@@ -26,7 +26,6 @@
import java.io.FileInputStream;
import java.io.InputStream;
import java.net.URL;
-import java.util.HashMap;
import junit.framework.TestCase;
Added:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/AbstractWidgetPortlet.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/AbstractWidgetPortlet.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/AbstractWidgetPortlet.java 2007-11-14
11:03:32 UTC (rev 8921)
@@ -0,0 +1,118 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.widget;
+
+import javax.portlet.GenericPortlet;
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletException;
+import javax.portlet.PortletMode;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel
Muckenhuber</a>
+ * @version $Revision$
+ */
+public abstract class AbstractWidgetPortlet extends GenericPortlet
+{
+ /** . */
+ private static final org.jboss.logging.Logger log =
org.jboss.logging.Logger.getLogger(WidgetPortlet.class);
+
+ /** . */
+ public final static String INIT_PARAM_CONNECTION_TIMEOUT =
"connectionTimeout";
+
+ /** .*/
+ public final static String INIT_PARAM_ENTRY_EXPIRATION = "entryExpiration";
+
+ /** . */
+ public final static String INIT_PARAM_QUERY_EXPIRATION = "queryExpiration";
+
+ /** .*/
+ public final static String INIT_PARAM_FETCH_WIDGETS_ON_LOOKUP =
"fetchWidgetsOnDirectoryLookup";
+
+ /** .*/
+ protected final PortletMode EDIT_CONTENT = new PortletMode("edit_content");
+
+ /**
+ * @return WidgetProvider
+ */
+ protected abstract WidgetProvider getProvider();
+
+ public void init() throws PortletException
+ {
+ PortletConfig config = getPortletConfig();
+ WidgetProvider provider = getProvider();
+ // Connection timeout
+ String timeout = config.getInitParameter(INIT_PARAM_CONNECTION_TIMEOUT);
+ if (timeout != null && timeout.length() > 0)
+ {
+ try
+ {
+ provider.setConnectionTimeout(Integer.parseInt(timeout));
+ }
+ catch (NumberFormatException e)
+ {
+ log.error("Failed to parse connectionTimeout init parameter - should be
integer number: ", e);
+ }
+ }
+ // Query expiration
+ String queryExpiration = config.getInitParameter(INIT_PARAM_QUERY_EXPIRATION);
+ if(queryExpiration != null && queryExpiration.length() > 0)
+ {
+ try
+ {
+ provider.setQueryExpiration(Integer.parseInt(queryExpiration));
+ }
+ catch(NumberFormatException e)
+ {
+ log.error("Failed to parse queryExpiration init parameter - should be
integer number: ", e);
+ }
+ }
+ // Entry expiration
+ String entryExpiration = config.getInitParameter(INIT_PARAM_ENTRY_EXPIRATION);
+ if(entryExpiration != null && entryExpiration.length() > 0)
+ {
+ try
+ {
+ provider.setEntryExpiration(Integer.parseInt(entryExpiration));
+ }
+ catch(NumberFormatException e)
+ {
+ log.error("Failed to parse entryExpiration init parameter - should be
integer number: ", e);
+ }
+ }
+ // Fetch all widgets of a query result ?
+ String fetchWidgetsOnDirectoryLookup =
config.getInitParameter(INIT_PARAM_FETCH_WIDGETS_ON_LOOKUP);
+ if(fetchWidgetsOnDirectoryLookup != null &&
fetchWidgetsOnDirectoryLookup.length() > 0)
+ {
+
provider.setFetchWidgetsOnDirectoryLookup(Boolean.getBoolean(fetchWidgetsOnDirectoryLookup));
+ }
+
+ // Finally start widget provider
+ provider.start();
+ }
+
+ public void destroy()
+ {
+ WidgetProvider provider = getProvider();
+ provider.stop();
+ }
+}
\ No newline at end of file
Modified:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/AbstractWidgetProvider.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/AbstractWidgetProvider.java 2007-11-14
10:04:44 UTC (rev 8920)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/AbstractWidgetProvider.java 2007-11-14
11:03:32 UTC (rev 8921)
@@ -70,7 +70,6 @@
/** Eviction thread timing */
protected long timing = TimeUnit.MILLISECONDS.convert(60, TimeUnit.SECONDS);
-
public void start()
{
executor = new ThreadPoolExecutor(4, 4, 0, TimeUnit.SECONDS, new
LinkedBlockingQueue());
@@ -87,7 +86,6 @@
executor = null;
scheduledExecutor = null;
}
-
public long getConnectionTimeout()
{
@@ -99,10 +97,21 @@
this.connectionTimeout = connectionTimeout;
}
- // TODO entryExpiration
- // TODO queryExpiration
- // TODO fetchwidgetsonDirectoryLookup
+ public void setQueryExpiration(long millis)
+ {
+ this.queryExpiration = millis;
+ }
+ public void setEntryExpiration(long millis)
+ {
+ this.entryExpiration = millis;
+ }
+
+ public void setFetchWidgetsOnDirectoryLookup(boolean fetch)
+ {
+ this.fetchWidgetsOnDirectoryLookup = fetch;
+ }
+
/*
private void addWidget(URL url)
{
@@ -160,7 +169,6 @@
public List<Widget> getWidgets(List<URL> list)
{
-// long millis = System.currentTimeMillis();
if (list == null)
{
throw new IllegalArgumentException();
@@ -192,11 +200,9 @@
entries.remove(url);
}
}
-// System.out.println("fetchting 3 took: " +
NumberFormat.getInstance().format((System.currentTimeMillis() - millis) / 1000.0));
return widgets;
}
-
public List<DirectoryQueryResultEntry> search(WidgetQuery q)
{
if (q == null)
@@ -216,11 +222,11 @@
}
catch(InterruptedException e)
{
- //
+ // TODO
}
catch(ExecutionException e)
{
- //
+ // TODO
}
if( this.fetchWidgetsOnDirectoryLookup )
Deleted:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/WidgetPortlet.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/WidgetPortlet.java 2007-11-14
10:04:44 UTC (rev 8920)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/WidgetPortlet.java 2007-11-14
11:03:32 UTC (rev 8921)
@@ -1,177 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.widget;
-
-import org.jboss.portal.widget.google.provider.GGProvider;
-
-import javax.portlet.ActionRequest;
-import javax.portlet.ActionResponse;
-import javax.portlet.GenericPortlet;
-import javax.portlet.PortletException;
-import javax.portlet.PortletMode;
-import javax.portlet.PortletRequestDispatcher;
-import javax.portlet.PortletSecurityException;
-import javax.portlet.RenderRequest;
-import javax.portlet.RenderResponse;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @author <a href="mailto:boleslaw dot dawidowicz at jboss dot
com">Boleslaw Dawidowicz</a>
- * @version $Revision$
- */
-public abstract class WidgetPortlet extends GenericPortlet
-{
- /** . */
- private static final org.jboss.logging.Logger log =
org.jboss.logging.Logger.getLogger(WidgetPortlet.class);
-
- /** . */
- public final static String INIT_PARAM_CONNECTION_TIMEOUT =
"connectionTimeout";
-
- /** . */
- private final PortletMode EDIT_CONTENT = new PortletMode("edit_content");
-
- /** . */
- private GGProvider provider = new GGProvider();
-
-
- public void init() throws PortletException
- {
- provider.start();
- String timeout =
getPortletConfig().getInitParameter(INIT_PARAM_CONNECTION_TIMEOUT);
- if (timeout != null && timeout.length() > 0)
- {
- try
- {
- provider.setConnectionTimeout(Integer.parseInt(timeout));
- }
- catch (NumberFormatException e)
- {
- log.error("Failed to parse connectionTimeout init parameter - should be
integer number: ", e);
- }
- }
- }
-
-
- public void processAction(ActionRequest req, ActionResponse resp) throws
PortletException, PortletSecurityException, IOException
- {
- if (req.getParameter("content.action.select") != null)
- {
- String contentURI = req.getParameter("content.uri");
- if (contentURI != null)
- {
- // Will contain the next render params
- Map params = new HashMap();
-
- //
- params.put("content.uri", new String[]{contentURI});
-
- //
- for (Iterator i = req.getParameterMap().entrySet().iterator(); i.hasNext();)
- {
- Map.Entry entry = (Map.Entry)i.next();
- String contentParamName = (String)entry.getKey();
- if (contentParamName.startsWith("content.param"))
- {
- String[] contentParamValue = (String[])entry.getValue();
- params.put(contentParamName, contentParamValue);
- }
- }
-
- //
- String catParam = req.getParameter("cat");
- if (catParam != null)
- {
- params.put("cat", new String[]{catParam});
- }
-
- //
- String queryParam = req.getParameter("query");
- if (queryParam != null)
- {
- params.put("query", new String[]{queryParam});
- }
-
- String pickMethod = req.getParameter("gg_pick_method");
- if (pickMethod != null)
- {
- params.put("gg_pick_method", new String[]{pickMethod});
- }
-
- //
- resp.setRenderParameters(params);
- }
- }
- }
-
- protected void doView(RenderRequest req, RenderResponse resp) throws PortletException,
PortletSecurityException, IOException
- {
- resp.setContentType("text/html");
- PrintWriter writer = resp.getWriter();
- String uri = req.getParameter("uri");
- Widget widget = provider.getWidget(uri);
- if (widget != null)
- {
- writer.print(widget.render(req.getParameterMap(), req.getLocale()));
- }
- else
- {
- writer.print("Widget is not available");
- }
- writer.close();
- }
-
-
- protected void doDispatch(RenderRequest req, RenderResponse resp) throws
PortletException, PortletSecurityException, IOException
- {
- if (EDIT_CONTENT.equals(req.getPortletMode()))
- {
- doEditContent(req, resp);
- }
- else
- {
- super.doDispatch(req, resp);
- }
- }
-
- protected void doEditContent(RenderRequest req, RenderResponse resp) throws
PortletException, PortletSecurityException, IOException
- {
- resp.setContentType("text/html");
-
- //
- req.setAttribute("provider", provider);
-
- //
- PortletRequestDispatcher dispatcher =
getPortletContext().getRequestDispatcher("/WEB-INF/jsp/edit_content.jsp");
- dispatcher.include(req, resp);
- }
-
- public void destroy()
- {
- provider.stop();
- }
-}
Modified:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/WidgetProvider.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/WidgetProvider.java 2007-11-14
10:04:44 UTC (rev 8920)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/WidgetProvider.java 2007-11-14
11:03:32 UTC (rev 8921)
@@ -40,10 +40,16 @@
public Widget getWidget(URL url) throws InterruptedException, ExecutionException;
public List<Widget> getWidgets(List<URL> list);
+
+ public List<DirectoryQueryResultEntry> search(WidgetQuery query);
+
+ public void setConnectionTimeout(long connectionTimeout);
+
+ public void setQueryExpiration(long millis);
-// public List<Widget> search(WidgetQuery query);
+ public void setEntryExpiration(long millis);
- public List<DirectoryQueryResultEntry> search(WidgetQuery query);
+ public void setFetchWidgetsOnDirectoryLookup(boolean fetch);
}
Modified:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/GGWidget.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/GGWidget.java 2007-11-14
10:04:44 UTC (rev 8920)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/GGWidget.java 2007-11-14
11:03:32 UTC (rev 8921)
@@ -131,7 +131,7 @@
String defaultValue = prefInfo.getDefaultValue() != null ?
prefInfo.getDefaultValue() : "";
String[] values = (String[])parameters.get(prefName);
String value = values != null ? values[0] : defaultValue;
-
+ System.out.println("value: " + value);
// if value is present and not a default parameter
if (value != null && !defaultValue.equals(value))
{
Modified:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/GGWidgetPortlet.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/GGWidgetPortlet.java 2007-11-14
10:04:44 UTC (rev 8920)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/GGWidgetPortlet.java 2007-11-14
11:03:32 UTC (rev 8921)
@@ -22,14 +22,15 @@
******************************************************************************/
package org.jboss.portal.widget.google;
+import org.jboss.portal.widget.AbstractWidgetPortlet;
import org.jboss.portal.widget.Widget;
+import org.jboss.portal.widget.WidgetProvider;
import org.jboss.portal.widget.google.provider.GGProvider;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
-import javax.portlet.GenericPortlet;
+import javax.portlet.PortletConfig;
import javax.portlet.PortletException;
-import javax.portlet.PortletMode;
import javax.portlet.PortletRequestDispatcher;
import javax.portlet.PortletSecurityException;
import javax.portlet.RenderRequest;
@@ -45,43 +46,26 @@
* @author <a href="mailto:boleslaw dot dawidowicz at jboss dot
com">Boleslaw Dawidowicz</a>
* @version $Revision: 8784 $
*/
-public class GGWidgetPortlet extends GenericPortlet
+public class GGWidgetPortlet extends AbstractWidgetPortlet
{
/** . */
private static final org.jboss.logging.Logger log =
org.jboss.logging.Logger.getLogger(GGWidgetPortlet.class);
/** . */
- public final static String INIT_PARAM_CONNECTION_TIMEOUT =
"connectionTimeout";
-
- /** . */
- private final PortletMode EDIT_CONTENT = new PortletMode("edit_content");
-
- /** . */
private GGProvider provider = new GGProvider();
-
- public void init() throws PortletException
+ @Override
+ protected WidgetProvider getProvider()
{
- provider.start();
- String timeout =
getPortletConfig().getInitParameter(INIT_PARAM_CONNECTION_TIMEOUT);
- if (timeout != null && timeout.length() > 0)
- {
- try
- {
- provider.setConnectionTimeout(Integer.parseInt(timeout));
- }
- catch (NumberFormatException e)
- {
- log.error("Failed to parse connectionTimeout init parameter - should be
integer number: ", e);
- }
- }
+ return provider;
}
-
public void processAction(ActionRequest req, ActionResponse resp) throws
PortletException, PortletSecurityException, IOException
{
if (req.getParameter("content.action.select") != null)
{
+ PortletConfig conf = getPortletConfig();
+
String contentURI = req.getParameter("content.uri");
if (contentURI != null)
{
@@ -167,7 +151,7 @@
protected void doEditContent(RenderRequest req, RenderResponse resp) throws
PortletException, PortletSecurityException, IOException
{
resp.setContentType("text/html");
-
+ Map map = req.getParameterMap();
//
req.setAttribute("provider", provider);
@@ -175,9 +159,4 @@
PortletRequestDispatcher dispatcher =
getPortletContext().getRequestDispatcher("/WEB-INF/jsp/edit_content.jsp");
dispatcher.include(req, resp);
}
-
- public void destroy()
- {
- provider.stop();
- }
}
Modified:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/NetvibesWidgetPortlet.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/NetvibesWidgetPortlet.java 2007-11-14
10:04:44 UTC (rev 8920)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/NetvibesWidgetPortlet.java 2007-11-14
11:03:32 UTC (rev 8921)
@@ -30,54 +30,35 @@
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
-import javax.portlet.GenericPortlet;
import javax.portlet.PortletException;
-import javax.portlet.PortletMode;
import javax.portlet.PortletRequestDispatcher;
import javax.portlet.PortletSecurityException;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
+import org.jboss.portal.widget.AbstractWidgetPortlet;
import org.jboss.portal.widget.Widget;
+import org.jboss.portal.widget.WidgetProvider;
import org.jboss.portal.widget.netvibes.provider.NetvibesProvider;
/**
* @author <a href="mailto:emuckenh@redhat.com">Emanuel
Muckenhuber</a>
* @version $Revision$
*/
-public class NetvibesWidgetPortlet extends GenericPortlet
+public class NetvibesWidgetPortlet extends AbstractWidgetPortlet
{
/** . */
private static final org.jboss.logging.Logger log =
org.jboss.logging.Logger.getLogger(NetvibesWidgetPortlet.class);
-
+
/** . */
- public final static String INIT_PARAM_CONNECTION_TIMEOUT =
"connectionTimeout";
-
- /** . */
- private final PortletMode EDIT_CONTENT = new PortletMode("edit_content");
-
- /** . */
private NetvibesProvider provider = new NetvibesProvider();
- public void init() throws PortletException
+ protected WidgetProvider getProvider()
{
- provider.start();
- String timeout =
getPortletConfig().getInitParameter(INIT_PARAM_CONNECTION_TIMEOUT);
- if (timeout != null && timeout.length() > 0)
- {
- try
- {
- provider.setConnectionTimeout(Integer.parseInt(timeout));
- }
- catch (NumberFormatException e)
- {
- log.error("Failed to parse connectionTimeout init parameter - should be
integer number: ", e);
- }
- }
+ return provider;
}
-
-
+
public void processAction(ActionRequest req, ActionResponse resp) throws
PortletException, PortletSecurityException, IOException
{
if (req.getParameter("content.action.select") != null)
@@ -162,7 +143,6 @@
protected void doEditContent(RenderRequest req, RenderResponse resp) throws
PortletException, PortletSecurityException, IOException
{
resp.setContentType("text/html");
-
//
req.setAttribute("provider", provider);
@@ -171,8 +151,4 @@
dispatcher.include(req, resp);
}
- public void destroy()
- {
- provider.stop();
- }
}
Modified:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/provider/NetvibesJSONInfoBuilder.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/provider/NetvibesJSONInfoBuilder.java 2007-11-14
10:04:44 UTC (rev 8920)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/provider/NetvibesJSONInfoBuilder.java 2007-11-14
11:03:32 UTC (rev 8921)
@@ -25,9 +25,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portal.common.net.URLTools;
Modified:
branches/JBoss_Portal_Branch_2_6/widget/src/resources/portal-widget-war/WEB-INF/jsp/edit_content.jsp
===================================================================
---
branches/JBoss_Portal_Branch_2_6/widget/src/resources/portal-widget-war/WEB-INF/jsp/edit_content.jsp 2007-11-14
10:04:44 UTC (rev 8920)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/resources/portal-widget-war/WEB-INF/jsp/edit_content.jsp 2007-11-14
11:03:32 UTC (rev 8921)
@@ -32,8 +32,16 @@
selWidget = (GGWidget) provider.getWidget(uri);
}
+
+ // Number of results to display
+ int numberOfResults = 10;
+ String resultSize= request.getParameter("numberOfResults");
+ if (resultSize != null && !resultSize.equals(""))
+ {
+ numberOfResults = Integer.parseInt(resultSize);
+ }
+
// Pagination
- int numberOfResults = 10;
int currentPage = 0;
String tempPage = request.getParameter("currentPage");
if ( tempPage != null && !tempPage.equals(""))
@@ -59,7 +67,7 @@
// Compute query
int queryStart = currentPage * numberOfResults;
- GGQuery query = new GGQuery(queryStart, numberOfResults, catTerm, queryTerm,
request.getLocale());
+ GGQuery query = new GGQuery(queryStart, numberOfResults + 1, catTerm, queryTerm,
request.getLocale());
List queryResults = provider.search(query);
String ggPickMethod = request.getParameter("gg_pick_method");
@@ -121,10 +129,11 @@
<div id="<p:namespace/>directory_search_div" style="display:
<%= !uriPickMethod ? "block" : "none" %>;">
<form action="<p:renderURL></p:renderURL>"
method="post">
- <input type="text" name="query" value="<%= queryTerm
%>" class="portlet-form-field"/>
+ <input type="text" name="query" value="<%= queryTerm
%>" class="portlet-form-field"/>
<select name="cat" class="portlet-form-field">
<option value=""> </option>
<%
+ // Category dropdown
for (Iterator i = provider.getCategories().iterator();
i.hasNext();)
{
GGWidgetCategoryInfo cat = (GGWidgetCategoryInfo)i.next();
@@ -135,7 +144,18 @@
<%
}
%>
+ </select>
+ <select name="numberOfResults"
class="portlet-form-field">
+ <%
+ // Number of results dropdown
+ for(int i = 5; i <= 25; i = i + 5)
+ {
+ boolean selected = i == numberOfResults;
+ %><option value="<%= i %>" <%= selected ?
"selected=\"selected\"" : "" %>><%= i
%></option><%
+ }
+ %>
</select>
+ <br/>
<input type="submit" value="Search Gadgets"
class="portlet-form-button"/>
</form>
@@ -144,21 +164,26 @@
<%
for (IteratorStatus i = new IteratorStatus(queryResults.iterator());
i.hasNext();)
{
+ if ( (i.getIndex() + 1) >= numberOfResults)
+ {
+ break;
+ }
+
DirectoryQueryResultEntry result = (DirectoryQueryResultEntry) i.next();
boolean selected = selWidget != null &&
selWidget.getId().equals(result.getURL().toString());
PortletURL selectURL = renderResponse.createActionURL();
-
+
// Set parameters for selection
selectURL.setParameter("content.action.select",
"content.action.select");
selectURL.setParameter("content.uri",
result.getURL().toString());
// Set default parametrization state
- // TODO ? really needed
// Propagage search nav state
selectURL.setParameter("cat", catTerm);
selectURL.setParameter("query", queryTerm);
selectURL.setParameter("currentPage",
String.valueOf(currentPage));
+ selectURL.setParameter("numberOfResults",
String.valueOf(numberOfResults));
//
String rowClass = selected ? "portlet-section-selected" :
(i.getIndex() % 2 == 0 ? "portlet-section-body" :
"portlet-section-alternate");
@@ -181,6 +206,7 @@
PortletURL prevURL = renderResponse.createRenderURL();
prevURL.setParameter("cat", catTerm);
prevURL.setParameter("query", queryTerm);
+ prevURL.setParameter("numberOfResults",
String.valueOf(numberOfResults));
String prevPage = String.valueOf(currentPage - 1);
@@ -191,11 +217,12 @@
</td>
<td style="text-align: right;">
<% // next page
- if ( queryResults.size() >= numberOfResults )
+ if ( queryResults.size() > numberOfResults )
{
PortletURL nextURL = renderResponse.createRenderURL();
nextURL.setParameter("cat", catTerm);
nextURL.setParameter("query", queryTerm);
+ nextURL.setParameter("numberOfResults",
String.valueOf(numberOfResults));
String nextPage = String.valueOf(currentPage + 1);
@@ -223,6 +250,7 @@
selectURL.setParameter("cat", catTerm);
selectURL.setParameter("query", queryTerm);
selectURL.setParameter("currentPage", String.valueOf(currentPage));
+ selectURL.setParameter("numberOfResults",
String.valueOf(numberOfResults));
//propagate visable div
if (uriPickMethod)