Checkpoint of code/config for the action config definition and externalisation task

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2544 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2006-03-13 18:07:35 +00:00
parent 5659614fff
commit 45135f13eb
10 changed files with 637 additions and 26 deletions

View File

@@ -9,6 +9,7 @@
<value>classpath:alfresco/web-client-config.xml</value> <value>classpath:alfresco/web-client-config.xml</value>
<value>classpath:alfresco/web-client-config-properties.xml</value> <value>classpath:alfresco/web-client-config-properties.xml</value>
<value>classpath:alfresco/web-client-config-navigation.xml</value> <value>classpath:alfresco/web-client-config-navigation.xml</value>
<value>classpath:alfresco/web-client-config-actions.xml</value>
<value>classpath:alfresco/extension/web-client-config-custom.xml</value> <value>classpath:alfresco/extension/web-client-config-custom.xml</value>
</list> </list>
</constructor-arg> </constructor-arg>

View File

@@ -0,0 +1,126 @@
<alfresco-config>
<config evaluator="string-compare" condition="Actions">
<actions>
<!-- each action is defined individually and then referenced in an 'action-group' block
via an 'idref' attribute specifing the action definition to use -->
<!-- full example -->
<action id="example1_edit_doc_http">
<!-- a list of permissions to evaluate action against before checking other preconditions -->
<permissions>
<!-- each permission can be an Allow or Deny check -->
<permission allow="true">Write</permission>
<permission allow="false">AddChildren</permission>
</permissions>
<!-- the evaluator is a class implementing the org.alfresco.web.action.ActionEvaluator contract,
it will be executed passing in the context for the outer action component -->
<evaluator>org.alfresco.web.action.evaluator.EditDocHttpEvaluator</evaluator>
<!-- label and tooltip can be provided as text or preferable I18N message Id -->
<label>Edit</label>
<label-msg>edit</label-msg>
<tooltip>My Tooltip</tooltip>
<tooltip-msg>tooltip</tooltip-msg>
<!-- various presentation attributes - generally it is better to provide these as part of the
parent 'actions' definition to give a consistent look-and-feel to a group of actions -->
<show-link>false</show-link>
<style>padding:4px</style>
<style-class>inlineAction</style-class>
<image>/images/icons/edit_icon.gif</image>
<!-- action, ActionLister, href and target action attributes supported -->
<actionListener>#{CheckinCheckoutBean.editFile}</actionListener>
<action>editDocument</action>
<href>http://...</href>
<target>new</target>
<!-- params specify the f:param tags to be generated as children of the action component -->
<!-- it is assumed that the context object for the action will have an appropriate getter method
to reflect the value of the param e.g. getId() for a param value of "id" -->
<params>
<param name="id">id</param>
</params>
</action>
<!-- Edit document action to open using normal HTTP access or inline Edit if set -->
<action id="edit_doc_http">
<permissions>
<permission allow="true">Write</permission>
</permissions>
<evaluator>org.alfresco.web.action.evaluator.EditDocHttpEvaluator</evaluator>
<label-msg>edit</label-msg>
<image>/images/icons/edit_icon.gif</image>
<action-listener>#{CheckinCheckoutBean.editFile}</action-listener>
<params>
<param name="id">id</param>
</params>
<!-- can also specify style, class etc. but this is better done in 'actions' element -->
</action>
<!-- Edit document using WebDav access -->
<action id="edit_doc_webdav">
<permissions>
<permission allow="true">Write</permission>
</permissions>
<evaluator>org.alfresco.web.action.evaluator.EditDocWebDavEvaluator</evaluator>
<label-msg>edit</label-msg>
<image>/images/icons/edit_icon.gif</image>
<!-- NOTE: uses the special 'actioncontext' object supplied by the parent actions component -->
<onclick>javascript:openDoc('#{actioncontext.webdavUrl}');</onclick>
</action>
<!-- Edit document using CIFS access -->
<action id="edit_doc_cifs">
<permissions>
<permission allow="true">Write</permission>
</permissions>
<evaluator>org.alfresco.web.action.evaluator.EditDocCIFSEvaluator</evaluator>
<label-msg>edit</label-msg>
<image>/images/icons/edit_icon.gif</image>
<!-- NOTE: uses the special 'actioncontext' object supplied by the parent actions component -->
<href>#{actioncontext.cifsPath}</href>
<target>cifs</target>
</action>
<!-- Checkout document -->
<!--<action id="checkout_doc">
<permissions>
<permission allow="true">CheckOut</permission>
</permissions>
<evaluator>org.alfresco.web.action.evaluator.CheckoutDocEvaluator</evaluator>
<label-msg>checkout</label-msg>
<image>/images/icons/CheckOut_icon.gif</image>
<action-listener>#{CheckinCheckoutBean.setupContentAction}</action-listener>
<action>checkoutFile</action>
<params>
<param name="id">id</param>
</params>
</action>-->
<!-- the 'actions' elements define unique blocks of actions that reference the actions
as defined above and can override or supply display elements for the group of actions -->
<!-- the element is allow responsible for making the context Node object available with name
of 'actioncontext' so the actions can access it directly to get properties -->
<action-group id="document_browse">
<show-link>false</show-link>
<style-class>inlineAction</style-class>
<action idref="edit_doc_http" />
<action idref="edit_doc_webdav" />
<action idref="edit_doc_cifs" />
<action id="specific_checkout_doc">
<permissions>
<permission allow="true">CheckOut</permission>
</permissions>
<label-msg>checkout</label-msg>
<image>/images/icons/CheckOut_icon.gif</image>
<action-listener>#{CheckinCheckoutBean.setupContentAction}</action-listener>
<action>checkoutFile</action>
</action>
</action-group>
</actions>
</config>
</alfresco-config>

