Re: BTable Example

"JIM & ALISON DOW" <[email protected]>
Newsgroups gmane.comp.java.enhydra.barracuda.general
Message-ID <[email protected]>
Belated thank you!  This helped me get in the right direction.  I was
building a dynamic navigation menu based on a user's role.  This was a
BTable and BLink returned from the table model.

Worked great.

Jim


----- Original Message -----
From: "Denny Chambers" <[email protected]>
To: <[email protected]>
Sent: Tuesday, May 27, 2003 12:42 PM
Subject: Re: [Barracuda] BTable Example


> Here are the examples I put together for using the Table stuff. They are
> pretty simple, but should get you going.
>
> Jacob Kjome wrote:
>
> >
> > Some basic stuff is near the bottom of this page...
> > http://www.barracudamvc.org/Barracuda/CompTest1
> >
> > that matches up with
src/org/enhydra/barracuda/examples/xmlc/CompEx1.java
> >
> > Otherwise, I think Denny Chambers has some test cases for BTable from
> > when he enhanced BTable a little while back. I can't find my copy of
> > that. Denny, can you post that to the list?
> >
> > Jake
> >
> > At 09:28 AM 5/27/2003 -0700, you wrote:
> >
> >> <?xml:namespace prefix="v" /><?xml:namespace prefix="o" />
> >> Can anyone point me to, or if you have an example of: BTable with
> >> TableModel and appropriate directives?
> >>
> >> Thanks…Jim Dow
> >
>



>
/***************************************************************************
****
> * Copyright (c) 2002, bugfixer.org
> * Author : Denny Chambers
> * Revision History :  08/23/2002   Denny Chambers   Initial Work
>
****************************************************************************
***/
>
> package org.bugfixer.btable.pres.screens;
> import javax.servlet.*;
> import javax.servlet.http.*;
> import java.io.*;
> import java.util.*;
> import org.enhydra.barracuda.core.comp.*;
> import org.enhydra.barracuda.core.event.*;
> import org.enhydra.barracuda.core.util.dom.*;
> import org.w3c.dom.*;
> import org.bugfixer.btable.pres.events.render.*;
> import org.bugfixer.btable.pres.events.pub.*;
>
> /**
> * This class will contain the EventListeners responsible for handling the
Get, Do, and Render Events
> *
> * @author Denny Chambers
> *
> */
>
> public class CaptionTest1 extends DefaultEventGateway {
>
>
>     //this defines the various event handlers
>
>     private ListenerFactory getCaptionTest1Factory =
>         new DefaultListenerFactory() {
>             public BaseEventListener getInstance() {
>                 return new GetCaptionTest1Handler();}
>             public String getListenerID() {
>                 return getID(GetCaptionTest1Handler.class);}};
>
>     private ListenerFactory renderCaptionTest1Factory =
>         new DefaultListenerFactory() {
>             public BaseEventListener getInstance() {
>                 return new RenderCaptionTest1Handler();}
>             public String getListenerID() {
>                 return getID(RenderCaptionTest1Handler.class);}};
>
>
>     //-------------------- DefaultEventGateway -------------------
>     /**
>     * Public constructor
>     */
>     public CaptionTest1() {
>         //specify who's interested in what
>         specifyLocalEventInterests(getCaptionTest1Factory,
GetCaptionTest1.class);
>         specifyLocalEventInterests(renderCaptionTest1Factory,
RenderCaptionTest1.class);
>     }
>
>     //------------------------------------------------------------
>     //             Model 2 - Controller Event Handlers
>     //------------------------------------------------------------
>     /**
>     * Event Handlers to hande the Get/Do request
>     *
>     */
>
>     class GetCaptionTest1Handler extends DefaultBaseEventListener {
>
>         /**
>         * This method handles the event
>         */
>         public void handleControlEvent(ControlEventContext context) throws
EventException, ServletException, IOException {
>             BaseEvent event = context.getEvent();
>             DispatchQueue queue = context.getQueue();
>             queue.addEvent(new RenderCaptionTest1(event));
>         }
>     }
>
>     //------------------------------------------------------------
>     //                Model 2 - View Event Handlers
>     //------------------------------------------------------------
>     /**
>     * Event handlers to hander render events.
>     */
>
>
>     class RenderCaptionTest1Handler extends DefaultBaseEventListener {
>
>         /**
>         * This method handles the event
>         */
>         public void handleViewEvent(ViewEventContext context) throws
EventException, ServletException, IOException {
>
>             HttpServletResponse resp = context.getResponse();
>         ViewContext vc = new DefaultViewContext(context);
>         Document page =
DefaultDOMLoader.getGlobalInstance().getDOM(CaptionTestHTML.class);
>             Node node = page.getDocumentElement();
>             BTemplate templateComp = new BTemplate();
>             templateComp.setView(new DefaultTemplateView(node));
>             templateComp.addModel(new CaptionTest1Model());
>             try{
>                 templateComp.render(vc);
>             }
>             catch (RenderException re){
>                 re.printStackTrace();
>             }
>
>             try
>             {
>                 resp.setContentType("text/html; charset=UTF-8");
>                 new DefaultDOMWriter(true).write(page, resp.getWriter());
>             }
>             catch (IOException io) {
>                 io.printStackTrace();
>             }
>         }
>     }
>
>     //------------------------------------------------------------
>     //                The Model for this Screen
>     //------------------------------------------------------------
>     class CaptionTest1Model extends AbstractTemplateModel {
>
>         private CaptionTest1HeaderModel headerModel;
>         private CaptionTest1FooterModel footerModel;
>         private CaptionTest1TableModel model;
>
>         public CaptionTest1Model() {
>             headerModel = new CaptionTest1HeaderModel();
>             footerModel = new CaptionTest1FooterModel();
>             model = new CaptionTest1TableModel();
>         }
>
>         //register the model by name
>         public String getName() {
>             return "CaptionTest";
>         }
>
>         //provide items by key
>         public Object getItem(String key) {
>             if(key.equals("tableExample1")){
>                 BTable bt = new BTable();
>                 bt.setModel(model);
>                 return bt;
>             }
>             else if(key.equals("tableExample2")){
>                 BTable bt = new BTable();
>                 bt.setModel(model);
>                 bt.setHeaderModel(headerModel);
>                 return bt;
>             }
>             else if(key.equals("tableExample3")){
>                 BTable bt = new BTable();
>                 bt.setModel(model);
>                 bt.setHeaderModel(headerModel);
>                 bt.setFooterModel(footerModel);
>                 return bt;
>             }
>             else if(key.equals("linkExample1")){
>                 BText bt = new BText("<big><b>1</b></big>");
>                 bt.setAllowMarkupInText(true);
>                 return bt;
>             }
>             else if(key.equals("linkExample2")){
>                 return "2";
>             }
>             else if(key.equals("linkExample3")){
>                 return "3";
>             }
>             else if(key.equals("linkExample4")){
>                 return "4";
>             }
>             else if(key.equals("linkExample5")){
>                 return "5";
>             }
>             else if(key.equals("linkExample6")){
>                 return "6";
>             }
>             return super.getItem(key);
>         }
>     }
>
>     //------------------------------------------------------------
>     //                       Table Models
>     //------------------------------------------------------------
>
>     class CaptionTest1HeaderModel extends AbstractTableModel{
>
>         private String[] header = {"Attribute", "Description"};
>
>         CaptionTest1HeaderModel(){
>             ;
>         }
>
>         //From TableModel Interface
>
>         public int getRowCount(){
>             return 1;
>         }
>
>         public int getColumnCount(){
>             return header.length;
>         }
>
>         public Object getItemAt(int row, int col){
>             if(row != 0){
>                 return null;
>             }
>
>             if(col < 0 || col >= header.length){
>                 return null;
>             }
>
>             return header[col];
>         }
>     }
>
>     class CaptionTest1FooterModel extends AbstractTableModel{
>
>         private String[] footer = {"Attribute", "Description"};
>
>         CaptionTest1FooterModel(){
>             ;
>         }
>
>         //From TableModel Interface
>
>         public int getRowCount(){
>             return 1;
>         }
>
>         public int getColumnCount(){
>             return footer.length;
>         }
>
>         public Object getItemAt(int row, int col){
>             if(row != 0){
>                 return null;
>             }
>
>             if(col < 0 || col >= footer.length){
>                 return null;
>             }
>
>             return footer[col];
>         }
>     }
>
>     class CaptionTest1TableModel extends AbstractTableModel{
>
>         private Vector tableModel;
>         CaptionTest1TableModel(){
>             String[] attributes = { "align", "id", "class", "style",
"title",
>                                     "lang", "dir", "onclick",
"ondblclick",
>                                     "onmousedown","onmouseup",
"onmouseover",
>                                     "onmouseout", "onkeypress",
"onkeydown",
>                                     "onkeyup"
>                                   };
>
>             String[] description = {
>                 "Deprecated",
>                 "This attribute assigns a name to an element. This name
must be unique in a document.",
>                 "This attribute assigns a class name or set of class names
to an element. Any number of elements may be assigned the same class name or
names. Multiple class names must be separated by white space characters.",
>                 "This attribute specifies style information for the
current element.",
>                 "This attribute offers advisory information about the
element for which it is set.",
>                 "This attribute specifies the base language of an
element's attribute values and text content. The default value of this
attribute is unknown.",
>                 "This attribute specifies the base direction of
directionally neutral text (i.e., text that doesn't have inherent
directionality as defined in [UNICODE]) in an element's content and
attribute values. Possible values: LTR - Left-to-right text or table, RTL -
Right-to-left text or table.",
>                 "The onclick event occurs when the pointing device button
is clicked over an element. This attribute may be used with most elements.",
>                 "The ondblclick event occurs when the pointing device
button is double clicked over an element. This attribute may be used with
most elements.",
>                 "The onmousedown event occurs when the pointing device
button is pressed over an element. This attribute may be used with most
elements.",
>                 "The onmouseup event occurs when the pointing device
button is released over an element. This attribute may be used with most
elements.",
>                 "The onmouseover event occurs when the pointing device is
moved onto an element. This attribute may be used with most elements.",
>                 "The onmouseout event occurs when the pointing device is
moved away from an element. This attribute may be used with most elements.",
>                 "The onkeypress event occurs when a key is pressed and
released over an element. This attribute may be used with most elements.",
>                 "The onkeydown event occurs when a key is pressed down
over an element. This attribute may be used with most elements.",
>                 "The onkeyup event occurs when a key is released over an
element. This attribute may be used with most elements.",
>             };
>
>             tableModel = new Vector();
>             for(int i = 0; i < attributes.length; i++){
>                 Vector newRow = new Vector();
>                 newRow.add(attributes[i]);
>                 newRow.add(description[i]);
>                 tableModel.add(newRow);
>             }
>
>         }
>
>         //From TableModel Interface
>
>         public int getRowCount(){
>             return tableModel.size();
>         }
>
>         public int getColumnCount(){
>             return 2;
>         }
>
>         public Object getItemAt(int row, int col){
>             if(row < 0 || row >= tableModel.size()){
>                 return null;
>             }
>
>             if(col < 0 || col >= 2){
>                 return null;
>             }
>
>             return ((Vector) tableModel.elementAt(row)).elementAt(col);
>         }
>     }
> }
>



