Author: chris.laprun(a)jboss.com
Date: 2008-12-17 15:38:08 -0500 (Wed, 17 Dec 2008)
New Revision: 12399
Added:
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/util/JSFFunctor.java
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/build.xml
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/InstanceManagerBean.java
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/jsf/instances.xhtml
Log:
- JBPORTAL-2264, JBPORTAL-2259: Added id sanitization before using them as HTML ids, users
can still use names
with . or spaces... Display performance of instance list seems to suffer from it so
should investigate
optimization.
Modified: branches/JBoss_Portal_Branch_2_7/core-admin/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-admin/build.xml 2008-12-17 19:44:06 UTC (rev
12398)
+++ branches/JBoss_Portal_Branch_2_7/core-admin/build.xml 2008-12-17 20:38:08 UTC (rev
12399)
@@ -149,10 +149,10 @@
<pathelement location="${project.tools}/lib/explode.jar"/>
<path refid="apache.ant.classpath"/>
</path>
- <taskdef
- name="explode"
- classname="org.jboss.portal.common.ant.Explode"
- classpathref="explode.task.classpath"/>
+ <taskdef
+ name="explode"
+ classname="org.jboss.portal.common.ant.Explode"
+ classpathref="explode.task.classpath"/>
</target>
<!--+====================================================================+-->
@@ -189,7 +189,7 @@
<!-- portal-admin.war -->
<copy todir="${build.resources}/portal-admin-war/WEB-INF/lib">
- <fileset dir="${glassfish.jstl.lib}"
includes="jstl.jar"/>
+ <fileset dir="${glassfish.jstl.lib}"
includes="jstl.jar"/>
<fileset dir="${facelets.facelets.lib}"
includes="jsf-facelets.jar"/>
<fileset dir="${jboss/portlet.bridge.lib}"
includes="portletbridge-api.jar"/>
<fileset dir="${jboss/portlet.bridge.lib}"
includes="portletbridge-impl.jar"/>
@@ -197,20 +197,20 @@
<fileset dir="${richfaces.richfaces.lib}"
includes="richfaces-impl.jar"/>
<fileset dir="${richfaces.richfaces.lib}"
includes="richfaces-ui.jar"/>
<fileset dir="${build.lib}"
includes="portal-core-admin-lib.jar"/>
- <fileset dir="${jboss.portal-faces.root}/lib"
includes="portal-faces-lib.jar"/>
+ <fileset dir="${jboss.portal-faces.root}/lib"
includes="portal-faces-lib.jar"/>
<fileset dir="${apache.beanutils.lib}"
includes="commons-beanutils.jar"/>
<fileset dir="${apache.digester.lib}"
includes="commons-digester.jar"/>
<fileset dir="${apache.lang.lib}"
includes="commons-lang.jar"/>
- </copy>
- <copy todir="${build.resources}/portal-admin-war">
- <fileset dir="${source.bin}/portal-admin-war"/>
- </copy>
+ </copy>
+ <copy todir="${build.resources}/portal-admin-war">
+ <fileset dir="${source.bin}/portal-admin-war"/>
+ </copy>
<!-- portal-admin.sar -->
<copy todir="${build.resources}/portal-admin.sar">
<fileset dir="${build.resources}/portal-admin-sar"/>
</copy>
<copy todir="${build.resources}/portal-admin.sar/lib">
- <fileset dir="${jboss.portal-faces.root}/lib"
includes="portal-faces-loader-lib.jar"/>
+ <fileset dir="${jboss.portal-faces.root}/lib"
includes="portal-faces-loader-lib.jar"/>
</copy>
<copy
todir="${build.resources}/portal-admin.sar/portal-admin.war">
@@ -285,8 +285,8 @@
<target name="deploy-ha"
description="Deploy."
depends="output">
- <require file="${jboss.home}/server/${portal-ha.deploy.dir}"/>
- <copy file="${build.lib}/portal-admin.sar"
todir="${jboss.home}/server/${portal-ha.deploy.dir}"
- overwrite="true"/>
- </target>
+ <require file="${jboss.home}/server/${portal-ha.deploy.dir}"/>
+ <copy file="${build.lib}/portal-admin.sar"
todir="${jboss.home}/server/${portal-ha.deploy.dir}"
+ overwrite="true"/>
+ </target>
</project>
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/InstanceManagerBean.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/InstanceManagerBean.java 2008-12-17
19:44:06 UTC (rev 12398)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/InstanceManagerBean.java 2008-12-17
20:38:08 UTC (rev 12399)
@@ -23,6 +23,7 @@
package org.jboss.portal.core.admin.ui;
import org.jboss.portal.Mode;
+import org.jboss.portal.faces.util.JSFFunctor;
import org.jboss.portal.core.model.instance.Instance;
import org.jboss.portal.core.model.instance.InstanceContainer;
import org.jboss.portal.core.model.instance.InstanceDefinition;
@@ -105,6 +106,20 @@
/** . */
private AuthorizationBean auth = new InstanceAuthorizationBean();
+ /** Removes white spaces from identifiers so that we can assign them to HTML id
attributes. */
+ private JSFFunctor idSanitizer = new JSFFunctor()
+ {
+ public Object get(Object parameter)
+ {
+ if (parameter instanceof String)
+ {
+ String id = (String)parameter;
+ return id.replaceAll("\\W|\\.", "_");
+ }
+ return null;
+ }
+ };
+
// Services accessors
public RoleModule getRoleModule()
@@ -137,6 +152,16 @@
this.domainConfigurator = domainConfigurator;
}
+ /**
+ * Functor acccess to sanitize identifiers.
+ *
+ * @return
+ */
+ public JSFFunctor getIdSanitizer()
+ {
+ return idSanitizer;
+ }
+
// Navigational state accessor
public int getPaginationSize()
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/jsf/instances.xhtml
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/jsf/instances.xhtml 2008-12-17
19:44:06 UTC (rev 12398)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/jsf/instances.xhtml 2008-12-17
20:38:08 UTC (rev 12399)
@@ -41,7 +41,8 @@
<td>
<img src="#{instance.portlet.smallIconLocation}"
alt="icon" align="middle"
style="margin:0 4px 0 0"/>
- <h:commandLink id="#{instance.id}"
action="#{instancemgr.selectInstance}">
+ <h:commandLink
id="#{instancemgr.idSanitizer[instance.id]}"
+
action="#{instancemgr.selectInstance}">
<h:outputText value="#{instance.id}"/>
<f:param name="id"
value="#{instance.id}"/>
<f:param name="plugin"
value="info"/>
@@ -53,19 +54,21 @@
<td>
<h:panelGrid columns="7"
cellpadding="0" cellspacing="0" border="0">
<h:commandLink
action="#{instancemgr.selectInstance}" styleClass="actionSecurity"
- id="security-#{instance.id}">
+
id="security-#{instancemgr.idSanitizer[instance.id]}">
<f:param name="id"
value="#{instance.id}"/>
<f:param name="plugin"
value="security"/>
#{bundle.SECURITY}
</h:commandLink>
<h:commandLink rendered="#{!
empty(instancemgr.selectedInstancesPrefs[instance.id])}"
- id="preference-#{instance.id}"
action="#{instancemgr.selectInstance}"
+
id="preference-#{instancemgr.idSanitizer[instance.id]}"
+
action="#{instancemgr.selectInstance}"
styleClass="actionPreferences">
<f:param name="id"
value="#{instance.id}"/>
<f:param name="plugin"
value="preferences"/>
#{bundle.PREFERENCES}
</h:commandLink>
- <h:commandLink action="confirmDeleteInstance"
id="delete-#{instance.id}"
+ <h:commandLink action="confirmDeleteInstance"
+
id="delete-#{instancemgr.idSanitizer[instance.id]}"
styleClass="actionDeleteInstance"
actionListener="#{instancemgr.selectInstance}">
<f:param name="id"
value="#{instance.id}"/>
Added:
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/util/JSFFunctor.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/util/JSFFunctor.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/util/JSFFunctor.java 2008-12-17
20:38:08 UTC (rev 12399)
@@ -0,0 +1,100 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, 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.faces.util;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.Collection;
+
+/**
+ * Allows to call a parameterized function in JSF EL expressions. See <a
href="http://wiki.apache.org/myfaces/Parameters_In_EL_Functions"...
+ * for more details. A better alternative would be to use JBoss-EL if it was available
from the standard JBoss
+ * repository...
+ *
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public abstract class JSFFunctor implements Map
+{
+ public int size()
+ {
+ return 0;
+ }
+
+ public boolean isEmpty()
+ {
+ return false;
+ }
+
+ public boolean containsKey(Object key)
+ {
+ return false;
+ }
+
+ public boolean containsValue(Object value)
+ {
+ return false;
+ }
+
+ /**
+ * This is where the functor works. Subclasses need to implement the function logic
here, the parameter being the
+ * specified parameter.
+ *
+ * @param parameter the value that will be used to compute the result of the function
we want to implement
+ * @return the result of the funtion for the specified value
+ */
+ public abstract Object get(Object parameter);
+
+ public Object put(Object key, Object value)
+ {
+ return null;
+ }
+
+ public Object remove(Object key)
+ {
+ return null;
+ }
+
+ public void putAll(Map m)
+ {
+ }
+
+ public void clear()
+ {
+ }
+
+ public Set keySet()
+ {
+ return null;
+ }
+
+ public Collection values()
+ {
+ return null;
+ }
+
+ public Set entrySet()
+ {
+ return null;
+ }
+}