Merge from HEAD into WCM-DEV2. Also fixes build breakage in

jndi-client and catalina-virtual that I introduced earlier. 


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3393 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-07-24 18:27:41 +00:00
parent ca9496d090
commit f6355ea108
171 changed files with 11880 additions and 3450 deletions

View File

@@ -0,0 +1,137 @@
package org.alfresco.web.ui.repo.component;
import java.io.IOException;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.el.ValueBinding;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.component.SelfRenderingComponent;
/**
* JSF component that displays information about a node.
* <p>
* The node to show information on
*
* @author gavinc
*/
public class UINodeInfo extends SelfRenderingComponent
{
protected final static String NODE_INFO_SCRIPTS_WRITTEN = "_alfNodeInfoScripts";
protected Object value = null;
// ------------------------------------------------------------------------------
// Component Impl
@Override
public String getFamily()
{
return "org.alfresco.faces.NodeInfo";
}
@Override
public void restoreState(FacesContext context, Object state)
{
Object values[] = (Object[])state;
// standard component attributes are restored by the super class
super.restoreState(context, values[0]);
this.value = values[1];
}
@Override
public Object saveState(FacesContext context)
{
Object values[] = new Object[8];
// standard component attributes are saved by the super class
values[0] = super.saveState(context);
values[1] = this.value;
return values;
}
@Override
@SuppressWarnings("unchecked")
public void encodeBegin(FacesContext context) throws IOException
{
if (!isRendered()) return;
// if AJAX is disabled don't render anything
if (Application.getClientConfig(context).isAjaxEnabled())
{
ResponseWriter out = context.getResponseWriter();
// output the scripts required by the component (checks are
// made to make sure the scripts are only written once)
Utils.writeAjaxScripts(context, out);
// write out the JavaScript specific to the NodeInfo component,
// again, make sure it's only done once
Object present = context.getExternalContext().getRequestMap().
get(NODE_INFO_SCRIPTS_WRITTEN);
if (present == null)
{
out.write("<script type=\"text/javascript\" src=\"");
out.write(context.getExternalContext().getRequestContextPath());
out.write("/scripts/ajax/node-info.js\"> </script>\n");
context.getExternalContext().getRequestMap().put(
NODE_INFO_SCRIPTS_WRITTEN, Boolean.TRUE);
}
// wrap the child components in a <span> that has the onmouseover
// event which kicks off the request for node information
String id = (String)this.getValue();
out.write("<span onmouseover=\"showNodeInfo('");
out.write(Repository.getStoreRef().toString());
out.write("/");
out.write(id);
out.write("', this)\" onmouseout=\"hideNodeInfo()\">");
}
}
@Override
public void encodeEnd(FacesContext context) throws IOException
{
if (!isRendered()) return;
// if AJAX is disabled don't render anything
if (Application.getClientConfig(context).isAjaxEnabled())
{
context.getResponseWriter().write("</span>");
}
}
// ------------------------------------------------------------------------------
// Strongly typed component property accessors
/**
* Get the value - the value is used in a equals() match against the current value in the
* parent ModeList component to set the selected item.
*
* @return the value
*/
public Object getValue()
{
ValueBinding vb = getValueBinding("value");
if (vb != null)
{
this.value = vb.getValue(getFacesContext());
}
return this.value;
}
/**
* Set the value - the value is used in a equals() match against the current value in the
* parent ModeList component to set the selected item.
*
* @param value the value
*/
public void setValue(Object value)
{
this.value = value;
}
}

View File