>
/***************************************************************************
****
> * Copyright (c) 2002, bugfixer.org
> * Author : Denny Chambers
> * Revision History :  08/23/2002   Denny Chambers   Initial Work
>
****************************************************************************
***/
>
> package org.bugfixer.btable.pres.screens;
> import javax.servlet.*;
> import javax.servlet.http.*;
> import java.io.*;
> import java.util.*;
> import org.enhydra.barracuda.core.comp.*;
> import org.enhydra.barracuda.core.event.*;
> import org.enhydra.barracuda.core.util.dom.*;
> import org.w3c.dom.*;
> import org.bugfixer.btable.pres.events.render.*;
> import org.bugfixer.btable.pres.events.pub.*;
>
> /**
> * This class will contain the EventListeners responsible for handling the
Get, Do, and Render Events
> *
> * @author Denny Chambers
> *
> */
>
> public class CaptionTest2 extends DefaultEventGateway {
>
>
>     //this defines the various event handlers
>
>     private ListenerFactory getCaptionTest2Factory =
>         new DefaultListenerFactory() {
>             public BaseEventListener getInstance() {
>                 return new GetCaptionTest2Handler();}
>             public String getListenerID() {
>                 return getID(GetCaptionTest2Handler.class);}};
>
>     private ListenerFactory renderCaptionTest2Factory =
>         new DefaultListenerFactory() {
>             public BaseEventListener getInstance() {
>                 return new RenderCaptionTest2Handler();}
>             public String getListenerID() {
>                 return getID(RenderCaptionTest2Handler.class);}};
>
>
>     //-------------------- DefaultEventGateway -------------------
>     /**
>     * Public constructor
>     */
>     public CaptionTest2() {
>         //specify who's interested in what
>         specifyLocalEventInterests(getCaptionTest2Factory,
GetCaptionTest2.class);
>         specifyLocalEventInterests(renderCaptionTest2Factory,
RenderCaptionTest2.class);
>     }
>
>     //------------------------------------------------------------
>     //             Model 2 - Controller Event Handlers
>     //------------------------------------------------------------
>     /**
>     * Event Handlers to hande the Get/Do request
>     *
>     */
>
>     class GetCaptionTest2Handler extends DefaultBaseEventListener {
>
>         /**
>         * This method handles the event
>         */
>         public void handleControlEvent(ControlEventContext context) throws
EventException, ServletException, IOException {
>             BaseEvent event = context.getEvent();
>             DispatchQueue queue = context.getQueue();
>             queue.addEvent(new RenderCaptionTest2(event));
>         }
>     }
>
>     //------------------------------------------------------------
>     //                Model 2 - View Event Handlers
>     //------------------------------------------------------------
>     /**
>     * Event handlers to hander render events.
>     */
>
>
>     class RenderCaptionTest2Handler extends DefaultBaseEventListener {
>
>         /**
>         * This method handles the event
>         */
>         public void handleViewEvent(ViewEventContext context) throws
EventException, ServletException, IOException {
>
>             HttpServletResponse resp = context.getResponse();
>         ViewContext vc = new DefaultViewContext(context);
>         Document page =
DefaultDOMLoader.getGlobalInstance().getDOM(CaptionTest1HTML.class);
>             Node node = page.getDocumentElement();
>             BTemplate templateComp = new BTemplate();
>             templateComp.setView(new DefaultTemplateView(node));
>             templateComp.addModel(new CaptionTestModel());
>             try{
>                 templateComp.render(vc);
>             }
>             catch (RenderException re){
>                 re.printStackTrace();
>             }
>
>             try
>             {
>                 resp.setContentType("text/html; charset=UTF-8");
>                 new DefaultDOMWriter(true).write(page, resp.getWriter());
>             }
>             catch (IOException io) {
>                 io.printStackTrace();
>             }
>         }
>     }
>
>     //------------------------------------------------------------
>     //                The Model for this Screen
>     //------------------------------------------------------------
>     class CaptionTestModel extends AbstractTemplateModel {
>
>         private CaptionTestHeaderModel headerModel;
>         private CaptionTestFooterModel footerModel;
>         private CaptionTestTableModel model;
>
>         public CaptionTestModel() {
>             headerModel = new CaptionTestHeaderModel();
>             footerModel = new CaptionTestFooterModel();
>             model = new CaptionTestTableModel();
>         }
>
>         //register the model by name
>         public String getName() {
>             return "CaptionTest";
>         }
>
>         //provide items by key
>         public Object getItem(String key) {
>             if(key.equals("tableExample1")){
>                 BTable bt = new BTable();
>                 bt.setModel(model);
>                 bt.setHeaderModel(headerModel);
>                 bt.setFooterModel(footerModel);
>                 return bt;
>             }
>             else if(key.equals("title")){
>                 return "Caption Test Example 2";
>             }
>             else if(key.equals("desc")){
>                 StringBuffer sb = new StringBuffer();
>                 sb.append("First I will start with a simple test. This
table ");
>                 sb.append("has a caption already defined with the proper
text ");
>                 sb.append("in the caption. The idea here is that the table
");
>                 sb.append("(thead, tfoot, and tbody) will be updated by
");
>                 sb.append("their respective models, but the caption will
stay ");
>                 sb.append("intact. I feel like this will be a common
occurance, ");
>                 sb.append("since most developers will know what the table
does ");
>                 sb.append("before it is rendered. The caption will ");
>                 sb.append("already have a description about the table in
it, ");
>                 sb.append("and only the table will need to be dynamically
updated.");
>                 return sb.toString();
>             }
>             else if(key.equals("linkExample1")){
>                 return "1";
>             }
>             else if(key.equals("linkExample2")){
>                 BText bt = new BText("<big><b>2</b></big>");
>                 bt.setAllowMarkupInText(true);
>                 return bt;
>             }
>             else if(key.equals("linkExample3")){
>                 return "3";
>             }
>             else if(key.equals("linkExample4")){
>                 return "4";
>             }
>             else if(key.equals("linkExample5")){
>                 return "5";
>             }
>             else if(key.equals("linkExample6")){
>                 return "6";
>             }
>             return super.getItem(key);
>         }
>     }
>
>     //------------------------------------------------------------
>     //                       Table Models
>     //------------------------------------------------------------
>
>     class CaptionTestHeaderModel extends AbstractTableModel{
>
>         private String[] header = {"Attribute", "Description"};
>
>         CaptionTestHeaderModel(){
>             ;
>         }
>
>         //From TableModel Interface
>
>         public int getRowCount(){
>             return 1;
>         }
>
>         public int getColumnCount(){
>             return header.length;
>         }
>
>         public Object getItemAt(int row, int col){
>             if(row != 0){
>                 return null;
>             }
>
>             if(col < 0 || col >= header.length){
>                 return null;
>             }
>
>             return header[col];
>         }
>     }
>
>     class CaptionTestFooterModel extends AbstractTableModel{
>
>         private String[] footer = {"Attribute", "Description"};
>
>         CaptionTestFooterModel(){
>             ;
>         }
>
>         //From TableModel Interface
>
>         public int getRowCount(){
>             return 1;
>         }
>
>         public int getColumnCount(){
>             return footer.length;
>         }
>
>         public Object getItemAt(int row, int col){
>             if(row != 0){
>                 return null;
>             }
>
>             if(col < 0 || col >= footer.length){
>                 return null;
>             }
>
>             return footer[col];
>         }
>     }
>
>     class CaptionTestTableModel extends AbstractTableModel{
>
>         private Vector tableModel;
>         CaptionTestTableModel(){
>             String[] attributes = { "align", "id", "class", "style",
"title",
>                                     "lang", "dir", "onclick",
"ondblclick",
>                                     "onmousedown","onmouseup",
"onmouseover",
>                                     "onmouseout", "onkeypress",
"onkeydown",
>                                     "onkeyup"
>                                   };
>
>             String[] description = {
>                 "Deprecated",
>                 "This attribute assigns a name to an element. This name
must be unique in a document.",
>                 "This attribute assigns a class name or set of class names
to an element. Any number of elements may be assigned the same class name or
names. Multiple class names must be separated by white space characters.",
>                 "This attribute specifies style information for the
current element.",
>                 "This attribute offers advisory information about the
element for which it is set.",
>                 "This attribute specifies the base language of an
element's attribute values and text content. The default value of this
attribute is unknown.",
>                 "This attribute specifies the base direction of
directionally neutral text (i.e., text that doesn't have inherent
directionality as defined in [UNICODE]) in an element's content and
attribute values. Possible values: LTR - Left-to-right text or table, RTL -
Right-to-left text or table.",
>                 "The onclick event occurs when the pointing device button
is clicked over an element. This attribute may be used with most elements.",
>                 "The ondblclick event occurs when the pointing device
button is double clicked over an element. This attribute may be used with
most elements.",
>                 "The onmousedown event occurs when the pointing device
button is pressed over an element. This attribute may be used with most
elements.",
>                 "The onmouseup event occurs when the pointing device
button is released over an element. This attribute may be used with most
elements.",
>                 "The onmouseover event occurs when the pointing device is
moved onto an element. This attribute may be used with most elements.",
>                 "The onmouseout event occurs when the pointing device is
moved away from an element. This attribute may be used with most elements.",
>                 "The onkeypress event occurs when a key is pressed and
released over an element. This attribute may be used with most elements.",
>                 "The onkeydown event occurs when a key is pressed down
over an element. This attribute may be used with most elements.",
>                 "The onkeyup event occurs when a key is released over an
element. This attribute may be used with most elements.",
>             };
>
>             tableModel = new Vector();
>             for(int i = 0; i < attributes.length; i++){
>                 Vector newRow = new Vector();
>                 newRow.add(attributes[i]);
>                 newRow.add(description[i]);
>                 tableModel.add(newRow);
>             }
>
>         }
>
>         //From TableModel Interface
>
>         public int getRowCount(){
>             return tableModel.size();
>         }
>
>         public int getColumnCount(){
>             return 2;
>         }
>
>         public Object getItemAt(int row, int col){
>             if(row < 0 || row >= tableModel.size()){
>                 return null;
>             }
>
>             if(col < 0 || col >= 2){
>                 return null;
>             }
>
>             return ((Vector) tableModel.elementAt(row)).elementAt(col);
>         }
>     }
> }
>



>
/***************************************************************************
****
> * Copyright (c) 2002, bugfixer.org
> * Author : Denny Chambers
> * Revision History :  08/23/2002   Denny Chambers   Initial Work
>
****************************************************************************
***/
>
> package org.bugfixer.btable.pres.screens;
> import javax.servlet.*;
> import javax.servlet.http.*;
> import java.io.*;
> import java.util.*;
> import org.enhydra.barracuda.core.comp.*;
> import org.enhydra.barracuda.core.event.*;
> import org.enhydra.barracuda.core.util.dom.*;
> import org.w3c.dom.*;
> import org.bugfixer.btable.pres.events.render.*;
> import org.bugfixer.btable.pres.events.pub.*;
>
> /**
> * This class will contain the EventListeners responsible for handling the
Get, Do, and Render Events
> *
> * @author Denny Chambers
> *
> */
>
> public class CaptionTest3 extends DefaultEventGateway {
>
>
>     //this defines the various event handlers
>
>     private ListenerFactory getCaptionTest3Factory =
>         new DefaultListenerFactory() {
>             public BaseEventListener getInstance() {
>                 return new GetCaptionTest3Handler();}
>             public String getListenerID() {
>                 return getID(GetCaptionTest3Handler.class);}};
>
>     private ListenerFactory renderCaptionTest3Factory =
>         new DefaultListenerFactory() {
>             public BaseEventListener getInstance() {
>                 return new RenderCaptionTest3Handler();}
>             public String getListenerID() {
>                 return getID(RenderCaptionTest3Handler.class);}};
>
>
>     //-------------------- DefaultEventGateway -------------------
>     /**
>     * Public constructor
>     */
>     public CaptionTest3() {
>         //specify who's interested in what
>         specifyLocalEventInterests(getCaptionTest3Factory,
GetCaptionTest3.class);
>         specifyLocalEventInterests(renderCaptionTest3Factory,
RenderCaptionTest3.class);
>     }
>
>     //------------------------------------------------------------
>     //             Model 2 - Controller Event Handlers
>     //------------------------------------------------------------
>     /**
>     * Event Handlers to hande the Get/Do request
>     *
>     */
>
>     class GetCaptionTest3Handler extends DefaultBaseEventListener {
>
>         /**
>         * This method handles the event
>         */
>         public void handleControlEvent(ControlEventContext context) throws
EventException, ServletException, IOException {
>             BaseEvent event = context.getEvent();
>             DispatchQueue queue = context.getQueue();
>             queue.addEvent(new RenderCaptionTest3(event));
>         }
>     }
>
>     //------------------------------------------------------------
>     //                Model 2 - View Event Handlers
>     //------------------------------------------------------------
>     /**
>     * Event handlers to hander render events.
>     */
>
>
>     class RenderCaptionTest3Handler extends DefaultBaseEventListener {
>
>         /**
>         * This method handles the event
>         */
>         public void handleViewEvent(ViewEventContext context) throws
EventException, ServletException, IOException {
>
>             HttpServletResponse resp = context.getResponse();
>         ViewContext vc = new DefaultViewContext(context);
>         Document page =
DefaultDOMLoader.getGlobalInstance().getDOM(CaptionTest1HTML.class);
>             Node node = page.getDocumentElement();
>             BTemplate templateComp = new BTemplate();
>             templateComp.setView(new DefaultTemplateView(node));
>             templateComp.addModel(new CaptionTestModel());
>             try{
>                 templateComp.render(vc);
>             }
>             catch (RenderException re){
>                 re.printStackTrace();
>             }
>
>             try
>             {
>                 resp.setContentType("text/html; charset=UTF-8");
>                 new DefaultDOMWriter(true).write(page, resp.getWriter());
>             }
>             catch (IOException io) {
>                 io.printStackTrace();
>             }
>         }
>     }
>
>     //------------------------------------------------------------
>     //                The Model for this Screen
>     //------------------------------------------------------------
>     class CaptionTestModel extends AbstractTemplateModel {
>
>         private CaptionTestHeaderModel headerModel;
>         private CaptionTestFooterModel footerModel;
>         private CaptionTestTableModel model;
>
>         public CaptionTestModel() {
>             headerModel = new CaptionTestHeaderModel();
>             footerModel = new CaptionTestFooterModel();
>             model = new CaptionTestTableModel();
>         }
>
>         //register the model by name
>         public String getName() {
>             return "CaptionTest";
>         }
>
>         //provide items by key
>         public Object getItem(String key) {
>             if(key.equals("tableExample1")){
>                 BTable bt = new BTable();
>                 bt.setModel(model);
>                 bt.setHeaderModel(headerModel);
>                 bt.setFooterModel(footerModel);
>                 bt.setCaption(new BText("This text was set using a BText
object"));
>                 return bt;
>             }
>             else if(key.equals("title")){
>                 return "Caption Test Example 3";
>             }
>             else if(key.equals("desc")){
>                 StringBuffer sb = new StringBuffer();
>                 sb.append("Now I will dynamically update the caption
element ");
>                 sb.append("using a BText object along with the tbody, ");
>                 sb.append("thead, and the tfoot. ");
>                 return sb.toString();
>             }
>             else if(key.equals("linkExample1")){
>                 return "1";
>             }
>             else if(key.equals("linkExample2")){
>                 return "2";
>             }
>             else if(key.equals("linkExample3")){
>                 BText bt = new BText("<big><b>3</b></big>");
>                 bt.setAllowMarkupInText(true);
>                 return bt;
>             }
>             else if(key.equals("linkExample4")){
>                 return "4";
>             }
>             else if(key.equals("linkExample5")){
>                 return "5";
>             }
>             else if(key.equals("linkExample6")){
>                 return "6";
>             }
>             return super.getItem(key);
>         }
>     }
>
>     //------------------------------------------------------------
>     //                       Table Models
>     //------------------------------------------------------------
>
>     class CaptionTestHeaderModel extends AbstractTableModel{
>
>         private String[] header = {"Attribute", "Description"};
>
>         CaptionTestHeaderModel(){
>             ;
>         }
>
>         //From TableModel Interface
>
>         public int getRowCount(){
>             return 1;
>         }
>
>         public int getColumnCount(){
>             return header.length;
>         }
>
>         public Object getItemAt(int row, int col){
>             if(row != 0){
>                 return null;
>             }
>
>             if(col < 0 || col >= header.length){
>                 return null;
>             }
>
>             return header[col];
>         }
>     }
>
>     class CaptionTestFooterModel extends AbstractTableModel{
>
>         private String[] footer = {"Attribute", "Description"};
>
>         CaptionTestFooterModel(){
>             ;
>         }
>
>         //From TableModel Interface
>
>         public int getRowCount(){
>             return 1;
>         }
>
>         public int getColumnCount(){
>             return footer.length;
>         }
>
>         public Object getItemAt(int row, int col){
>             if(row != 0){
>                 return null;
>             }
>
>             if(col < 0 || col >= footer.length){
>                 return null;
>             }
>
>             return footer[col];
>         }
>     }
>
>     class CaptionTestTableModel extends AbstractTableModel{
>
>         private Vector tableModel;
>         CaptionTestTableModel(){
>             String[] attributes = { "align", "id", "class", "style",
"title",
>                                     "lang", "dir", "onclick",
"ondblclick",
>                                     "onmousedown","onmouseup",
"onmouseover",
>                                     "onmouseout", "onkeypress",
"onkeydown",
>                                     "onkeyup"
>                                   };
>
>             String[] description = {
>                 "Deprecated",
>                 "This attribute assigns a name to an element. This name
must be unique in a document.",
>                 "This attribute assigns a class name or set of class names
to an element. Any number of elements may be assigned the same class name or
names. Multiple class names must be separated by white space characters.",
>                 "This attribute specifies style information for the
current element.",
>                 "This attribute offers advisory information about the
element for which it is set.",
>                 "This attribute specifies the base language of an
element's attribute values and text content. The default value of this
attribute is unknown.",
>                 "This attribute specifies the base direction of
directionally neutral text (i.e., text that doesn't have inherent
directionality as defined in [UNICODE]) in an element's content and
attribute values. Possible values: LTR - Left-to-right text or table, RTL -
Right-to-left text or table.",
>                 "The onclick event occurs when the pointing device button
is clicked over an element. This attribute may be used with most elements.",
>                 "The ondblclick event occurs when the pointing device
button is double clicked over an element. This attribute may be used with
most elements.",
>                 "The onmousedown event occurs when the pointing device
button is pressed over an element. This attribute may be used with most
elements.",
>                 "The onmouseup event occurs when the pointing device
button is released over an element. This attribute may be used with most
elements.",
>                 "The onmouseover event occurs when the pointing device is
moved onto an element. This attribute may be used with most elements.",
>                 "The onmouseout event occurs when the pointing device is
moved away from an element. This attribute may be used with most elements.",
>                 "The onkeypress event occurs when a key is pressed and
released over an element. This attribute may be used with most elements.",
>                 "The onkeydown event occurs when a key is pressed down
over an element. This attribute may be used with most elements.",
>                 "The onkeyup event occurs when a key is released over an
element. This attribute may be used with most elements.",
>             };
>
>             tableModel = new Vector();
>             for(int i = 0; i < attributes.length; i++){
>                 Vector newRow = new Vector();
>                 newRow.add(attributes[i]);
>                 newRow.add(description[i]);
>                 tableModel.add(newRow);
>             }
>
>         }
>
>         //From TableModel Interface
>
>         public int getRowCount(){
>             return tableModel.size();
>         }
>
>         public int getColumnCount(){
>             return 2;
>         }
>
>         public Object getItemAt(int row, int col){
>             if(row < 0 || row >= tableModel.size()){
>                 return null;
>             }
>
>             if(col < 0 || col >= 2){
>                 return null;
>             }
>
>             return ((Vector) tableModel.elementAt(row)).elementAt(col);
>         }
>     }
> }
>



>
/***************************************************************************
****
> * Copyright (c) 2002, bugfixer.org
> * Author : Denny Chambers
> * Revision History :  08/23/2002   Denny Chambers   Initial Work
>
****************************************************************************
***/
>
> package org.bugfixer.btable.pres.screens;
> import javax.servlet.*;
> import javax.servlet.http.*;
> import java.io.*;
> import java.util.*;
> import org.enhydra.barracuda.core.comp.*;
> import org.enhydra.barracuda.core.event.*;
> import org.enhydra.barracuda.core.util.dom.*;
> import org.w3c.dom.*;
> import org.bugfixer.btable.pres.events.render.*;
> import org.bugfixer.btable.pres.events.pub.*;
>
> /**
> * This class will contain the EventListeners responsible for handling the
Get, Do, and Render Events
> *
> * @author Denny Chambers
> *
> */
>
> public class CaptionTest4 extends DefaultEventGateway {
>
>
>     //this defines the various event handlers
>
>     private ListenerFactory getCaptionTest4Factory =
>         new DefaultListenerFactory() {
>             public BaseEventListener getInstance() {
>                 return new GetCaptionTest4Handler();}
>             public String getListenerID() {
>                 return getID(GetCaptionTest4Handler.class);}};
>
>     private ListenerFactory renderCaptionTest4Factory =
>         new DefaultListenerFactory() {
>             public BaseEventListener getInstance() {
>                 return new RenderCaptionTest4Handler();}
>             public String getListenerID() {
>                 return getID(RenderCaptionTest4Handler.class);}};
>
>
>     //-------------------- DefaultEventGateway -------------------
>     /**
>     * Public constructor
>     */
>     public CaptionTest4() {
>         //specify who's interested in what
>         specifyLocalEventInterests(getCaptionTest4Factory,
GetCaptionTest4.class);
>         specifyLocalEventInterests(renderCaptionTest4Factory,
RenderCaptionTest4.class);
>     }
>
>     //------------------------------------------------------------
>     //             Model 2 - Controller Event Handlers
>     //------------------------------------------------------------
>     /**
>     * Event Handlers to hande the Get/Do request
>     *
>     */
>
>     class GetCaptionTest4Handler extends DefaultBaseEventListener {
>
>         /**
>         * This method handles the event
>         */
>         public void handleControlEvent(ControlEventContext context) throws
EventException, ServletException, IOException {
>             BaseEvent event = context.getEvent();
>             DispatchQueue queue = context.getQueue();
>             queue.addEvent(new RenderCaptionTest4(event));
>         }
>     }
>
>     //------------------------------------------------------------
>     //                Model 2 - View Event Handlers
>     //------------------------------------------------------------
>     /**
>     * Event handlers to hander render events.
>     */
>
>
>     class RenderCaptionTest4Handler extends DefaultBaseEventListener {
>
>         /**
>         * This method handles the event
>         */
>         public void handleViewEvent(ViewEventContext context) throws
EventException, ServletException, IOException {
>
>             HttpServletResponse resp = context.getResponse();
>         ViewContext vc = new DefaultViewContext(context);
>         Document page =
DefaultDOMLoader.getGlobalInstance().getDOM(CaptionTest1HTML.class);
>             Node node = page.getDocumentElement();
>             BTemplate templateComp = new BTemplate();
>             templateComp.setView(new DefaultTemplateView(node));
>             templateComp.addModel(new CaptionTestModel());
>             try{
>                 templateComp.render(vc);
>             }
>             catch (RenderException re){
>                 re.printStackTrace();
>             }
>
>             try
>             {
>                 resp.setContentType("text/html; charset=UTF-8");
>                 new DefaultDOMWriter(true).write(page, resp.getWriter());
>             }
>             catch (IOException io) {
>                 io.printStackTrace();
>             }
>         }
>     }
>
>     //------------------------------------------------------------
>     //                The Model for this Screen
>     //------------------------------------------------------------
>     class CaptionTestModel extends AbstractTemplateModel {
>
>         private CaptionTestHeaderModel headerModel;
>         private CaptionTestFooterModel footerModel;
>         private CaptionTestTableModel model;
>
>         public CaptionTestModel() {
>             headerModel = new CaptionTestHeaderModel();
>             footerModel = new CaptionTestFooterModel();
>             model = new CaptionTestTableModel();
>         }
>
>         //register the model by name
>         public String getName() {
>             return "CaptionTest";
>         }
>
>         //provide items by key
>         public Object getItem(String key) {
>             if(key.equals("tableExample1")){
>                 BTable bt = new BTable();
>                 bt.setModel(model);
>                 bt.setHeaderModel(headerModel);
>                 bt.setFooterModel(footerModel);
>                 StringBuffer sb = new StringBuffer();
>                 sb.append("The caption element allows inline html to be
used with in it. ");
>                 sb.append("Here is examples of the fontstyle html elements
that are allowed: ");
>                 sb.append("<tt>teletype text</tt>, <i>italic</i>,
<b>bold</b>, <big>big</big>, ");
>                 sb.append("and <small>small</small>. Captions also allow
Phrase elements: ");
>                 sb.append("<em>emphasis</em>, <strong>strong</strong>,
<dfn>defining instance</dfn> ");
>                 sb.append(", <code>code</code>, <samp>sample</samp>,
<kbd>keyboard text</kbd>, ");
>                 sb.append("<var>variable or program argument</var>,
<cite>cite</cite>, ");
>                 sb.append("<abbr>abbr</abbr>, and
<acronym>acronym</acronym>. Special html ");
>                 sb.append("elements are allowed as well, these include: A,
IMG, OBJECT, ");
>                 sb.append("BR, SCRIPT, MAP, Q, SUB, SUP, SPAN, BDO. The
last set of html ");
>                 sb.append("elements allowed, are the formctrl elements:
INPUT, SELECT, TEXTAREA, LABEL, BUTTON");
>                 BText text = new BText(sb.toString());
>                 text.setAllowMarkupInText(true);
>                 bt.setCaption(text);
>                 return bt;
>             }
>             else if(key.equals("title")){
>                 return "Caption Test Example 4";
>             }
>             else if(key.equals("desc")){
>                 StringBuffer sb = new StringBuffer();
>                 sb.append("Now I will dynamically update the caption
element ");
>                 sb.append("using a BText object with html in the text
along with the tbody, ");
>                 sb.append("thead, and the tfoot. ");
>                 return sb.toString();
>             }
>             else if(key.equals("linkExample1")){
>                 return "1";
>             }
>             else if(key.equals("linkExample2")){
>                 return "2";
>             }
>             else if(key.equals("linkExample3")){
>                 return "3";
>             }
>             else if(key.equals("linkExample4")){
>                 BText bt = new BText("<big><b>4</b></big>");
>                 bt.setAllowMarkupInText(true);
>                 return bt;
>             }
>             else if(key.equals("linkExample5")){
>                 return "5";
>             }
>             else if(key.equals("linkExample6")){
>                 return "6";
>             }
>             return super.getItem(key);
>         }
>     }
>
>     //------------------------------------------------------------
>     //                       Table Models
>     //------------------------------------------------------------
>
>     class CaptionTestHeaderModel extends AbstractTableModel{
>
>         private String[] header = {"Attribute", "Description"};
>
>         CaptionTestHeaderModel(){
>             ;
>         }
>
>         //From TableModel Interface
>
>         public int getRowCount(){
>             return 1;
>         }
>
>         public int getColumnCount(){
>             return header.length;
>         }
>
>         public Object getItemAt(int row, int col){
>             if(row != 0){
>                 return null;
>             }
>
>             if(col < 0 || col >= header.length){
>                 return null;
>             }
>
>             return header[col];
>         }
>     }
>
>     class CaptionTestFooterModel extends AbstractTableModel{
>
>         private String[] footer = {"Attribute", "Description"};
>
>         CaptionTestFooterModel(){
>             ;
>         }
>
>         //From TableModel Interface
>
>         public int getRowCount(){
>             return 1;
>         }
>
>         public int getColumnCount(){
>             return footer.length;
>         }
>
>         public Object getItemAt(int row, int col){
>             if(row != 0){
>                 return null;
>             }
>
>             if(col < 0 || col >= footer.length){
>                 return null;
>             }
>
>             return footer[col];
>         }
>     }
>
>     class CaptionTestTableModel extends AbstractTableModel{
>
>         private Vector tableModel;
>         CaptionTestTableModel(){
>             String[] attributes = { "align", "id", "class", "style",
"title",
>                                     "lang", "dir", "onclick",
"ondblclick",
>                                     "onmousedown","onmouseup",
"onmouseover",
>                                     "onmouseout", "onkeypress",
"onkeydown",
>                                     "onkeyup"
>                                   };
>
>             String[] description = {
>                 "Deprecated",
>                 "This attribute assigns a name to an element. This name
must be unique in a document.",
>                 "This attribute assigns a class name or set of class names
to an element. Any number of elements may be assigned the same class name or
names. Multiple class names must be separated by white space characters.",
>                 "This attribute specifies style information for the
current element.",
>                 "This attribute offers advisory information about the
element for which it is set.",
>                 "This attribute specifies the base language of an
element's attribute values and text content. The default value of this
attribute is unknown.",
>                 "This attribute specifies the base direction of
directionally neutral text (i.e., text that doesn't have inherent
directionality as defined in [UNICODE]) in an element's content and
attribute values. Possible values: LTR - Left-to-right text or table, RTL -
Right-to-left text or table.",
>                 "The onclick event occurs when the pointing device button
is clicked over an element. This attribute may be used with most elements.",
>                 "The ondblclick event occurs when the pointing device
button is double clicked over an element. This attribute may be used with
most elements.",
>                 "The onmousedown event occurs when the pointing device
button is pressed over an element. This attribute may be used with most
elements.",
>                 "The onmouseup event occurs when the pointing device
button is released over an element. This attribute may be used with most
elements.",
>                 "The onmouseover event occurs when the pointing device is
moved onto an element. This attribute may be used with most elements.",
>                 "The onmouseout event occurs when the pointing device is
moved away from an element. This attribute may be used with most elements.",
>                 "The onkeypress event occurs when a key is pressed and
released over an element. This attribute may be used with most elements.",
>                 "The onkeydown event occurs when a key is pressed down
over an element. This attribute may be used with most elements.",
>                 "The onkeyup event occurs when a key is released over an
element. This attribute may be used with most elements.",
>             };
>
>             tableModel = new Vector();
>             for(int i = 0; i < attributes.length; i++){
>                 Vector newRow = new Vector();
>                 newRow.add(attributes[i]);
>                 newRow.add(description[i]);
>                 tableModel.add(newRow);
>             }
>
>         }
>
>         //From TableModel Interface
>
>         public int getRowCount(){
>             return tableModel.size();
>         }
>
>         public int getColumnCount(){
>             return 2;
>         }
>
>         public Object getItemAt(int row, int col){
>             if(row < 0 || row >= tableModel.size()){
>                 return null;
>             }
>
>             if(col < 0 || col >= 2){
>                 return null;
>             }
>
>             return ((Vector) tableModel.elementAt(row)).elementAt(col);
>         }
>     }
> }
>



>
/***************************************************************************
****
> * Copyright (c) 2002, bugfixer.org
> * Author : Denny Chambers
> * Revision History :  08/23/2002   Denny Chambers   Initial Work
>
****************************************************************************
***/
>
> package org.bugfixer.btable.pres.screens;
> import javax.servlet.*;
> import javax.servlet.http.*;
> import java.io.*;
> import java.util.*;
> import org.enhydra.barracuda.core.comp.*;
> import org.enhydra.barracuda.core.event.*;
> import org.enhydra.barracuda.core.util.dom.*;
> import org.w3c.dom.*;
> import org.bugfixer.btable.pres.events.render.*;
> import org.bugfixer.btable.pres.events.pub.*;
>
> /**
> * This class will contain the EventListeners responsible for handling the
Get, Do, and Render Events
> *
> * @author Denny Chambers
> *
> */
>
> public class CaptionTest5 extends DefaultEventGateway {
>
>
>     //this defines the various event handlers
>
>     private ListenerFactory getCaptionTest5Factory =
>         new DefaultListenerFactory() {
>             public BaseEventListener getInstance() {
>                 return new GetCaptionTest5Handler();}
>             public String getListenerID() {
>                 return getID(GetCaptionTest5Handler.class);}};
>
>     private ListenerFactory renderCaptionTest5Factory =
>         new DefaultListenerFactory() {
>             public BaseEventListener getInstance() {
>                 return new RenderCaptionTest5Handler();}
>             public String getListenerID() {
>                 return getID(RenderCaptionTest5Handler.class);}};
>
>
>     //-------------------- DefaultEventGateway -------------------
>     /**
>     * Public constructor
>     */
>     public CaptionTest5() {
>         //specify who's interested in what
>         specifyLocalEventInterests(getCaptionTest5Factory,
GetCaptionTest5.class);
>         specifyLocalEventInterests(renderCaptionTest5Factory,
RenderCaptionTest5.class);
>     }
>
>     //------------------------------------------------------------
>     //             Model 2 - Controller Event Handlers
>     //------------------------------------------------------------
>     /**
>     * Event Handlers to hande the Get/Do request
>     *
>     */
>
>     class GetCaptionTest5Handler extends DefaultBaseEventListener {
>
>         /**
>         * This method handles the event
>         */
>         public void handleControlEvent(ControlEventContext context) throws
EventException, ServletException, IOException {
>             BaseEvent event = context.getEvent();
>             DispatchQueue queue = context.getQueue();
>             queue.addEvent(new RenderCaptionTest5(event));
>         }
>     }
>
>     //------------------------------------------------------------
>     //                Model 2 - View Event Handlers
>     //------------------------------------------------------------
>     /**
>     * Event handlers to hander render events.
>     */
>
>
>     class RenderCaptionTest5Handler extends DefaultBaseEventListener {
>
>         /**
>         * This method handles the event
>         */
>         public void handleViewEvent(ViewEventContext context) throws
EventException, ServletException, IOException {
>
>             HttpServletResponse resp = context.getResponse();
>         ViewContext vc = new DefaultViewContext(context);
>         Document page =
DefaultDOMLoader.getGlobalInstance().getDOM(CaptionTest1HTML.class);
>             Node node = page.getDocumentElement();
>             BTemplate templateComp = new BTemplate();
>             templateComp.setView(new DefaultTemplateView(node));
>             templateComp.addModel(new CaptionTestModel());
>             try{
>                 templateComp.render(vc);
>             }
>             catch (RenderException re){
>                 re.printStackTrace();
>             }
>
>             try
>             {
>                 resp.setContentType("text/html; charset=UTF-8");
>                 new DefaultDOMWriter(true).write(page, resp.getWriter());
>             }
>             catch (IOException io) {
>                 io.printStackTrace();
>             }
>         }
>     }
>
>     //------------------------------------------------------------
>     //                The Model for this Screen
>     //------------------------------------------------------------
>     class CaptionTestModel extends AbstractTemplateModel {
>
>         private CaptionTestHeaderModel headerModel;
>         private CaptionTestFooterModel footerModel;
>         private CaptionTestTableModel model;
>
>         public CaptionTestModel() {
>             headerModel = new CaptionTestHeaderModel();
>             footerModel = new CaptionTestFooterModel();
>             model = new CaptionTestTableModel();
>         }
>
>         //register the model by name
>         public String getName() {
>             return "CaptionTest";
>         }
>
>         //provide items by key
>         public Object getItem(String key) {
>             if(key.equals("tableExample1")){
>                 BTable bt = new BTable();
>                 bt.setModel(model);
>                 bt.setCaption(new BText("This text was set using a BText
object"));
>                 return bt;
>             }
>             else if(key.equals("title")){
>                 return "Caption Test Example 5";
>             }
>             else if(key.equals("desc")){
>                 StringBuffer sb = new StringBuffer();
>                 sb.append("Now I will dynamically update the caption
element ");
>                 sb.append("using a BText object an only a tbody");
>                 return sb.toString();
>             }
>             else if(key.equals("linkExample1")){
>                 return "1";
>             }
>             else if(key.equals("linkExample2")){
>                 return "2";
>             }
>             else if(key.equals("linkExample3")){
>                 return "3";
>             }
>             else if(key.equals("linkExample4")){
>                 return "4";
>             }
>             else if(key.equals("linkExample5")){
>                 BText bt = new BText("<big><b>5</b></big>");
>                 bt.setAllowMarkupInText(true);
>                 return bt;
>             }
>             else if(key.equals("linkExample6")){
>                 return "6";
>             }
>             return super.getItem(key);
>         }
>     }
>
>     //------------------------------------------------------------
>     //                       Table Models
>     //------------------------------------------------------------
>
>     class CaptionTestHeaderModel extends AbstractTableModel{
>
>         private String[] header = {"Attribute", "Description"};
>
>         CaptionTestHeaderModel(){
>             ;
>         }
>
>         //From TableModel Interface
>
>         public int getRowCount(){
>             return 1;
>         }
>
>         public int getColumnCount(){
>             return header.length;
>         }
>
>         public Object getItemAt(int row, int col){
>             if(row != 0){
>                 return null;
>             }
>
>             if(col < 0 || col >= header.length){
>                 return null;
>             }
>
>             return header[col];
>         }
>     }
>
>     class CaptionTestFooterModel extends AbstractTableModel{
>
>         private String[] footer = {"Attribute", "Description"};
>
>         CaptionTestFooterModel(){
>             ;
>         }
>
>         //From TableModel Interface
>
>         public int getRowCount(){
>             return 1;
>         }
>
>         public int getColumnCount(){
>             return footer.length;
>         }
>
>         public Object getItemAt(int row, int col){
>             if(row != 0){
>                 return null;
>             }
>
>             if(col < 0 || col >= footer.length){
>                 return null;
>             }
>
>             return footer[col];
>         }
>     }
>
>     class CaptionTestTableModel extends AbstractTableModel{
>
>         private Vector tableModel;
>         CaptionTestTableModel(){
>             String[] attributes = { "align", "id", "class", "style",
"title",
>                                     "lang", "dir", "onclick",
"ondblclick",
>                                     "onmousedown","onmouseup",
"onmouseover",
>                                     "onmouseout", "onkeypress",
"onkeydown",
>                                     "onkeyup"
>                                   };
>
>             String[] description = {
>                 "Deprecated",
>                 "This attribute assigns a name to an element. This name
must be unique in a document.",
>                 "This attribute assigns a class name or set of class names
to an element. Any number of elements may be assigned the same class name or
names. Multiple class names must be separated by white space characters.",
>                 "This attribute specifies style information for the
current element.",
>                 "This attribute offers advisory information about the
element for which it is set.",
>                 "This attribute specifies the base language of an
element's attribute values and text content. The default value of this
attribute is unknown.",
>                 "This attribute specifies the base direction of
directionally neutral text (i.e., text that doesn't have inherent
directionality as defined in [UNICODE]) in an element's content and
attribute values. Possible values: LTR - Left-to-right text or table, RTL -
Right-to-left text or table.",
>                 "The onclick event occurs when the pointing device button
is clicked over an element. This attribute may be used with most elements.",
>                 "The ondblclick event occurs when the pointing device
button is double clicked over an element. This attribute may be used with
most elements.",
>                 "The onmousedown event occurs when the pointing device
button is pressed over an element. This attribute may be used with most
elements.",
>                 "The onmouseup event occurs when the pointing device
button is released over an element. This attribute may be used with most
elements.",
>                 "The onmouseover event occurs when the pointing device is
moved onto an element. This attribute may be used with most elements.",
>                 "The onmouseout event occurs when the pointing device is
moved away from an element. This attribute may be used with most elements.",
>                 "The onkeypress event occurs when a key is pressed and
released over an element. This attribute may be used with most elements.",
>                 "The onkeydown event occurs when a key is pressed down
over an element. This attribute may be used with most elements.",
>                 "The onkeyup event occurs when a key is released over an
element. This attribute may be used with most elements.",
>             };
>
>             tableModel = new Vector();
>             for(int i = 0; i < attributes.length; i++){
>                 Vector newRow = new Vector();
>                 newRow.add(attributes[i]);
>                 newRow.add(description[i]);
>                 tableModel.add(newRow);
>             }
>
>         }
>
>         //From TableModel Interface
>
>         public int getRowCount(){
>             return tableModel.size();
>         }
>
>         public int getColumnCount(){
>             return 2;
>         }
>
>         public Object getItemAt(int row, int col){
>             if(row < 0 || row >= tableModel.size()){
>                 return null;
>             }
>
>             if(col < 0 || col >= 2){
>                 return null;
>             }
>
>             return ((Vector) tableModel.elementAt(row)).elementAt(col);
>         }
>     }
> }
>



>
/***************************************************************************
****
> * Copyright (c) 2002, bugfixer.org
> * Author : Denny Chambers
> * Revision History :  08/23/2002   Denny Chambers   Initial Work
>
****************************************************************************
***/
>
> package org.bugfixer.btable.pres.screens;
> import javax.servlet.*;
> import javax.servlet.http.*;
> import java.io.*;
> import java.util.*;
> import org.enhydra.barracuda.core.comp.*;
> import org.enhydra.barracuda.core.event.*;
> import org.enhydra.barracuda.core.util.dom.*;
> import org.w3c.dom.*;
> import org.bugfixer.btable.pres.events.render.*;
> import org.bugfixer.btable.pres.events.pub.*;
>
> /**
> * This class will contain the EventListeners responsible for handling the
Get, Do, and Render Events
> *
> * @author Denny Chambers
> *
> */
>
> public class CaptionTest6 extends DefaultEventGateway {
>
>
>     //this defines the various event handlers
>
>     private ListenerFactory getCaptionTest6Factory =
>         new DefaultListenerFactory() {
>             public BaseEventListener getInstance() {
>                 return new GetCaptionTest6Handler();}
>             public String getListenerID() {
>                 return getID(GetCaptionTest6Handler.class);}};
>
>     private ListenerFactory renderCaptionTest6Factory =
>         new DefaultListenerFactory() {
>             public BaseEventListener getInstance() {
>                 return new RenderCaptionTest6Handler();}
>             public String getListenerID() {
>                 return getID(RenderCaptionTest6Handler.class);}};
>
>
>     //-------------------- DefaultEventGateway -------------------
>     /**
>     * Public constructor
>     */
>     public CaptionTest6() {
>         //specify who's interested in what
>         specifyLocalEventInterests(getCaptionTest6Factory,
GetCaptionTest6.class);
>         specifyLocalEventInterests(renderCaptionTest6Factory,
RenderCaptionTest6.class);
>     }
>
>     //------------------------------------------------------------
>     //             Model 2 - Controller Event Handlers
>     //------------------------------------------------------------
>     /**
>     * Event Handlers to hande the Get/Do request
>     *
>     */
>
>     class GetCaptionTest6Handler extends DefaultBaseEventListener {
>
>         /**
>         * This method handles the event
>         */
>         public void handleControlEvent(ControlEventContext context) throws
EventException, ServletException, IOException {
>             BaseEvent event = context.getEvent();
>             DispatchQueue queue = context.getQueue();
>             queue.addEvent(new RenderCaptionTest6(event));
>         }
>     }
>
>     //------------------------------------------------------------
>     //                Model 2 - View Event Handlers
>     //------------------------------------------------------------
>     /**
>     * Event handlers to hander render events.
>     */
>
>
>     class RenderCaptionTest6Handler extends DefaultBaseEventListener {
>
>         /**
>         * This method handles the event
>         */
>         public void handleViewEvent(ViewEventContext context) throws
EventException, ServletException, IOException {
>
>             HttpServletResponse resp = context.getResponse();
>         ViewContext vc = new DefaultViewContext(context);
>         Document page =
DefaultDOMLoader.getGlobalInstance().getDOM(CaptionTest1HTML.class);
>             Node node = page.getDocumentElement();
>             BTemplate templateComp = new BTemplate();
>             templateComp.setView(new DefaultTemplateView(node));
>             templateComp.addModel(new CaptionTestModel());
>             try{
>                 templateComp.render(vc);
>             }
>             catch (RenderException re){
>                 re.printStackTrace();
>             }
>
>             try
>             {
>                 resp.setContentType("text/html; charset=UTF-8");
>                 new DefaultDOMWriter(true).write(page, resp.getWriter());
>             }
>             catch (IOException io) {
>                 io.printStackTrace();
>             }
>         }
>     }
>
>     //------------------------------------------------------------
>     //                The Model for this Screen
>     //------------------------------------------------------------
>     class CaptionTestModel extends AbstractTemplateModel {
>
>         private CaptionTestHeaderModel headerModel;
>         private CaptionTestFooterModel footerModel;
>         private CaptionTestTableModel model;
>
>         public CaptionTestModel() {
>             headerModel = new CaptionTestHeaderModel();
>             footerModel = new CaptionTestFooterModel();
>             model = new CaptionTestTableModel();
>         }
>
>         //register the model by name
>         public String getName() {
>             return "CaptionTest";
>         }
>
>         //provide items by key
>         public Object getItem(String key) {
>             if(key.equals("tableExample1")){
>                 BTable bt = new BTable();
>                 bt.setModel(model);
>                 bt.setHeaderModel(headerModel);
>                 bt.setCaption(new BText("This text was set using a BText
object"));
>                 return bt;
>             }
>             else if(key.equals("title")){
>                 return "Caption Test Example 6";
>             }
>             else if(key.equals("desc")){
>                 StringBuffer sb = new StringBuffer();
>                 sb.append("Now I will dynamically update the caption
element ");
>                 sb.append("using a BText object along with the tbody, ");
>                 sb.append("and thead");
>                 return sb.toString();
>             }
>             else if(key.equals("linkExample1")){
>                 return "1";
>             }
>             else if(key.equals("linkExample2")){
>                 return "2";
>             }
>             else if(key.equals("linkExample3")){
>                 return "3";
>             }
>             else if(key.equals("linkExample4")){
>                 return "4";
>             }
>             else if(key.equals("linkExample5")){
>                 return "5";
>             }
>             else if(key.equals("linkExample6")){
>                 BText bt = new BText("<big><b>6</b></big>");
>                 bt.setAllowMarkupInText(true);
>                 return bt;
>             }
>             return super.getItem(key);
>         }
>     }
>
>     //------------------------------------------------------------
>     //                       Table Models
>     //------------------------------------------------------------
>
>     class CaptionTestHeaderModel extends AbstractTableModel{
>
>         private String[] header = {"Attribute", "Description"};
>
>         CaptionTestHeaderModel(){
>             ;
>         }
>
>         //From TableModel Interface
>
>         public int getRowCount(){
>             return 1;
>         }
>
>         public int getColumnCount(){
>             return header.length;
>         }
>
>         public Object getItemAt(int row, int col){
>             if(row != 0){
>                 return null;
>             }
>
>             if(col < 0 || col >= header.length){
>                 return null;
>             }
>
>             return header[col];
>         }
>     }
>
>     class CaptionTestFooterModel extends AbstractTableModel{
>
>         private String[] footer = {"Attribute", "Description"};
>
>         CaptionTestFooterModel(){
>             ;
>         }
>
>         //From TableModel Interface
>
>         public int getRowCount(){
>             return 1;
>         }
>
>         public int getColumnCount(){
>             return footer.length;
>         }
>
>         public Object getItemAt(int row, int col){
>             if(row != 0){
>                 return null;
>             }
>
>             if(col < 0 || col >= footer.length){
>                 return null;
>             }
>
>             return footer[col];
>         }
>     }
>
>     class CaptionTestTableModel extends AbstractTableModel{
>
>         private Vector tableModel;
>         CaptionTestTableModel(){
>             String[] attributes = { "align", "id", "class", "style",
"title",
>                                     "lang", "dir", "onclick",
"ondblclick",
>                                     "onmousedown","onmouseup",
"onmouseover",
>                                     "onmouseout", "onkeypress",
"onkeydown",
>                                     "onkeyup"
>                                   };
>
>             String[] description = {
>                 "Deprecated",
>                 "This attribute assigns a name to an element. This name
must be unique in a document.",
>                 "This attribute assigns a class name or set of class names
to an element. Any number of elements may be assigned the same class name or
names. Multiple class names must be separated by white space characters.",
>                 "This attribute specifies style information for the
current element.",
>                 "This attribute offers advisory information about the
element for which it is set.",
>                 "This attribute specifies the base language of an
element's attribute values and text content. The default value of this
attribute is unknown.",
>                 "This attribute specifies the base direction of
directionally neutral text (i.e., text that doesn't have inherent
directionality as defined in [UNICODE]) in an element's content and
attribute values. Possible values: LTR - Left-to-right text or table, RTL -
Right-to-left text or table.",
>                 "The onclick event occurs when the pointing device button
is clicked over an element. This attribute may be used with most elements.",
>                 "The ondblclick event occurs when the pointing device
button is double clicked over an element. This attribute may be used with
most elements.",
>                 "The onmousedown event occurs when the pointing device
button is pressed over an element. This attribute may be used with most
elements.",
>                 "The onmouseup event occurs when the pointing device
button is released over an element. This attribute may be used with most
elements.",
>                 "The onmouseover event occurs when the pointing device is
moved onto an element. This attribute may be used with most elements.",
>                 "The onmouseout event occurs when the pointing device is
moved away from an element. This attribute may be used with most elements.",
>                 "The onkeypress event occurs when a key is pressed and
released over an element. This attribute may be used with most elements.",
>                 "The onkeydown event occurs when a key is pressed down
over an element. This attribute may be used with most elements.",
>                 "The onkeyup event occurs when a key is released over an
element. This attribute may be used with most elements.",
>             };
>
>             tableModel = new Vector();
>             for(int i = 0; i < attributes.length; i++){
>                 Vector newRow = new Vector();
>                 newRow.add(attributes[i]);
>                 newRow.add(description[i]);
>                 tableModel.add(newRow);
>             }
>
>         }
>
>         //From TableModel Interface
>
>         public int getRowCount(){
>             return tableModel.size();
>         }
>
>         public int getColumnCount(){
>             return 2;
>         }
>
>         public Object getItemAt(int row, int col){
>             if(row < 0 || row >= tableModel.size()){
>                 return null;
>             }
>
>             if(col < 0 || col >= 2){
>                 return null;
>             }
>
>             return ((Vector) tableModel.elementAt(row)).elementAt(col);
>         }
>     }
> }
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.