jacquard 1.12.0 by The Web Engineering Factory and Toolworks

uk.co.weft.htform
Class LinkTableWidget

java.lang.Object
  extended byuk.co.weft.htform.ResourceConsumerImpl
      extended byuk.co.weft.domutil.NodeGeneratorImpl
          extended byuk.co.weft.htform.Widget
              extended byuk.co.weft.htform.MenuWidget
                  extended byuk.co.weft.htform.MultiSelectWidget
                      extended byuk.co.weft.htform.ShuffleWidget
                          extended byuk.co.weft.htform.LinkTableWidget
All Implemented Interfaces:
java.lang.Cloneable, NodeGenerator, ResourceConsumer
Direct Known Subclasses:
CompositeStylesheetWidget

public class LinkTableWidget
extends ShuffleWidget
implements NodeGenerator

In some simple database designs many-to-many relationships are represented by simple link tables. This is a widget for editing simple link table relationships. It is not magic, and may not do what you want... Special warning: the default postProcess method smashes and recreates all the relevent entries in the link table each time round, so if there is any useful information held in other fields in the link table this class is not what you want (although you might specialise it). It only makes sense to use one of these in a TableWrapperForm.

Version:
$Revision: 1.19.4.3 $ This revision: $Author: simon $
Author:
Simon Brooke (simon@weft.co.uk)

Field Summary
 
Fields inherited from class uk.co.weft.htform.ShuffleWidget
doProcessExtension, excludeLabel, includeLabel, preferGracefulDegradeToNetscapeBugs, shuffleScript, unselectedExtension
 
Fields inherited from class uk.co.weft.htform.MultiSelectWidget
eltTag
 
Fields inherited from class uk.co.weft.htform.MenuWidget
defaultSize, unsetLabel, UNSETVALUEMAGICTOKEN
 
Fields inherited from class uk.co.weft.htform.Widget
ACTIONCSSCLASS, akprompt, attrs, CONTEXTATTRIBUTESSUFFIX, cssClass, DANGEROUSCSSCLASS, debug, DEFAULTTOKEN, dflt, form, generateAs, GENERATEASHTML, GENERATEASXFORM, GENERATEASXML, help, HELPTOKEN, immutable, ISIMMUTABLETOKEN, ISMANDATORYTOKEN, mandatory, MANDATORYCSSCLASS, maxVisibleSize, name, NAMETOKEN, OPTIONALCSSCLASS, PREVIOUSVALUESUFFIX, prompt, PROMPTTOKEN, size, SIZETOKEN, type, TYPETOKEN
 
Fields inherited from class uk.co.weft.domutil.NodeGeneratorImpl
namespaceURI
 
Fields inherited from class uk.co.weft.htform.ResourceConsumerImpl
resourceBundleName
 
Fields inherited from interface uk.co.weft.domutil.NodeGenerator
NAMESPACEURIMAGICTOKEN
 
Fields inherited from interface uk.co.weft.htform.ResourceConsumer
RESOURCEBUNDLEMAGICTOKEN
 
Constructor Summary
LinkTableWidget(java.lang.String name, java.lang.String prompt, java.lang.String help, boolean mute, int size, java.lang.String near_table, java.lang.String far_table, java.lang.String near_key, java.lang.String far_key, java.lang.String far_ident)
          Basic setup -- all the normal widget things, plus a lot more of my own.
LinkTableWidget(java.lang.String name, java.lang.String prompt, java.lang.String help, boolean mute, int size, java.lang.String near_table, java.lang.String far_table, java.lang.String near_key, java.lang.String far_key, java.lang.String far_ident, java.lang.String rank)
          Intermediate setup -- basic plus rank.
LinkTableWidget(java.lang.String name, java.lang.String prompt, java.lang.String help, boolean mute, int size, java.lang.String near_table, java.lang.String far_table, java.lang.String near_key, java.lang.String far_key, java.lang.String far_ident, java.lang.String near_link, java.lang.String far_link, java.lang.String rank)
          Full setup -- all the normal widget things, plus a lot more of my own.
 
Method Summary
 java.util.Vector getOptions(Context context)
          Query the database for my options.
 int getTabPlaces(Context context)
          Specialisation:
 void layout(Context context, int tabIndex)
          There's no point in laying out a LinkTableWidget for a record that hasn't yet been created because all attempts to use it will fail.
 java.lang.String onloadRequest(Context context)
          LinkTableWidgets positively need JavaScript scripts to support them!
protected  void postProcess(Context context)
          Pull my values out of the link table.
protected  void preProcess(Context context)
          If I have values passed in, update the link table to reflect them.
 
Methods inherited from class uk.co.weft.htform.ShuffleWidget
getWidth, layoutSelectedWidget, layoutSelectedWidget, layoutShuffleButton, layoutShuffleButton, layoutUnselectedWidget, layoutUnselectedWidget, scriptRequest
 
Methods inherited from class uk.co.weft.htform.MultiSelectWidget
getHeight, layoutValue
 
Methods inherited from class uk.co.weft.htform.MenuWidget
addOption, clone, generateInnerHTML, generateValue, setDebug
 
Methods inherited from class uk.co.weft.htform.Widget
generate, generateAttributes, generateAttributes, generateHTML, generateHTMLPrompt, generateXML, getContextAttribute, getCssClass, getHelp, getName, getPrompt, getType, init, layout, layout, layout, layoutAttribute, layoutAttributes, makeReady, maybeLayout, maybeLayout, onloadRequest, scriptRequest, setAttribute, setContextAttribute, setCssClass, setDefault, setHelp, setImmutable, setMandatory, setMandatory, setName, setPrompt, setSize, setType
 
