in myfaces-html5-core/src/main/java/org/apache/myfaces/html5/handler/DragSourceBehaviorHandler.java [99:197]
public void apply(FaceletContext faceletContext, UIComponent parent)
{
if (!ComponentHandler.isNew(parent))
{
if (log.isLoggable(Level.FINE))
log.fine("Component " + DebugUtils.getPathToComponent(parent)
+ " is not new, thus return without any operation.");
return;
}
if (parent instanceof ClientBehaviorHolder)
{
ClientBehaviorHolder holder = _getClientBehaviorHolder(parent);
FacesContext context = faceletContext.getFacesContext();
Application app = context.getApplication();
String behaviorId = getBehaviorId();
Behavior behavior = app.createBehavior(behaviorId);
if (!(behavior instanceof DragSourceBehavior))
{
throw new FacesException("Behavior is not a DragSourceBehavior");
}
// manually added all of the properties, so no need for this:
// setAttributes(faceletContext, behavior);
// set parent as draggable
if (parent instanceof Draggable)
{
((Draggable) parent).setDraggable(true);
}
else
{
if (log.isLoggable(Level.WARNING))
log.warning("Parent " + DebugUtils.getPathToComponent(parent)
+ " does not implement Draggable interface, thus unable to set the draggable attribute. "
+ "Renderer of the parent must handle the decision of being draggable manually.");
}
DragSourceBehavior dragSourceBehavior = (DragSourceBehavior) behavior;
// evaluating the _param's value expression doesn't this work if I put the dragSource in a datatable and try
// to set the valueexpression using the var of table.
// see https://issues.apache.org/jira/browse/MYFACES-2616
// see the thread http://www.mail-archive.com/dev@myfaces.apache.org/msg46764.html
// thus need to pass the valuexpression to the behavior, then the renderer can evaluate it. AjaxBehavior
// does this with a map.
// using the same approach in DropTargetBehavior too...
if (_action != null)
{
if (_action.isLiteral())
{
dragSourceBehavior.setAction(_action.getValue(faceletContext));
}
else
{
dragSourceBehavior.setValueExpression("action",
_action.getValueExpression(faceletContext, String.class));
}
}
if (_dropTargetTypes != null)
{
if (_dropTargetTypes.isLiteral())
{
dragSourceBehavior.setDropTargetTypes(_dropTargetTypes.getObject(faceletContext));
}
else
{
dragSourceBehavior.setValueExpression("dropTargetTypes",
_dropTargetTypes.getValueExpression(faceletContext, Object.class));
}
}
if (_param != null)
{
if (_param.isLiteral())
{
dragSourceBehavior.setParam(_param.getValue(faceletContext));
}
else
{
dragSourceBehavior.setValueExpression("param",
_param.getValueExpression(faceletContext, String.class));
}
}
holder.addClientBehavior(ClientBehaviorEvents.DRAGSTART_EVENT, dragSourceBehavior);
}
else
{
if (log.isLoggable(Level.WARNING))
log.warning("Parent is not a ClientBehaviorHolder.");
}
}