uk.co.weft.htform
Class LinkTableWidget
java.lang.Object
uk.co.weft.htform.ResourceConsumerImpl
uk.co.weft.domutil.NodeGeneratorImpl
uk.co.weft.htform.Widget
uk.co.weft.htform.MenuWidget
uk.co.weft.htform.MultiSelectWidget
uk.co.weft.htform.ShuffleWidget
uk.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)
| 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 |
|
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.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 java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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 databasenear_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 keyfar_link - the name of the column in the link table which joins
to the farside keyrank - 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 databasenear_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 databasenear_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)
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