org.mmbase.applications.editwizard
Class Wizard

java.lang.Object
  extended byorg.mmbase.applications.editwizard.Wizard
All Implemented Interfaces:
SizeMeasurable

public class Wizard
extends Object
implements SizeMeasurable

EditWizard

Since:
MMBase-1.6
Version:
$Id: Wizard.java,v 1.148 2006/07/13 13:18:14 nklasens Exp $
Author:
Kars Veling, Michiel Meeuwissen, Pierre van Rooden, Hillebrand Gelderblom
Warning: No Java Documentation Available.

Field Summary
static String DTD_EDITWIZARD_1_0
           
static String PUBLIC_ID_EDITWIZARD_1_0
           
static String PUBLIC_ID_EDITWIZARD_1_0_FAULT
           
 
Constructor Summary
Wizard(String context, URIResolver uri, Config.WizardConfig wizardConfig, Cloud cloud)
          Constructor.
Wizard(String context, URIResolver uri, String wizardname, String dataid, Cloud cloud)
          Deprecated. use Wizard(String, URIResolver, Config.WizardConfig, Cloud)
 
Method Summary
 void addBinaryData(Node fieldnode)
          This method stores binary data in the data, so that the information can be used by the html.
protected  boolean checkNode(String objectNumber, String operation)
          Returns true if the specified operation is valid for the node with the specified objectnumber.
 boolean committed()
          Returns whether the wizard may be closed
 Document createPreHtml(Node wizardSchema, String formid, Node data, String instanceName)
          This method generated the pre-html.
 Document createPreHtml(String instanceName)
          This method generates the pre-html.
 void createPreHtmlForm(Node form, Node formdef, Node dataContext)
          This method is used by the #createPreHtml method to generate a pre-html form.
 String determineNextForm(String direction)
          This method is used to determine what form is the sequential next, previous, first etc.
 byte[] getBinary(String did)
          This method allows you to retrieve the data of a temporarily stored binary.
 String getBinaryName(String did)
          With this method you can retrieve the binaryname of a placed binary.
 String getBinaryPath(String did)
          With this method you can retrieve the binarypath of a placed binary.
 int getByteSize()
          Determines the byte-size of this object
 int getByteSize(SizeOf sizeof)
          Determines the byte-size of this object using the given SizeOf instance.
 Node getConstraints(String objecttype)
          This method gets the MMBase constraints.
 Node getConstraints(String objecttype, String fieldname)
          This method gets the MMBase constraints.
 Document getData()
           
 String getDataId()
           
 String getObjectNumber()
           
 Document getPreForm()
           
 Document getPreForm(String instanceName)
           
 Document getSchema()
           
 WizardCommand getStartWizardCommand()
          Returns the subwizard start command
protected  void loadData()
           
protected  void loadWizard(Config.WizardConfig wizardConfig)
          Loads the wizard schema, and a work document, and fills it with initial data.
 boolean mayBeClosed()
          Returns whether the wizard may be closed
protected  boolean mayDeleteNode(String objectNumber)
          Returns true if the node with the specified objectnumber can be deleted
protected  boolean mayEditNode(String objectNumber)
          Returns true if the node with the specified objectnumber can be edited
 void mergeConstraints(Node fieldDef, Node fieldNode)
          This method is used to merge MMBase specific constraints with the values placed in the Wizard definition.
 void processCommand(WizardCommand cmd)
          This method is usually called by #processCommands and processes one command.
 void processRequest(ServletRequest req)
          Processes an incoming request (usually passed on by a jsp code).
 String retrieveFieldValue(String did, String fieldName)
          Obtains the value form the right field (given by name) of the right node (given by did).
 void setBinary(String did, byte[] bytes, String name, String path)
          With this method you can store a binary in the wizard.
 void setBinary(String did, byte[] bytes, String name, String path, String type)
           
 void setReferrer(String s)
           
 void setSessionId(String s)
           
 void setSessionKey(String s)
           
 void setTemplatesDir(String f)
           
 void setTimezone(String s)
           
 boolean startWizard()
          Returns whether a sub wizard should be started
protected  void storeConfigurationAttributes(Config.WizardConfig wizardConfig)
          Stores configuration variables as attributes in the variabless set.
 void storeFieldValue(String did, String fieldName, String value)
          Puts the given value in the right field (given by name) of the right node (given by did) Assumes a text field.
 void writeHtmlForm(Writer out, String instanceName)
          Constructs and writes final form-html to the given out writer.
 void writeHtmlForm(Writer out, String instanceName, Map externParams)
          Constructs and writes final form-html to the given out writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PUBLIC_ID_EDITWIZARD_1_0

public static final String PUBLIC_ID_EDITWIZARD_1_0
See Also:
Constant Field Values

PUBLIC_ID_EDITWIZARD_1_0_FAULT

public static final String PUBLIC_ID_EDITWIZARD_1_0_FAULT
See Also:
Constant Field Values

DTD_EDITWIZARD_1_0

public static final String DTD_EDITWIZARD_1_0
See Also:
Constant Field Values
Constructor Detail