View File

@@ -12,6 +12,7 @@
<element-reader element-name="languages" class="org.alfresco.web.config.LanguagesElementReader" /> <element-reader element-name="languages" class="org.alfresco.web.config.LanguagesElementReader" />
<element-reader element-name="advanced-search" class="org.alfresco.web.config.AdvancedSearchElementReader" /> <element-reader element-name="advanced-search" class="org.alfresco.web.config.AdvancedSearchElementReader" />
<element-reader element-name="views" class="org.alfresco.web.config.ViewsElementReader" /> <element-reader element-name="views" class="org.alfresco.web.config.ViewsElementReader" />
<element-reader element-name="actions" class="org.alfresco.web.config.ActionsElementReader" />
</element-readers> </element-readers>
</plug-ins> </plug-ins>

View File

@@ -895,10 +895,6 @@ public class BrowseBean implements IContextListener
{ {
editLinkType = Application.getClientConfig( editLinkType = Application.getClientConfig(
FacesContext.getCurrentInstance()).getEditLinkType(); FacesContext.getCurrentInstance()).getEditLinkType();
if (editLinkType == null)
{
editLinkType = "http";
}
} }
return editLinkType; return editLinkType;

View File

@@ -0,0 +1,231 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.web.config;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.config.ConfigElement;
import org.alfresco.config.ConfigException;
import org.alfresco.config.element.ConfigElementAdapter;
import org.alfresco.web.action.ActionEvaluator;
/**
* Action config element.
*
* @author Kevin Roast
*/
public class ActionsConfigElement extends ConfigElementAdapter
{
public static final String CONFIG_ELEMENT_ID = "actions";
private Map<String, ActionDefinition> actionDefs = new HashMap<String, ActionDefinition>(32, 1.0f);
private Map<String, ActionGroup> actionGroups = new HashMap<String, ActionGroup>(16, 1.0f);
/**
* Default constructor
*/
public ActionsConfigElement()
{
super(CONFIG_ELEMENT_ID);
}
/**
* @param name
*/
public ActionsConfigElement(String name)
{
super(name);
}
/**
* @see org.alfresco.config.element.ConfigElementAdapter#getChildren()
*/
public List<ConfigElement> getChildren()
{
throw new ConfigException("Reading the Actions config via the generic interfaces is not supported");
}
/**
* @see org.alfresco.config.element.ConfigElementAdapter#combine(org.alfresco.config.ConfigElement)
*/
public ConfigElement combine(ConfigElement configElement)
{
ActionsConfigElement existingElement = (ActionsConfigElement)configElement;
ActionsConfigElement combinedElement = new ActionsConfigElement();
//
// TODO: implement to allow override of config elements
//
return null;
}
/*package*/ void addActionDefinition(ActionDefinition actionDef)
{
actionDefs.put(actionDef.getId(), actionDef);
}
public ActionDefinition getActionDefinition(String id)
{
return actionDefs.get(id);
}
/*package*/ void addActionGroup(ActionGroup group)
{
actionGroups.put(group.getId(), group);
}
public ActionGroup getActionGroup(String id)
{
return actionGroups.get(id);
}
/**
* Simple class representing the definition of a UI action.
*
* @author Kevin Roast
*/
public static class ActionDefinition
{
public ActionDefinition(String id)
{
if (id == null || id.length() == 0)
{
throw new IllegalArgumentException("ActionDefinition ID is mandatory.");
}
this.id = id;
}
public String getId()
{
return id;
}
public void addAllowPermission(String permission)
{
if (permissionAllow == null)
{
permissionAllow = new ArrayList<String>(2);
}
permissionAllow.add(permission);
}
public void addDenyPermission(String permission)
{
if (permissionDeny == null)
{
permissionDeny = new ArrayList<String>(1);
}
permissionDeny.add(permission);
}
public List<String> getAllowPermissions()
{
return permissionAllow;
}
public List<String> getDenyPermissions()
{
return permissionDeny;
}
public void addParam(String name, String value)
{
if (params == null)
{
params = new HashMap<String, String>(1, 1.0f);
}
params.put(name, value);
}
public Map<String, String> getParams()
{
return params;
}
private String id;
private List<String> permissionAllow = null;
private List<String> permissionDeny = null;
private Map<String, String> params = null;
public ActionEvaluator Evaluator = null;
public String Label;
public String LabelMsg;
public String Tooltip;
public String TooltipMsg;
public boolean ShowLink;
public String Style;
public String StyleClass;
public String Image;
public String ActionListener;
public String Action;
public String Href;
public String Target;
}
/**
* Simple class representing a group of UI actions.
*
* @author Kevin Roast
*/
public static class ActionGroup implements Iterable<ActionDefinition>
{
public ActionGroup(String id)
{
if (id == null || id.length() == 0)
{
throw new IllegalArgumentException("ActionGroup ID is mandatory.");
}
this.id = id;
}
public String getId()
{
return id;
}
public void addAction(ActionDefinition actionDef)
{
actions.put(actionDef.getId(), actionDef);
}
/**
* @return Iterator to the ActionDefinition objects referenced by this group
*/
public Iterator<ActionDefinition> iterator()
{
return actions.values().iterator();
}
private String id;
/** the action definitions, we use a linked hashmap to ensure we do not have more
than one action with the same Id and that the insertion order is preserved */
private Map<String, ActionDefinition> actions = new LinkedHashMap(8, 1.0f);
public boolean ShowLink;
public String Style;
public String StyleClass;
}
}