Methods inherited from class uk.co.weft.domutil.NodeGeneratorImpl
getNamespaceURI, setNamespaceURI
 
Methods inherited from class uk.co.weft.htform.ResourceConsumerImpl
getContextOrResource, getResource, getResourceOrContext, getResourceString, grs, grs
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface uk.co.weft.domutil.NodeGenerator
generate, getName, getNamespaceURI, init, setDebug
 

Constructor Detail

LinkTableWidget

public LinkTableWidget(java.lang.String name,
                       java.lang.String prompt,
                       java.lang.String help,
                       boolean mute,
                       int size,
                       java.lang.String near_table,
                       java.lang.String far_table,
                       java.lang.String near_key,
                       java.lang.String far_key,
                       java.lang.String far_ident,
                       java.lang.String near_link,
                       java.lang.String far_link,
                       java.lang.String rank)
Full setup -- all the normal widget things, plus a lot more of my own. Conventions: my name is the name of the link table.

Parameters:
name - the name of the link table in the database
near_table - the name of the table on the 'near' side of the join.
far_table - the name of the table on the 'far' side of the join.
near_key - the name of the key field in the near table. It is assumed that a value for this can be found in the context at update time.
far_key - the name of the key field in the far table.
far_ident - the name of a field in the far table which contains user-friendly identifying information (e.g. a name)
near_link - the name of the column in the link table which joins to the nearside key
far_link - the name of the column in the link table which joins to the farside key
rank - the name of the column to order the entries by. If not null, must be the name of an additional integer column in the link table.

LinkTableWidget

public LinkTableWidget(java.lang.String name,
                       java.lang.String prompt,
                       java.lang.String help,
                       boolean mute,
                       int size,
                       java.lang.String near_table,
                       java.lang.String far_table,
                       java.lang.String near_key,
                       java.lang.String far_key,
                       java.lang.String far_ident,
                       java.lang.String rank)
Intermediate setup -- basic plus rank.

Parameters:
name - the name of the link table in the database
near_table - the name of the table on the 'near' side of the join.
far_table - the name of the table on the 'far' side of the join.
near_key - the name of the key field in the near table. The column that joins to this in the link table is assumed to have the same name. It is assumed that a value for this can be found in the context at update time.
far_key - the name of the key field in the far table. The column that joins to this in the link table is assumed to have the same name.
far_ident - the name of a field in the far table which contains user-friendly identifying information (e.g. a name)
rank - the name of the column to order the entries by. If not null, must be the name of an additional integer column in the link table.

LinkTableWidget

public LinkTableWidget(java.lang.String name,
                       java.lang.String prompt,
                       java.lang.String help,
                       boolean mute,
                       int size,
                       java.lang.String near_table,
                       java.lang.String far_table,
                       java.lang.String near_key,
                       java.lang.String far_key,
                       java.lang.String far_ident)
Basic setup -- all the normal widget things, plus a lot more of my own. Conventions: my name is the name of the link table.

Parameters:
name - the name of the link table in the database
near_table - the name of the table on the 'near' side of the join.
far_table - the name of the table on the 'far' side of the join.
near_key - the name of the key field in the near table. The column that joins to this in the link table is assumed to have the same name. It is assumed that a value for this can be found in the context at update time.
far_key - the name of the key field in the far table. The column that joins to this in the link table is assumed to have the same name.
far_ident - the name of a field in the far table which contains user-friendly identifying information (e.g. a name)
Method Detail

getOptions

public java.util.Vector getOptions(Context context)
                            throws javax.servlet.ServletException
Query the database for my options.

Overrides:
getOptions in class MenuWidget
Throws:
javax.servlet.ServletException

preProcess

protected void preProcess(Context context)
                   throws DataStoreException,
                          javax.servlet.ServletException
If I have values passed in, update the link table to reflect them. Functionality here needs to be driven down into dbutil; this is messy and depends on key fields being numeric. TODO: rewrite carefully.

Overrides:
preProcess in class MultiSelectWidget
Throws:
DataStoreException
javax.servlet.ServletException

postProcess

protected void postProcess(Context context)
                    throws DataStoreException,
                           javax.servlet.ServletException
Pull my values out of the link table.

Overrides:
postProcess in class Widget
Throws:
DataStoreException
javax.servlet.ServletException
See Also:
LinkTableWidget

layout

public void layout(Context context,
                   int tabIndex)
            throws DataFormatException,
                   javax.servlet.ServletException,
                   java.io.IOException
There's no point in laying out a LinkTableWidget for a record that hasn't yet been created because all attempts to use it will fail.

Overrides:
layout in class ShuffleWidget
Throws:
DataFormatException
javax.servlet.ServletException
java.io.IOException

getTabPlaces

public int getTabPlaces(Context context)
Specialisation:

Overrides:
getTabPlaces in class ShuffleWidget
Parameters:
context -
Returns:
See Also:
ShuffleWidget.getTabPlaces(uk.co.weft.dbutil.Context)

onloadRequest

public java.lang.String onloadRequest(Context context)
                               throws javax.servlet.ServletException
LinkTableWidgets positively need JavaScript scripts to support them!

Overrides:
onloadRequest in class ShuffleWidget
Throws:
javax.servlet.ServletException

jacquard 1.12.0 by The Web Engineering Factory and Toolworks