Wizard

public Wizard(String context,
              URIResolver uri,
              String wizardname,
              String dataid,
              Cloud cloud)
       throws WizardException
Deprecated. use Wizard(String, URIResolver, Config.WizardConfig, Cloud)

Constructor. Setup initial variables and connects to mmbase to load the data structure.

Parameters:
context - the editwizard context path
uri - the URIResolver with which the wizard schema's and the xsl's will be loaded
wizardname - name of teh wizard
dataid - the objectnumber
cloud - the Cloud to use

Wizard

public Wizard(String context,
              URIResolver uri,
              Config.WizardConfig wizardConfig,
              Cloud cloud)
       throws WizardException
Constructor. Setup initial variables and connects to mmbase to load the data structure.

Parameters:
context - the editwizard context path
uri - the URIResolver with which the wizard schema's and the xsl's will be loaded
wizardConfig - the class containing the configuration parameters (i.e. wizard name and objectnumber)
cloud - the Cloud to use
Method Detail

getByteSize

public int getByteSize()
Description copied from interface: SizeMeasurable
Determines the byte-size of this object

Specified by:
getByteSize in interface SizeMeasurable

getByteSize

public int getByteSize(SizeOf sizeof)
Description copied from interface: SizeMeasurable
Determines the byte-size of this object using the given SizeOf instance. A SizeOf instance stores a Set already counted objects. So this method is typically called by SizeOf itself (recursion).

Specified by:
getByteSize in interface SizeMeasurable

setSessionId

public void setSessionId(String s)

setSessionKey

public void setSessionKey(String s)

setReferrer

public void setReferrer(String s)

setTemplatesDir

public void setTemplatesDir(String f)

setTimezone

public void setTimezone(String s)

getObjectNumber

public String getObjectNumber()

getDataId

public String getDataId()

getData

public Document getData()

getSchema

public Document getSchema()

getPreForm

public Document getPreForm()
                    throws WizardException
Throws:
WizardException

getPreForm

public Document getPreForm(String instanceName)
                    throws WizardException
Throws:
WizardException

committed

public boolean committed()
Returns whether the wizard may be closed


mayBeClosed

public boolean mayBeClosed()
Returns whether the wizard may be closed


startWizard

public boolean startWizard()
Returns whether a sub wizard should be started


checkNode

protected boolean checkNode(String objectNumber,
                            String operation)
                     throws WizardException
Returns true if the specified operation is valid for the node with the specified objectnumber. The operation is valid if the node has the given property set to true. To maintain backwards compatible, if the property is not given, the default value is true.

Parameters:
objectNumber - teh number of teh ndoe to check
operation - a valid operation, i.e. maywrite or maydelete
Throws:
WizardException - if the object cannot be retrieved

mayEditNode

protected boolean mayEditNode(String objectNumber)
                       throws WizardException
Returns true if the node with the specified objectnumber can be edited

Parameters:
objectNumber - number of the object to check
Throws:
WizardException - if the object cannot be retrieved

mayDeleteNode

protected boolean mayDeleteNode(String objectNumber)
                         throws WizardException
Returns true if the node with the specified objectnumber can be deleted

Parameters:
objectNumber - number of the object to check
Throws:
WizardException - if the object cannot be retrieved

getStartWizardCommand

public WizardCommand getStartWizardCommand()
Returns the subwizard start command


storeConfigurationAttributes

protected void storeConfigurationAttributes(Config.WizardConfig wizardConfig)
Stores configuration variables as attributes in the variabless set.

Parameters:
wizardConfig - the config with the parameters

loadWizard

protected void loadWizard(Config.WizardConfig wizardConfig)
                   throws WizardException
Loads the wizard schema, and a work document, and fills it with initial data.

Parameters:
wizardConfig - the class containing the configuration parameters (i.e. wizard name and objectnumber)
Throws:
WizardException

loadData

protected void loadData()
                 throws WizardException
Throws:
WizardException
Since:
MMBase-1.7

processRequest

public void processRequest(ServletRequest req)
                    throws WizardException
Processes an incoming request (usually passed on by a jsp code). First, all given values are stored in the current datatree, Second, all given commands are processed sequentially.

Parameters:
req - the ServletRequest contains the name-value pairs received through the http connection
Throws:
WizardException

writeHtmlForm

public void writeHtmlForm(Writer out,
                          String instanceName)
                   throws WizardException,
                          TransformerException
Constructs and writes final form-html to the given out writer. You can specify an instancename, so that the wizard is able to start another wizard in the same session. The jsp pages and in the html the instancenames are used to keep track of one and another.

Parameters:
out - The writer where the output (html) should be written to.
instanceName - name of the current instance
Throws:
WizardException
TransformerException

writeHtmlForm

public void writeHtmlForm(Writer out,
                          String instanceName,
                          Map externParams)
                   throws WizardException,
                          TransformerException
Constructs and writes final form-html to the given out writer. You can specify an instancename, so that the wizard is able to start another wizard in the same session. The jsp pages and in the html the instancenames are used to keep track of one and another.