View File

@@ -0,0 +1,263 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.web.config;
import java.util.Iterator;
import org.alfresco.config.ConfigElement;
import org.alfresco.config.ConfigException;
import org.alfresco.config.xml.elementreader.ConfigElementReader;
import org.alfresco.web.action.ActionEvaluator;
import org.alfresco.web.config.ActionsConfigElement.ActionDefinition;
import org.alfresco.web.config.ActionsConfigElement.ActionGroup;
import org.dom4j.Element;
/**
* Config Element Reader for the "Action" config blocks.
*
* @author Kevin Roast
*/
public class ActionsElementReader implements ConfigElementReader
{
public static final String ELEMENT_ACTION = "action";
public static final String ELEMENT_ACTIONGROUP = "action-group";
public static final String ELEMENT_PERMISSIONS = "permissions";
public static final String ELEMENT_PERMISSION = "permission";
public static final String ELEMENT_EVALUATOR = "evaluator";
public static final String ELEMENT_LABEL = "label";
public static final String ELEMENT_LABELMSG = "label-msg";
public static final String ELEMENT_TOOLTIP = "tooltip";
public static final String ELEMENT_TOOLTIPMSG = "tooltip-msg";
public static final String ELEMENT_SHOWLINK = "show-link";
public static final String ELEMENT_STYLE = "style";
public static final String ELEMENT_STYLECLASS = "style-class";
public static final String ELEMENT_IMAGE = "image";
public static final String ELEMENT_ACTIONLISTENER = "action-listener";
public static final String ELEMENT_HREF = "href";
public static final String ELEMENT_TARGET = "target";
public static final String ELEMENT_PARAMS = "params";
public static final String ELEMENT_PARAM = "param";
public static final String ATTRIBUTE_ID = "id";
public static final String ATTRIBUTE_IDREF = "idref";
public static final String ATTRIBUTE_NAME = "name";
public static final String ATTRIBUTE_ALLOW = "allow";
/**
* @see org.alfresco.config.xml.elementreader.ConfigElementReader#parse(org.dom4j.Element)
*/
@SuppressWarnings("unchecked")
public ConfigElement parse(Element element)
{
ActionsConfigElement configElement = new ActionsConfigElement();
if (element != null)
{
if (ActionsConfigElement.CONFIG_ELEMENT_ID.equals(element.getName()) == false)
{
throw new ConfigException("ActionsElementReader can only parse config elements of type 'Actions'");
}
Iterator<Element> actionItr = element.elementIterator(ELEMENT_ACTION);
while (actionItr.hasNext())
{
// work on each 'action' element in turn
Element actionElement = actionItr.next();
// parse the action definition for the element
ActionDefinition actionDef = parseActionDefinition(actionElement);
// add our finished action def to the map of all actions
configElement.addActionDefinition(actionDef);
}
Iterator<Element> actionGroupItr = element.elementIterator(ELEMENT_ACTIONGROUP);
while (actionGroupItr.hasNext())
{
// work on each 'action-group' element in turn
Element groupElement = actionGroupItr.next();
String groupId = groupElement.attributeValue(ATTRIBUTE_ID);
if (groupId == null || groupId.length() == 0)
{
throw new ConfigException("'action-group' config element specified without mandatory 'id' attribute.");
}
// build a structure to represent the action group
ActionGroup actionGroup = new ActionGroup(groupId);
// loop round each action ref and add them to the list for this action group
Iterator<Element> actionRefItr = groupElement.elementIterator(ELEMENT_ACTION);
while (actionRefItr.hasNext())
{
Element actionRefElement = actionRefItr.next();
// look for an action referred to be Id - this is the common use-case
ActionDefinition def = null;
String idRef = actionRefElement.attributeValue(ATTRIBUTE_IDREF);
if (idRef != null && idRef.length() != 0)
{
// try to find the referenced action by Id
def = configElement.getActionDefinition(idRef);
if (def == null)
{
throw new ConfigException("Action group '" + groupId +
"' cannot find action definition referenced by '" + idRef + "'");
}
}
else
{
// look for an action defined directly rather than referenced by Id
String id = actionRefElement.attributeValue(ATTRIBUTE_ID);
if (id != null && id.length() != 0)
{
def = parseActionDefinition(actionRefElement);
}
}
if (def != null)
{
actionGroup.addAction(def);
}
}
// get simple string properties for the action group
actionGroup.Style = groupElement.elementTextTrim(ELEMENT_STYLE);
actionGroup.StyleClass = groupElement.elementTextTrim(ELEMENT_STYLECLASS);
if (groupElement.element(ELEMENT_SHOWLINK) != null)
{
actionGroup.ShowLink = Boolean.parseBoolean(groupElement.element(ELEMENT_SHOWLINK).getTextTrim());
}
// add the action group to the map of all action groups
configElement.addActionGroup(actionGroup);
}
}
return configElement;
}
/**
* Parse an ActionDefinition from the specific config element.
*
* @param actionElement The config element containing the action def
*
* @return The populated ActionDefinition
*/
public ActionDefinition parseActionDefinition(Element actionElement)
{
String actionId = actionElement.attributeValue(ATTRIBUTE_ID);
if (actionId == null || actionId.length() == 0)
{
throw new ConfigException("'action' config element specified without mandatory 'id' attribute.");
}
// build a structure to represent the action definition
ActionDefinition actionDef = new ActionDefinition(actionId);
// look for the permissions element - it can contain many permission
Element permissionsElement = actionElement.element(ELEMENT_PERMISSIONS);
if (permissionsElement != null)
{
// read and process each permission element
Iterator<Element> permissionItr = permissionsElement.elementIterator(ELEMENT_PERMISSION);
while (permissionItr.hasNext())
{
Element permissionElement = permissionItr.next();
boolean allow = true;
if (permissionElement.attributeValue(ATTRIBUTE_ALLOW) != null)
{
allow = Boolean.parseBoolean(permissionElement.attributeValue(ATTRIBUTE_ALLOW));
}
String permissionValue = permissionElement.getTextTrim();
if (allow)
{
actionDef.addAllowPermission(permissionValue);
}
else
{
actionDef.addDenyPermission(permissionValue);
}
}
}
// find and construct the specified evaluator class
Element evaluatorElement = actionElement.element(ELEMENT_EVALUATOR);
if (evaluatorElement != null)
{
Object evaluator;
String className = evaluatorElement.getTextTrim();
try
{
Class clazz = Class.forName(className);
evaluator = clazz.newInstance();
}
catch (Throwable err)
{
throw new ConfigException("Unable to construct action '" +
actionId + "' evaluator classname: " +className);
}
if (evaluator instanceof ActionEvaluator == false)
{
throw new ConfigException("Action '" + actionId + "' evaluator class '" +
className + "' does not implement ActionEvaluator interface.");
}
actionDef.Evaluator = (ActionEvaluator)evaluator;
}
// find any parameter values that the action requires
Element paramsElement = actionElement.element(ELEMENT_PARAMS);
if (paramsElement != null)
{
Iterator<Element> paramsItr = paramsElement.elementIterator(ELEMENT_PARAM);
while (paramsItr.hasNext())
{
Element paramElement = paramsItr.next();
String name = paramElement.attributeValue(ATTRIBUTE_NAME);
if (name == null || name.length() == 0)
{
throw new ConfigException("Action '" + actionId +
"' param does not have mandatory 'name' attribute.");
}
String value = paramElement.getTextTrim();
if (value == null || value.length() == 0)
{
throw new ConfigException("Action '" + actionId + "' param '" + name + "'" +
"' does not have a value.");
}
actionDef.addParam(name, value);
}
}
// get simple string properties for the action
actionDef.Label = actionElement.elementTextTrim(ELEMENT_LABEL);
actionDef.LabelMsg = actionElement.elementTextTrim(ELEMENT_LABELMSG);
actionDef.Tooltip = actionElement.elementTextTrim(ELEMENT_TOOLTIP);
actionDef.TooltipMsg = actionElement.elementTextTrim(ELEMENT_TOOLTIPMSG);
actionDef.Href = actionElement.elementTextTrim(ELEMENT_HREF);
actionDef.Target = actionElement.elementTextTrim(ELEMENT_TARGET);
actionDef.Action = actionElement.elementTextTrim(ELEMENT_ACTION);
actionDef.ActionListener = actionElement.elementTextTrim(ELEMENT_ACTIONLISTENER);
actionDef.Image = actionElement.elementTextTrim(ELEMENT_IMAGE);
actionDef.Style = actionElement.elementTextTrim(ELEMENT_STYLE);
actionDef.StyleClass = actionElement.elementTextTrim(ELEMENT_STYLECLASS);
if (actionElement.element(ELEMENT_SHOWLINK) != null)
{
actionDef.ShowLink = Boolean.parseBoolean(actionElement.element(ELEMENT_SHOWLINK).getTextTrim());
}
return actionDef;
}
}

