Author: julien(a)jboss.com
Date: 2007-02-28 17:10:14 -0500 (Wed, 28 Feb 2007)
New Revision: 6472
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/portlet/management/InstanceManagerBean.java
trunk/core-admin/src/main/org/jboss/portal/core/portlet/management/PortletManagerBean.java
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsp/management/instances.xhtml
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsp/management/portlets.xhtml
Log:
pagination for portlets
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/portlet/management/InstanceManagerBean.java
===================================================================
---
trunk/core-admin/src/main/org/jboss/portal/core/portlet/management/InstanceManagerBean.java 2007-02-28
21:59:59 UTC (rev 6471)
+++
trunk/core-admin/src/main/org/jboss/portal/core/portlet/management/InstanceManagerBean.java 2007-02-28
22:10:14 UTC (rev 6472)
@@ -96,7 +96,14 @@
/** . */
private AbstractAuthorizationBean auth = new AuthorizationBean();
+ /** . */
+ private final int paginationSize = 10;
+ public int getPaginationSize()
+ {
+ return paginationSize;
+ }
+
public int getSelectedFrom()
{
return selectedFrom;
@@ -209,7 +216,7 @@
// }
//
- int to = Math.min(selectedFrom + 5, instances.size());
+ int to = Math.min(selectedFrom + 10, instances.size());
//
return instances.subList(selectedFrom, to);
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/portlet/management/PortletManagerBean.java
===================================================================
---
trunk/core-admin/src/main/org/jboss/portal/core/portlet/management/PortletManagerBean.java 2007-02-28
21:59:59 UTC (rev 6471)
+++
trunk/core-admin/src/main/org/jboss/portal/core/portlet/management/PortletManagerBean.java 2007-02-28
22:10:14 UTC (rev 6472)
@@ -94,30 +94,26 @@
private FederatingPortletInvoker federatingPortletInvoker;
/** . */
- private String sortColumn;
+ private int selectedFrom;
- private boolean sortAscending;
+ /** . */
+ private final int paginationSize = 10;
- public String getSortColumn()
+ public int getPaginationSize()
{
- return sortColumn;
+ return paginationSize;
}
- public void setSortColumn(String sortColumn)
+ public int getSelectedFrom()
{
- this.sortColumn = sortColumn;
+ return selectedFrom;
}
- public boolean getSortAscending()
+ public void setSelectedFrom(int selectedFrom)
{
- return sortAscending;
+ this.selectedFrom = selectedFrom;
}
- public void setSortAscending(boolean sortAscending)
- {
- this.sortAscending = sortAscending;
- }
-
public RoleModule getRoleModule()
{
return roleModule;
@@ -199,42 +195,47 @@
this.federatingPortletInvoker = federatingPortletInvoker;
}
+ public PreferencesBean getSelectedPreferences()
+ {
+ return selectedPreferences;
+ }
+
public Collection getPortlets()
{
- List portlets = Collections.EMPTY_LIST;
try
{
- portlets = new ArrayList(getPortletInvoker().getPortlets());
+ List portlets = new ArrayList(getPortletInvoker().getPortlets());
+
+ //
+ int to = Math.min(selectedFrom + 10, portlets.size());
+
+ //
+ return portlets.subList(selectedFrom, to);
}
catch (PortletInvokerException e)
{
log.warn("Couldn't access portlet invoker. Portlets won't be
listed.\nReason:\n\t" + e.getLocalizedMessage());
+ return Collections.EMPTY_LIST;
}
+ }
+ public int getPortletCount()
+ {
try
{
- sortPortlets(portlets, sortColumn, sortAscending);
+ return getPortletInvoker().getPortlets().size();
}
- catch (Exception e)
+ catch (PortletInvokerException e)
{
- log.warn("Error during sorting portlets list");
+ return 0;
}
-
- return portlets;
}
- // ****************
-
public DomainConfigurator getDomainConfigurator()
{
return
authorizationDomainRegistry.getDomain("portlet").getConfigurator();
}
- public String[] getToto()
- {
- return new String[]{"1", "2", "3"};
- }
-
public AbstractAuthorizationBean getAuth()
{
return auth;
@@ -262,17 +263,20 @@
}
}
- public String selectPortlet()
+ public void selectPortlet()
{
FacesContext ctx = FacesContext.getCurrentInstance();
selectedPortletId =
(String)ctx.getExternalContext().getRequestParameterMap().get("id");
selectedPlugin =
(String)ctx.getExternalContext().getRequestParameterMap().get("plugin");
- return "portlets";
+ selectedFrom = 0; // Could we guess the index of the portlet in the list ?
}
- public PreferencesBean getSelectedPreferences()
+ public void selectFrom()
{
- return selectedPreferences;
+ Map pmap =
FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
+ selectedFrom = Integer.parseInt((String)pmap.get("from"));
+ selectedPlugin = null;
+ selectedPortletId = null;
}
/** Refresh the selected prefs if they are available. */
@@ -280,53 +284,58 @@
{
selectedPreferences = null;
- // Get user locale
- FacesContext ctx = FacesContext.getCurrentInstance();
- Locale locale = ctx.getExternalContext().getRequestLocale();
+ //
+ if ("preferences".equals(selectedPlugin))
+ {
+ // Get user locale
+ FacesContext ctx = FacesContext.getCurrentInstance();
+ Locale locale = ctx.getExternalContext().getRequestLocale();
- // Get portlet
- Portlet portlet = getSelectedPortlet();
+ // Get portlet
+ Portlet portlet = getSelectedPortlet();
- if (portlet != null)
- {
- // Get preferences info
- PreferencesInfo prefsInfo = portlet.getInfo().getPreferences();
-
- // If the portlet has preferences info then we display them
- if (prefsInfo != null)
+ //
+ if (portlet != null)
{
- RowSetModel model = new RowSetModel(null, prefsInfo.getKeys().size());
- model.setMutable(false);
+ // Get preferences info
+ PreferencesInfo prefsInfo = portlet.getInfo().getPreferences();
- //
- int index = 0;
- for (Iterator i = prefsInfo.getKeys().iterator(); i.hasNext(); index++)
+ // If the portlet has preferences info then we display them
+ if (prefsInfo != null)
{
- String key = (String)i.next();
+ RowSetModel model = new RowSetModel(null, prefsInfo.getKeys().size());
+ model.setMutable(false);
//
- PreferenceInfo prefs = prefsInfo.getPreference(key);
- Value value = new StringValue("not available");
- Boolean readOnly = prefs.isReadOnly();
+ int index = 0;
+ for (Iterator i = prefsInfo.getKeys().iterator(); i.hasNext(); index++)
+ {
+ String key = (String)i.next();
- //
- Row row = model.getRow(index);
+ //
+ PreferenceInfo prefs = prefsInfo.getPreference(key);
+ Value value = new StringValue("not available");
+ Boolean readOnly = prefs.isReadOnly();
- //
- Cell cell = row.getCell();
- cell.setHandback("" + i);
- cell.setValue(value.asStringArray());
+ //
+ Row row = model.getRow(index);
+ //
+ Cell cell = row.getCell();
+ cell.setHandback("" + i);
+ cell.setValue(value.asStringArray());
+
+ //
+ row.setHandback(key);
+ row.setKey(key);
+ row.setName(prefs.getDisplayName().getString(locale, true));
+ row.setReadOnly(Boolean.TRUE.equals(readOnly));
+ row.setValue(value.asStringArray());
+ }
+
//
- row.setHandback(key);
- row.setKey(key);
- row.setName(prefs.getDisplayName().getString(locale, true));
- row.setReadOnly(Boolean.TRUE.equals(readOnly));
- row.setValue(value.asStringArray());
+ selectedPreferences = new PreferencesBean(model);
}
-
- //
- selectedPreferences = new PreferencesBean(model);
}
}
}
Modified:
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsp/management/instances.xhtml
===================================================================
---
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsp/management/instances.xhtml 2007-02-28
21:59:59 UTC (rev 6471)
+++
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsp/management/instances.xhtml 2007-02-28
22:10:14 UTC (rev 6472)
@@ -48,7 +48,7 @@
</tbody>
</table>
<ul class="pagination">
- <c:forEach begin="0" end="#{instancemgr.instanceCount}"
step="5" var="index">
+ <c:forEach begin="0" end="#{instancemgr.instanceCount}"
step="#{instancemgr.paginationSize}" var="index">
<li class="#{index == instancemgr.selectedFrom ? 'selected' :
''}">
<h:commandLink
action="#{instancemgr.selectFrom}"><f:param name="from"
value="#{index}"/><h:outputText
value="#{index}"/></h:commandLink>
</li>
Modified:
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsp/management/portlets.xhtml
===================================================================
---
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsp/management/portlets.xhtml 2007-02-28
21:59:59 UTC (rev 6471)
+++
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsp/management/portlets.xhtml 2007-02-28
22:10:14 UTC (rev 6472)
@@ -61,6 +61,13 @@
</c:forEach>
</tbody>
</table>
+ <ul class="pagination">
+ <c:forEach begin="0" end="#{portletmgr.portletCount}"
step="#{portletmgr.paginationSize}" var="index">
+ <li class="#{index == portletmgr.selectedFrom ? 'selected'
: ''}">
+ <h:commandLink
action="#{portletmgr.selectFrom}"><f:param name="from"
value="#{index}"/><h:outputText
value="#{index}"/></h:commandLink>
+ </li>
+ </c:forEach>
+ </ul>
</h:form>
<c:if test="#{portletmgr.selectedPortlet != null}">
Show replies by date