Parameters:
out - The writer where the output (html) should be written to.
instanceName - name of the current instance
externParams - sending parameters to the stylesheet which are not from the editwizards itself
Throws:
WizardException
TransformerException

determineNextForm

public String determineNextForm(String direction)
This method is used to determine what form is the sequential next, previous, first etc. You can use the parameter to indicate what you want to know:

Parameters:
direction - indicates what you wanna know. Possibilities: - first (default) - last - previous - next

createPreHtml

public Document createPreHtml(String instanceName)
                       throws WizardException
This method generates the pre-html. See the full-spec method for more details.

Throws:
WizardException
See Also:
createPreHtml(java.lang.String)

createPreHtml

public Document createPreHtml(Node wizardSchema,
                              String formid,
                              Node data,
                              String instanceName)
                       throws WizardException
This method generated the pre-html. Pre-html is a temporarily datatree (xml of course) which is used to generate the final html from. Is uses the wizardschema, the current formid, the current datatree and the instancename to generate the pre-html. Mainly, the pre-html contains all data needed to make a nice htmlform. The XSL's use the pre-html to generate html (thats why pre-html)

Parameters:
wizardSchema - the main node of the schema to be used. Includes should already be resolved.
formid - The id of the current form
data - The main node of the data tree to be used
instanceName - The instancename of this wizard
Throws:
WizardException

createPreHtmlForm

public void createPreHtmlForm(Node form,
                              Node formdef,
                              Node dataContext)
                       throws WizardException
This method is used by the #createPreHtml method to generate a pre-html form.

Parameters:
form - The node of the pre-html form which is to be generated
formdef - the node of the wizardschema form definition
dataContext - Points to the datacontext node which should be used for this form.
Throws:
WizardException

storeFieldValue

public void storeFieldValue(String did,
                            String fieldName,
                            String value)
                     throws WizardException
Puts the given value in the right field (given by name) of the right node (given by did) Assumes a text field.

Parameters:
did - The data id of the node
fieldName - The name of the field
value - The (String) value what should be stored in the data.
Throws:
WizardException

retrieveFieldValue

public String retrieveFieldValue(String did,
                                 String fieldName)
                          throws WizardException
Obtains the value form the right field (given by name) of the right node (given by did). Assumes a text field.

Parameters:
did - The data id of the node
fieldName - The name of the field
Throws:
WizardException

processCommand

public void processCommand(WizardCommand cmd)
                    throws WizardException
This method is usually called by #processCommands and processes one command. Possible wizard commands are:

Parameters:
cmd - The command to be processed
Throws:
WizardException

setBinary

public void setBinary(String did,
                      byte[] bytes,
                      String name,
                      String path)
With this method you can store a binary in the wizard.

Parameters:
did - This is the dataid what points to in what field the binary should be stored, once commited.
bytes - This is a bytearray with the data to be stored.
name - This is the name which will be used to show what file is uploaded.
path - The (local) path of the file placed.

setBinary

public void setBinary(String did,
                      byte[] bytes,
                      String name,
                      String path,
                      String type)
Parameters:
type - Content-type of the byte (or null). If not null, then the fields 'mimetype', 'size' and 'filename' are filled as well.
Since:
MMBase-1.7.2

getBinary

public byte[] getBinary(String did)
This method allows you to retrieve the data of a temporarily stored binary.

Parameters:
did - The dataid of the binary you want.
Returns:
the binary data, if found.

getBinaryName

public String getBinaryName(String did)
With this method you can retrieve the binaryname of a placed binary.

Parameters:
did - The dataid of the binary you want.
Returns:
The name as set when #setBinary was used.

getBinaryPath

public String getBinaryPath(String did)
With this method you can retrieve the binarypath of a placed binary.

Parameters:
did - The dataid of the binary you want.
Returns:
The path as set when #setBinary was used.

addBinaryData

public void addBinaryData(Node fieldnode)
This method stores binary data in the data, so that the information can be used by the html. This method is called from the form creating code.

Parameters:
fieldnode - the fieldnode where the binary data information should be stored.

mergeConstraints

public void mergeConstraints(Node fieldDef,
                             Node fieldNode)
This method is used to merge MMBase specific constraints with the values placed in the Wizard definition. For now, it checks requiredness and datatypes. It connects to the Dove, gets the constraints (from cache or not) and merges the values.

Parameters:
fieldDef - the fielddefinition as placed in the wizardschema (==definition)
fieldNode - The fieldnode points to the datanode. (This is needed to find out what datatype this field is about).

getConstraints

public Node getConstraints(String objecttype)
This method gets the MMBase constraints.

Parameters:
objecttype - The name of the object, eg. images, jumpers, urls, news

getConstraints

public Node getConstraints(String objecttype,
                           String fieldname)
This method gets the MMBase constraints. It also handles the internal constraints cache.

Parameters:
objecttype - The name of the object, eg. images, jumpers, urls, news
fieldname - The name of the field, eg. title, body, start


MMBase build 1.8.1.20060716