01: // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
02: // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
03: // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
04: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
05: // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
06: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
07: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
08: // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
09: // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
10: // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
11: // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
12: // POSSIBILITY OF SUCH DAMAGE.
13: //
14: // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
15: package com.metaboss.enterprise.xi.enhydrabarracuda;
16:
17: import org.w3c.dom.html.HTMLElement;
18:
19: import com.metaboss.enterprise.ui.UIUnexpectedProgramConditionException;
20:
21: /** This class is the abstraction of the element - some portion of the html idenified by id */
22: public abstract class Widget {
23: private String mResourceId = null;
24: private String mFormResourceId = null;
25: private Page mOwnerPage = null;
26:
27: /** Package visibility only - this helper creates an instance of any element */
28: static Widget createInstance(Page pOwnerPage, Class pWidgetClass,
29: String pFormResourceId, String pResourceId)
30: throws IllegalAccessException, InstantiationException {
31: Widget lInstance = (Widget) pWidgetClass.newInstance();
32: // Set up all member variables
33: lInstance.mOwnerPage = pOwnerPage;
34: lInstance.mFormResourceId = pFormResourceId;
35: lInstance.mResourceId = pResourceId;
36: // Returns the instance for further processing
37: return lInstance;
38: }
39:
40: /** Returns id of the control */
41: public Page getOwnerPage() {
42: return mOwnerPage;
43: }
44:
45: /** Returns id of the element in the resource in the page */
46: public String getResourceId() {
47: return mResourceId;
48: }
49:
50: /** Returns the HTML Element this control is bound to */
51: public HTMLElement getBoundDocumentElement() {
52: return mOwnerPage.getBoundDocumentElement(mResourceId);
53: }
54:
55: /** @return array of widget values (size 1 for the single value fields) or null if nothing found */
56: public WidgetModel getModel() {
57: return mOwnerPage.getWidgetModel(mResourceId);
58: }
59:
60: /** This standard method creates an instance of the model object for this widget
61: * @exception UIUnexpectedProgramConditionException thrown if the model can not be created for this widget for some technical reason */
62: public abstract WidgetModel createModel()
63: throws UIUnexpectedProgramConditionException;
64:
65: /** This lifecycle method is expected to render the control's image onto the document
66: * @exception UIUnexpectedProgramConditionException thrown if the widget can not be rendered for some technical reason */
67: public abstract void render()
68: throws UIUnexpectedProgramConditionException;
69: }
|