Merge V1.4 to HEAD

- Ignored Enterprise-specific changes
   svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@3701 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@3703 .
   svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@3704 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@3705 .
   svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@3707 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@3876 .
   svn revert root\projects\web-client\source\web\jsp\admin\admin-console.jsp


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3879 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2006-09-21 23:35:51 +00:00
parent 35594dadf8
commit 7df3c602a1
54 changed files with 1634 additions and 675 deletions

View File

@@ -111,165 +111,175 @@ public class ActionLinkRenderer extends BaseRenderer
*/
private String renderActionLink(FacesContext context, UIActionLink link)
{
Map attrs = link.getAttributes();
StringBuilder linkBuf = new StringBuilder(256);
// if there is no value for the link there will be no visible output
// on the page so don't bother rendering anything
String linkHtml = "";
Object linkValue = link.getValue();
if (link.getHref() == null)
if (linkValue != null)
{
linkBuf.append("<a href='#' onclick=\"");
Map attrs = link.getAttributes();
StringBuilder linkBuf = new StringBuilder(256);
// if we have an overriden onclick add that
if (link.getOnclick() != null)
if (link.getHref() == null)
{
linkBuf.append(link.getOnclick());
}
else
{
// generate JavaScript to set a hidden form field and submit
// a form which request attributes that we can decode
linkBuf.append(Utils.generateFormSubmit(context, link, Utils.getActionHiddenFieldName(context, link), link.getClientId(context), getParameterComponents(link)));
}
linkBuf.append('"');
}
else
{
String href = link.getHref();
// prefix the web context path if required
linkBuf.append("<a href=\"");
if (href.startsWith("/"))
{
linkBuf.append(context.getExternalContext().getRequestContextPath());
}
linkBuf.append(href);
// append arguments if specified
Map<String, String> actionParams = getParameterComponents(link);
if (actionParams != null)
{
boolean first = (href.indexOf('?') == -1);
for (String name : actionParams.keySet())
linkBuf.append("<a href='#' onclick=\"");
// if we have an overriden onclick add that
if (link.getOnclick() != null)
{
String paramValue = actionParams.get(name);
if (first)
{
linkBuf.append('?');
first = false;
}
else
{
linkBuf.append('&');
}
try
{
linkBuf.append(name).append("=").append(URLEncoder.encode(paramValue, "UTF-8"));
}
catch (UnsupportedEncodingException err)
{
// if this happens we have bigger problems than a missing URL parameter...!
}
}
}
linkBuf.append('"');
// output href 'target' attribute if supplied
if (link.getTarget() != null)
{
linkBuf.append(" target=\"")
.append(link.getTarget())
.append("\"");
}
}
if (attrs.get("style") != null)
{
linkBuf.append(" style=\"")
.append(attrs.get("style"))
.append('"');
}
if (attrs.get("styleClass") != null)
{
linkBuf.append(" class=")
.append(attrs.get("styleClass"));
}
if (link.getTooltip() != null)
{
linkBuf.append(" title=\"")
.append(Utils.encode(link.getTooltip()))
.append('"');
}
linkBuf.append('>');
StringBuilder buf = new StringBuilder(350);
if (link.getImage() != null)
{
int padding = link.getPadding();
if (padding != 0)
{
// TODO: make this width value a property!
buf.append("<table cellspacing=0 cellpadding=0><tr><td width=16>");
}
if (link.getShowLink() == false)
{
buf.append(linkBuf.toString());
}
// TODO: allow configuring of alignment attribute
buf.append(Utils.buildImageTag(context, link.getImage(), (String)link.getValue(), "absmiddle"));
if (link.getShowLink() == false)
{
buf.append("</a>");
}
else
{
if (padding != 0)
{
buf.append("</td><td style=\"padding:")
.append(padding)
.append("px\">");
linkBuf.append(link.getOnclick());
}
else
{
// TODO: add horizontal spacing as component property
buf.append("<span style='padding-left:2px");
// text next to an image may need alignment
if (attrs.get("verticalAlign") != null)
{
buf.append(";vertical-align:")
.append(attrs.get("verticalAlign"));
}
buf.append("'>");
// generate JavaScript to set a hidden form field and submit
// a form which request attributes that we can decode
linkBuf.append(Utils.generateFormSubmit(context, link, Utils.getActionHiddenFieldName(context, link), link.getClientId(context), getParameterComponents(link)));
}
buf.append(linkBuf.toString());
buf.append(Utils.encode(link.getValue().toString()));
buf.append("</a>");
linkBuf.append('"');
}
else
{
String href = link.getHref();
if (padding == 0)
// prefix the web context path if required
linkBuf.append("<a href=\"");
if (href.startsWith("/"))
{
buf.append("</span>");
linkBuf.append(context.getExternalContext().getRequestContextPath());
}
linkBuf.append(href);
// append arguments if specified
Map<String, String> actionParams = getParameterComponents(link);
if (actionParams != null)
{
boolean first = (href.indexOf('?') == -1);
for (String name : actionParams.keySet())
{
String paramValue = actionParams.get(name);
if (first)
{
linkBuf.append('?');
first = false;
}
else
{
linkBuf.append('&');
}
try
{
linkBuf.append(name).append("=").append(URLEncoder.encode(paramValue, "UTF-8"));
}
catch (UnsupportedEncodingException err)
{
// if this happens we have bigger problems than a missing URL parameter...!
}
}
}
linkBuf.append('"');
// output href 'target' attribute if supplied
if (link.getTarget() != null)
{
linkBuf.append(" target=\"")
.append(link.getTarget())
.append("\"");
}
}
if (padding != 0)
if (attrs.get("style") != null)
{
buf.append("</td></tr></table>");
linkBuf.append(" style=\"")
.append(attrs.get("style"))
.append('"');
}
}
else
{
buf.append(linkBuf.toString());
buf.append(Utils.encode(link.getValue().toString()));
buf.append("</a>");
if (attrs.get("styleClass") != null)
{
linkBuf.append(" class=")
.append(attrs.get("styleClass"));
}
if (link.getTooltip() != null)
{
linkBuf.append(" title=\"")
.append(Utils.encode(link.getTooltip()))
.append('"');
}
linkBuf.append('>');
StringBuilder buf = new StringBuilder(350);
if (link.getImage() != null)
{
int padding = link.getPadding();
if (padding != 0)
{
// TODO: make this width value a property!
buf.append("<table cellspacing=0 cellpadding=0><tr><td width=16>");
}
if (link.getShowLink() == false)
{
buf.append(linkBuf.toString());
}
// TODO: allow configuring of alignment attribute
buf.append(Utils.buildImageTag(context, link.getImage(), (String)link.getValue(), "absmiddle"));
if (link.getShowLink() == false)
{
buf.append("</a>");
}
else
{
if (padding != 0)
{
buf.append("</td><td style=\"padding:")
.append(padding)
.append("px\">");
}
else
{
// TODO: add horizontal spacing as component property
buf.append("<span style='padding-left:2px");
// text next to an image may need alignment
if (attrs.get("verticalAlign") != null)
{
buf.append(";vertical-align:")
.append(attrs.get("verticalAlign"));
}
buf.append("'>");
}
buf.append(linkBuf.toString());
buf.append(Utils.encode(link.getValue().toString()));
buf.append("</a>");
if (padding == 0)
{
buf.append("</span>");
}
}
if (padding != 0)
{
buf.append("</td></tr></table>");
}
}
else
{
buf.append(linkBuf.toString());
buf.append(Utils.encode(link.getValue().toString()));
buf.append("</a>");
}
linkHtml = buf.toString();
}
return buf.toString();
return linkHtml;
}
/**
@@ -282,71 +292,81 @@ public class ActionLinkRenderer extends BaseRenderer
*/
private String renderMenuAction(FacesContext context, UIActionLink link, int padding)
{
StringBuilder buf = new StringBuilder(256);
// if there is no value for the link there will be no visible output
// on the page so don't bother rendering anything
String linkHtml = "";
Object linkValue = link.getValue();
buf.append("<tr><td>");
// render image cell first for a menu
if (link.getImage() != null)
if (linkValue != null)
{
buf.append(Utils.buildImageTag(context, link.getImage(), (String)link.getValue()));
}
buf.append("</td><td");
if (padding != 0)
{
buf.append(" style=\"padding:")
.append(padding)
.append("px\"");
}
buf.append(">");
// render text link cell for the menu
if (link.getHref() == null)
{
buf.append("<a href='#' onclick=\"");
buf.append(Utils.generateFormSubmit(context, link, Utils.getActionHiddenFieldName(context, link), link.getClientId(context), getParameterComponents(link)));
buf.append('"');
}
else
{
String href = link.getHref();
if (href.startsWith("http") == false)
{
href = context.getExternalContext().getRequestContextPath() + href;
}
buf.append("<a href=\"")
.append(href)
.append('"');
StringBuilder buf = new StringBuilder(256);
// output href 'target' attribute if supplied
if (link.getTarget() != null)
buf.append("<tr><td>");
// render image cell first for a menu
if (link.getImage() != null)
{
buf.append(" target=\"")
.append(link.getTarget())
.append("\"");
buf.append(Utils.buildImageTag(context, link.getImage(), (String)link.getValue()));
}
buf.append("</td><td");
if (padding != 0)
{
buf.append(" style=\"padding:")
.append(padding)
.append("px\"");
}
buf.append(">");
// render text link cell for the menu
if (link.getHref() == null)
{
buf.append("<a href='#' onclick=\"");
buf.append(Utils.generateFormSubmit(context, link, Utils.getActionHiddenFieldName(context, link), link.getClientId(context), getParameterComponents(link)));
buf.append('"');
}
else
{
String href = link.getHref();
if (href.startsWith("http") == false)
{
href = context.getExternalContext().getRequestContextPath() + href;
}
buf.append("<a href=\"")
.append(href)
.append('"');
// output href 'target' attribute if supplied
if (link.getTarget() != null)
{
buf.append(" target=\"")
.append(link.getTarget())
.append("\"");
}
}
Map attrs = link.getAttributes();
if (attrs.get("style") != null)
{
buf.append(" style=\"")
.append(attrs.get("style"))
.append('"');
}
if (attrs.get("styleClass") != null)
{
buf.append(" class=")
.append(attrs.get("styleClass"));
}
buf.append('>');
buf.append(Utils.encode(link.getValue().toString()));
buf.append("</a>");
buf.append("</td></tr>");
linkHtml = buf.toString();
}
Map attrs = link.getAttributes();
if (attrs.get("style") != null)
{
buf.append(" style=\"")
.append(attrs.get("style"))
.append('"');
}
if (attrs.get("styleClass") != null)
{
buf.append(" class=")
.append(attrs.get("styleClass"));
}
buf.append('>');
buf.append(Utils.encode(link.getValue().toString()));
buf.append("</a>");
buf.append("</td></tr>");
return buf.toString();
return linkHtml;
}