View File

@@ -35,7 +35,7 @@ public class ClientConfigElement extends ConfigElementAdapter
private boolean shelfVisible = true; private boolean shelfVisible = true;
private int searchMinimum = 3; private int searchMinimum = 3;
private String helpUrl = null; private String helpUrl = null;
private String editLinkType = null; private String editLinkType = "http";
private String homeSpacePermission = null; private String homeSpacePermission = null;
/** /**

View File

@@ -62,10 +62,9 @@ public class UIActionLink extends UICommand
this.padding = (Integer)values[1]; this.padding = (Integer)values[1];
this.image = (String)values[2]; this.image = (String)values[2];
this.showLink = (Boolean)values[3]; this.showLink = (Boolean)values[3];
this.params = (Map)values[4]; this.href = (String)values[4];
this.href = (String)values[5]; this.tooltip = (String)values[5];
this.tooltip = (String)values[6]; this.target = (String)values[6];
this.target = (String)values[7];
} }
/** /**
@@ -73,16 +72,15 @@ public class UIActionLink extends UICommand
*/ */
public Object saveState(FacesContext context) public Object saveState(FacesContext context)
{ {
Object values[] = new Object[8]; Object values[] = new Object[7];
// standard component attributes are saved by the super class // standard component attributes are saved by the super class
values[0] = super.saveState(context); values[0] = super.saveState(context);
values[1] = this.padding; values[1] = this.padding;
values[2] = this.image; values[2] = this.image;
values[3] = this.showLink; values[3] = this.showLink;
values[4] = this.params; values[4] = this.href;
values[5] = this.href; values[5] = this.tooltip;
values[6] = this.tooltip; values[6] = this.target;
values[7] = this.target;
return (values); return (values);
} }
@@ -100,7 +98,7 @@ public class UIActionLink extends UICommand
{ {
if (this.params == null) if (this.params == null)
{ {
this.params = new HashMap<String, String>(3, 1.0f); this.params = new HashMap<String, String>(1, 1.0f);
} }
return this.params; return this.params;
} }
@@ -328,6 +326,6 @@ public class UIActionLink extends UICommand
/** the onclick handler */ /** the onclick handler */
private String onclick = null; private String onclick = null;
/** Map of child param name/values pairs */ /** Transient map of currently set param name/values pairs */
private Map<String, String> params = null; private Map<String, String> params = null;
} }