@@ -739,37 +739,40 @@ public class UIPropertySheet extends UIPanel implements NamingContainer
}
// now setup the common stuff across all component types
FacesHelper.setupComponentId(context, propSheetItem, id);
propSheetItem.setName(item.getName());
propSheetItem.setConverter(item.getConverter());
propSheetItem.setComponentGenerator(item.getComponentGenerator());
propSheetItem.setIgnoreIfMissing(item.getIgnoreIfMissing());
String displayLabel = item.getDisplayLabel();
if (item.getDisplayLabelId() != null)
if (propSheetItem != null)
{
String label = Application.getMessage(context, item.getDisplayLabelId());
if (label != null)
FacesHelper.setupComponentId(context, propSheetItem, id);
propSheetItem.setName(item.getName());
propSheetItem.setConverter(item.getConverter());
propSheetItem.setComponentGenerator(item.getComponentGenerator());
propSheetItem.setIgnoreIfMissing(item.getIgnoreIfMissing());
String displayLabel = item.getDisplayLabel();
if (item.getDisplayLabelId() != null)
{
displayLabel = label;
String label = Application.getMessage(context, item.getDisplayLabelId());
if (label != null)
{
displayLabel = label;
}
}
propSheetItem.setDisplayLabel(displayLabel);
// if this property sheet is set as read only or the config says the property
// should be read only set it as such
if (isReadOnly() || item.isReadOnly())
{
propSheetItem.setReadOnly(true);
}
this.getChildren().add(propSheetItem);
if (logger.isDebugEnabled())
logger.debug("Created property sheet item component " + propSheetItem + "(" +
propSheetItem.getClientId(context) +
") for '" + item.getName() +
"' and added it to property sheet " + this);
}
propSheetItem.setDisplayLabel(displayLabel);
// if this property sheet is set as read only or the config says the property
// should be read only set it as such
if (isReadOnly() || item.isReadOnly())
{
propSheetItem.setReadOnly(true);
}
this.getChildren().add(propSheetItem);
if (logger.isDebugEnabled())
logger.debug("Created property sheet item component " + propSheetItem + "(" +
propSheetItem.getClientId(context) +
") for '" + item.getName() +
"' and added it to property sheet " + this);
}
}

View File

@@ -58,7 +58,7 @@ public class DefaultModelHelper
*
* @return Map containing the default model.
*/
public static Map<String, Object> buildDefaultModel(ServiceRegistry services, User user)
public static Map<String, Object> buildDefaultModel(ServiceRegistry services, User user, NodeRef template)
{
if (services == null)
{
@@ -85,6 +85,12 @@ public class DefaultModelHelper
// supply the current user Node as "person"
root.put("person", new TemplateNode(user.getPerson(), services, imageResolver));
// add the template itself as "template" if it comes from content on a node
if (template != null)
{
root.put("template", new TemplateNode(template, services, imageResolver));
}
// current date/time is useful to have and isn't supplied by FreeMarker by default
root.put("date", new Date());
@@ -97,7 +103,7 @@ public class DefaultModelHelper
}
/** Template Image resolver helper */
public static TemplateImageResolver imageResolver = new TemplateImageResolver()
public static final TemplateImageResolver imageResolver = new TemplateImageResolver()
{
public String resolveImagePathForName(String filename, boolean small)
{

View File

@@ -17,21 +17,16 @@
package org.alfresco.web.ui.repo.component.template;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
import org.alfresco.repo.template.DateCompareMethod;
import org.alfresco.repo.template.HasAspectMethod;
import org.alfresco.repo.template.I18NMessageMethod;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.repository.TemplateException;
import org.alfresco.service.cmr.repository.TemplateImageResolver;
import org.alfresco.service.cmr.repository.TemplateNode;
import org.alfresco.service.cmr.repository.TemplateService;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository;
@@ -108,9 +103,6 @@ public class UITemplate extends SelfRenderingComponent
return;
}
// get the data model to use - building default if required
Object model = getModel();
// get the template to process
String template = getTemplate();
if (template != null && template.length() != 0)
@@ -125,6 +117,9 @@ public class UITemplate extends SelfRenderingComponent
startTime = System.currentTimeMillis();
}
// get the data model to use - building default if required
Object model = getModel();
// process the template against the model
try
{
@@ -195,7 +190,16 @@ public class UITemplate extends SelfRenderingComponent
FacesContext fc = FacesContext.getCurrentInstance();
ServiceRegistry services = Repository.getServiceRegistry(fc);
User user = Application.getCurrentUser(fc);
Map root = DefaultModelHelper.buildDefaultModel(services, user);
// add the template itself to the model
NodeRef templateRef = null;
if (getTemplate().indexOf(StoreRef.URI_FILLER) != -1)
{
// found a noderef template
templateRef = new NodeRef(getTemplate());
}
Map root = DefaultModelHelper.buildDefaultModel(services, user, templateRef);
// merge models
if (model instanceof Map)