View File

@@ -37,8 +37,6 @@ import javax.faces.model.SelectItem;
import org.alfresco.web.app.Application;
import org.alfresco.web.ui.common.Utils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* @author kevinr
@@ -58,8 +56,6 @@ public class DatePickerRenderer extends BaseRenderer
private static final int CMD_SET = 1;
private static final int CMD_RESET = 2;
private static final int CMD_TODAY = 3;
private static final Log logger = LogFactory.getLog(DatePickerRenderer.class);
/**
* @see javax.faces.render.Renderer#decode(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
@@ -168,6 +164,7 @@ public class DatePickerRenderer extends BaseRenderer
* input component must render the submitted value if it's set, and use the local
* value only if there is no submitted value.
*/
@SuppressWarnings("deprecation")
public void encodeBegin(FacesContext context, UIComponent component)
throws IOException
{
@@ -178,6 +175,7 @@ public class DatePickerRenderer extends BaseRenderer
String clientId = component.getClientId(context);
ResponseWriter out = context.getResponseWriter();
String cmdFieldName = clientId + FIELD_CMD;
Boolean initIfNull = (Boolean)component.getAttributes().get("initialiseIfNull");
// this is part of the spec:
// first you attempt to build the date from the submitted value
@@ -188,12 +186,19 @@ public class DatePickerRenderer extends BaseRenderer
}
else
{
// second if no submitted value is found, default to the current value
// second - if no submitted value is found, default to the current value
Object value = ((ValueHolder)component).getValue();
if (value instanceof Date)
{
date = (Date)value;
}
// third - if no date is present and the initialiseIfNull attribute
// is set to true set the date to today's date
if (date == null && initIfNull != null && initIfNull.booleanValue())
{
date = new Date();
}
}
// create a flag to show if the component is disabled
@@ -253,18 +258,23 @@ public class DatePickerRenderer extends BaseRenderer
out.write("&nbsp;");
// render 2 links (if the component is not disabled) to allow the user to reset the
// date back to null or to select today's date
// date back to null (if initialiseIfNull is false) or to select today's date
if (disabled.booleanValue() == false)
{
out.write("<input type=\"button\" onclick=\"");
out.write(Utils.generateFormSubmit(context, component, cmdFieldName, Integer.toString(CMD_TODAY)));
out.write("\" value=\"");
out.write(Application.getMessage(context, "today"));
out.write("\">&nbsp;<input type=\"button\" onclick=\"");
out.write(Utils.generateFormSubmit(context, component, cmdFieldName, Integer.toString(CMD_RESET)));
out.write("\" value=\"");
out.write(Application.getMessage(context, "none"));
out.write("\">");
out.write("\">&nbsp;");
if (initIfNull != null && initIfNull.booleanValue() == false)
{
out.write("<input type=\"button\" onclick=\"");
out.write(Utils.generateFormSubmit(context, component, cmdFieldName, Integer.toString(CMD_RESET)));
out.write("\" value=\"");
out.write(Application.getMessage(context, "none"));
out.write("\">");
}
}
}
else
@@ -412,7 +422,7 @@ public class DatePickerRenderer extends BaseRenderer
Locale locale = Application.getLanguage(FacesContext.getCurrentInstance());
if (locale == null)
{
locale = locale.getDefault();
locale = Locale.getDefault();
}
DateFormatSymbols dfs = new DateFormatSymbols(locale);
String[] names = dfs.getMonths();