View File

@@ -27,16 +27,12 @@ import javax.faces.event.ActionEvent;
import org.alfresco.web.ui.common.Utils; import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.component.UIActionLink; import org.alfresco.web.ui.common.component.UIActionLink;
import org.alfresco.web.ui.common.component.UIMenu; import org.alfresco.web.ui.common.component.UIMenu;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/** /**
* @author kevinr * @author kevinr
*/ */
public class ActionLinkRenderer extends BaseRenderer public class ActionLinkRenderer extends BaseRenderer
{ {
private static Log logger = LogFactory.getLog(ActionLinkRenderer.class);
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Renderer implementation // Renderer implementation
@@ -55,8 +51,7 @@ public class ActionLinkRenderer extends BaseRenderer
// on the request which match our params and set them into the component // on the request which match our params and set them into the component
UIActionLink link = (UIActionLink)component; UIActionLink link = (UIActionLink)component;
Map<String, String> destParams = link.getParameterMap(); Map<String, String> destParams = link.getParameterMap();
destParams.clear(); Map<String, String> actionParams = getParameterComponents(link);
Map<String, String> actionParams = getParameterMap(link);
if (actionParams != null) if (actionParams != null)
{ {
for (String name : actionParams.keySet()) for (String name : actionParams.keySet())
@@ -122,7 +117,7 @@ public class ActionLinkRenderer extends BaseRenderer
{ {
// generate JavaScript to set a hidden form field and submit // generate JavaScript to set a hidden form field and submit
// a form which request attributes that we can decode // a form which request attributes that we can decode
linkBuf.append(Utils.generateFormSubmit(context, link, Utils.getActionHiddenFieldName(context, link), link.getClientId(context), getParameterMap(link))); linkBuf.append(Utils.generateFormSubmit(context, link, Utils.getActionHiddenFieldName(context, link), link.getClientId(context), getParameterComponents(link)));
} }
linkBuf.append('"'); linkBuf.append('"');
@@ -270,7 +265,7 @@ public class ActionLinkRenderer extends BaseRenderer
if (link.getHref() == null) if (link.getHref() == null)
{ {
buf.append("<a href='#' onclick=\""); buf.append("<a href='#' onclick=\"");
buf.append(Utils.generateFormSubmit(context, link, Utils.getActionHiddenFieldName(context, link), link.getClientId(context), getParameterMap(link))); buf.append(Utils.generateFormSubmit(context, link, Utils.getActionHiddenFieldName(context, link), link.getClientId(context), getParameterComponents(link)));
buf.append('"'); buf.append('"');
} }
else else

View File

@@ -83,13 +83,13 @@ public abstract class BaseRenderer extends Renderer
* *
* @return a Map of name/value pairs or null if none found * @return a Map of name/value pairs or null if none found
*/ */
protected static Map<String, String> getParameterMap(UIComponent component) protected static Map<String, String> getParameterComponents(UIComponent component)
{ {
Map<String, String> params = null; Map<String, String> params = null;
if (component.getChildCount() != 0) if (component.getChildCount() != 0)
{ {
params = new HashMap<String, String>(3, 1.0f); params = new HashMap<String, String>(component.getChildCount(), 1.0f);
for (Iterator i=component.getChildren().iterator(); i.hasNext(); /**/) for (Iterator i=component.getChildren().iterator(); i.hasNext(); /**/)
{ {
UIComponent child = (UIComponent)i.next(); UIComponent child = (UIComponent)i.next();