org.mmbase.applications.vprowizards.spring.action
Class ToggleRelationAction

java.lang.Object
  extended by org.mmbase.applications.vprowizards.spring.action.Action
      extended by org.mmbase.applications.vprowizards.spring.action.AbstractNodeAction
          extended by org.mmbase.applications.vprowizards.spring.action.AbstractRelationAction
              extended by org.mmbase.applications.vprowizards.spring.action.CreateRelationAction
                  extended by org.mmbase.applications.vprowizards.spring.action.ToggleRelationAction

public class ToggleRelationAction
extends CreateRelationAction

This action is to replace the the CreateCheckboxRelation and UpdateCheckboxRelation actions from the previous version of the backing code. This action adds one field to the CreateRelationAction, 'relate'. When this field is set (with 'true') A relation if type 'role' is created between the source and destination. If 'relate' has any other or no value, and there is a relation of given role between the source and destination node, it is deleted. This action can be is used by the CheckboxRelation and RadiobuttonRelation tags. This action is a bit of a strange specialization of the CreateRelationAction class, because not all things you can do to that action (like setting fields) is useful for this action. This is not briliant design, but to make it a little bit more solid all unsupported setters have been overridden, and do no throw an UnsupportedOperationException

Author:
Ernst Bunders

Field Summary
 
Fields inherited from class org.mmbase.applications.vprowizards.spring.action.CreateRelationAction
SORT_POSITION_BEGIN, SORT_POSITION_END
 
Fields inherited from class org.mmbase.applications.vprowizards.spring.action.AbstractRelationAction
destinationNode, destinationNodeNumber, destinationNodeRef, relationManager, relationValues, role, searchDir, sourceNode, sourceNodeNumber, sourceNodeRef
 
Fields inherited from class org.mmbase.applications.vprowizards.spring.action.AbstractNodeAction
securityContext
 
Constructor Summary
ToggleRelationAction()
           
 
Method Summary
protected  void createCacheFlushHints()
          This template method is called when the node to edit is changed.
protected  Node createRelation(Transaction transaction, Map<String,Node> idMap, HttpServletRequest request)
          This template method should be implemented by concrete implementations of this class.
 String getRelate()
           
protected  boolean isNodeNullIllegal()
          for this action node can actually be null
 void setDateFields(Map<String,DateTime> dateFields)
           
 void setFields(Map<String,String> fields)
           
 void setFile(org.springframework.web.multipart.MultipartFile file)
           
 void setId(String id)
           
 void setRelate(String relate)
          when this is set to 'true' and the relation does not exist yet, the relation is created.
 void setSortField(String sortField)
           
 void setSortPosition(String sortPosition)
           
 
Methods inherited from class org.mmbase.applications.vprowizards.spring.action.CreateRelationAction
getSortField, getSortPosition, processNode, resolvePosition, setRole
 
Methods inherited from class org.mmbase.applications.vprowizards.spring.action.AbstractRelationAction
createNode, getDestinationNodeNumber, getDestinationNodeRef, getRelationValues, getRole, getSearchDir, getSourceNodeNumber, getSourceNodeRef, putValues, resolveNode, resolveSourceAndDestination, setDestinationNodeNumber, setDestinationNodeRef, setRelationValues, setSearchDir, setSourceNodeNumber, setSourceNodeRef
 
Methods inherited from class org.mmbase.applications.vprowizards.spring.action.AbstractNodeAction
addCachFlushHint, addFieldError, addFieldError, addFieldErrorTypeMessage, addFieldErrorTypeMessage, addFieldErrorTypeValue, addGlobalError, addGlobalError, addGlobalError, addNodeParam, addParam, getDateFields, getFields, getFile, getId, getLocale, getNode, hasChanged, hasErrors, mayCreate, mayDelete, mayWrite, process, setChanged, setHtmlField, setSecurityContext, shouldProcess, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ToggleRelationAction

public ToggleRelationAction()
Method Detail

getRelate

public String getRelate()

setRelate

public void setRelate(String relate)
when this is set to 'true' and the relation does not exist yet, the relation is created. Otherwise the relation is deleted if it exists.

Parameters:
relate -

createRelation

protected Node createRelation(Transaction transaction,
                              Map<String,Node> idMap,
                              HttpServletRequest request)
Description copied from class: AbstractRelationAction
This template method should be implemented by concrete implementations of this class. It is called by AbstractRelationAction.createNode(Transaction, Map, HttpServletRequest) after all the preliminary checks.

Overrides:
createRelation in class CreateRelationAction
Returns:

createCacheFlushHints

protected void createCacheFlushHints()
Description copied from class: AbstractNodeAction
This template method is called when the node to edit is changed. custom cachflush hints can be set here. This class dous not know if the current node is updated or created, so it dousn't know what kind of events to create.

Overrides:
createCacheFlushHints in class CreateRelationAction

isNodeNullIllegal

protected boolean isNodeNullIllegal()
for this action node can actually be null

Overrides:
isNodeNullIllegal in class AbstractNodeAction
Returns:
true by default.

setSortField

public void setSortField(String sortField)
                  throws UnsupportedOperationException
Overrides:
setSortField in class CreateRelationAction
Throws:
UnsupportedOperationException

setSortPosition

public void setSortPosition(String sortPosition)
                     throws UnsupportedOperationException
Overrides:
setSortPosition in class CreateRelationAction
Throws:
UnsupportedOperationException

setDateFields

public void setDateFields(Map<String,DateTime> dateFields)
                   throws UnsupportedOperationException
Overrides:
setDateFields in class AbstractNodeAction
Throws:
UnsupportedOperationException

setFields

public void setFields(Map<String,String> fields)
               throws UnsupportedOperationException
Overrides:
setFields in class AbstractNodeAction
Throws:
UnsupportedOperationException

setFile

public void setFile(org.springframework.web.multipart.MultipartFile file)
             throws UnsupportedOperationException
Overrides:
setFile in class AbstractNodeAction
Throws:
UnsupportedOperationException

setId

public void setId(String id)
           throws UnsupportedOperationException
Overrides:
setId in class AbstractNodeAction
Throws:
UnsupportedOperationException


MMBase 2.0-SNAPSHOT - null