You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ecs-user@jakarta.apache.org by "RESTREPO, ALEXANDER G [Non-Pharmacia/1000]" <al...@monsanto.com> on 2001/03/22 21:17:55 UTC

Clearing a TR Element

Hello ECS Gurus:

Is there a simple way to clear a TR Element, for example:
(Is there a generic method that will work with any
HTML Element type????)

TD td1   = new TD("Table Data 1");
TD td2   = new TD("Table Data 2");
TD td3   = new TD("Table Data 3);
TR myTR  = new TR();
myTR.addElement(td1);
myTR.addElement(td2);
myTR.addElement(td3);

myTR.clearElements()<--------Is there a simple way to do this?????


Many Thanks:

Alex Restrepo

-----Original Message-----
From: David Ethell [mailto:dethell@sscdinc.com]
Sent: Wednesday, March 21, 2001 5:38 AM
To: ecs-user@jakarta.apache.org
Subject: RE: Returning an object containing various HTML objects


Or, write them all as Strings and return a string:

public String create questionPanel()
{
    String returnString = "";
    Table firstTable  = new Table();
    Table secondTable = new Table();
    Table thirdTable  = new Table();
       .
       .
       .
     Other Objects.....

      ....add all objects together
    returnString += firstTable.toString();
    returnString += secondTable.toString();
    returnString += thirdTable.toString();
    returnString += otherObjects.toString();
     return (returnString);    
}

> -----Original Message-----
> From: snagy@mail.catalystsolutions.net
> [mailto:snagy@mail.catalystsolutions.net]On Behalf Of Stephan Nagy
> Sent: Tuesday, March 20, 2001 6:14 PM
> To: ecs-user@jakarta.apache.org
> Subject: Re: Returning an object containing various HTML objects
> 
> 
> "RESTREPO, ALEXANDER G [Non-Pharmacia/1000]" wrote:
> 
> > Hello:
> >
> > I am creating a method which needs to return an
> > object which contains 3 HTML tables and a few other
> > HTML objects.  I want to basically return an object
> > which contains all these elements.
> >
> > How can I do this? What class type would this method
> > have to return.? How can I "concatenate" all the HTML
> > objects I need to use without using the body tag?
> >
> > For example:
> >
> > public ???  create questionPanel()
> > {
> >     Table firstTable  = new Table();
> >     Table secondTable = new Table();
> >     Table thirdTable  = new Table();
> >        .
> >        .
> >        .
> >      Other Objects.....
> >
> >       ....add all objects together
> >
> >      return ????;
> > }
> >
> > Any help would greatly be appreciated.
> 
> Here is one way to do it, there are a couple others as well.
> 
> StringElement se = new
> StringElement().addElement(firstTable).addElement(secondTable).add
> Element(thirdTable);
> 
> or alternativly just write the tables directly to the output stream
> like:
> 
> public void createQuestionPanel(PrintWriter out)
> {
>     Table firstTable  = new Table();
>     Table secondTable = new Table();
>     Table thirdTable  = new Table();
>        .
>        .
>        .
>      Other Objects.....
> 
>       ....add all objects together
> 
>      firstTable.output(out);
>      secondTable.output(out);
>      thirdTable.output(out);
> }
> 
> -stephan
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ecs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: ecs-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: ecs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: ecs-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: ecs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: ecs-user-help@jakarta.apache.org


Re: Clearing a TR Element

Posted by Vladimir Grishchenko <vl...@std.teradyne.com>.
I didn't originate the question, but I can give you a
couple of reasons why.

1. I can speculate that creation of a new object is more expensive
   than just clearing an existing one

2. The way I wrote a couple of servlets was I created a template
   class responsible for creation of general page look and feel. So a servlet
   would pass several dynamically generated elements to that template
   page which had to be removed after output was done so the template
   is ready to be reused.

Not sure if these examples are convinsing. Also, I was able to live without
clearElements() so far.

My 2c.

--V.

Stephan Nagy wrote:
> 
> "RESTREPO, ALEXANDER G [Non-Pharmacia/1000]" wrote:
> 
> > Hello ECS Gurus:
> >
> > Is there a simple way to clear a TR Element, for example:
> > (Is there a generic method that will work with any
> > HTML Element type????)
> >
> > TD td1   = new TD("Table Data 1");
> > TD td2   = new TD("Table Data 2");
> > TD td3   = new TD("Table Data 3);
> > TR myTR  = new TR();
> > myTR.addElement(td1);
> > myTR.addElement(td2);
> > myTR.addElement(td3);
> >
> > myTR.clearElements()<--------Is there a simple way to do this?????
> >
> 
> myTr = new TR(); // <--- would do it.
> 
> If you can provide me a good reason why you would want to clear the list
> of elements in an element i'll implement it as it is rather trivial
> otherwise the above will do it.
> 
> -stephan
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ecs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: ecs-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: ecs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: ecs-user-help@jakarta.apache.org


Re: Clearing a TR Element

Posted by Stephan Nagy <sn...@connectria.com>.
"RESTREPO, ALEXANDER G [Non-Pharmacia/1000]" wrote:

> Hello ECS Gurus:
>
> Is there a simple way to clear a TR Element, for example:
> (Is there a generic method that will work with any
> HTML Element type????)
>
> TD td1   = new TD("Table Data 1");
> TD td2   = new TD("Table Data 2");
> TD td3   = new TD("Table Data 3);
> TR myTR  = new TR();
> myTR.addElement(td1);
> myTR.addElement(td2);
> myTR.addElement(td3);
>
> myTR.clearElements()<--------Is there a simple way to do this?????
>

myTr = new TR(); // <--- would do it.

If you can provide me a good reason why you would want to clear the list
of elements in an element i'll implement it as it is rather trivial
otherwise the above will do it.

-stephan



---------------------------------------------------------------------
To unsubscribe, e-mail: ecs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: ecs-user-help@jakarta.apache.org


Re: Clearing a TR Element

Posted by Vladimir Grishchenko <vl...@std.teradyne.com>.
I'd also like to know if it exists... I used:

myTR.removeElement(td1.hashCode() + "")
    .removeElement(td2.hashCode() + "")
    .removeElement(td3.hashCode() + "");


--V.

"RESTREPO, ALEXANDER G [Non-Pharmacia/1000]" wrote:
> 
> Hello ECS Gurus:
> 
> Is there a simple way to clear a TR Element, for example:
> (Is there a generic method that will work with any
> HTML Element type????)
> 
> TD td1   = new TD("Table Data 1");
> TD td2   = new TD("Table Data 2");
> TD td3   = new TD("Table Data 3);
> TR myTR  = new TR();
> myTR.addElement(td1);
> myTR.addElement(td2);
> myTR.addElement(td3);
> 
> myTR.clearElements()<--------Is there a simple way to do this?????
> 
> Many Thanks:
> 
> Alex Restrepo
> 
> -----Original Message-----
> From: David Ethell [mailto:dethell@sscdinc.com]
> Sent: Wednesday, March 21, 2001 5:38 AM
> To: ecs-user@jakarta.apache.org
> Subject: RE: Returning an object containing various HTML objects
> 
> Or, write them all as Strings and return a string:
> 
> public String create questionPanel()
> {
>     String returnString = "";
>     Table firstTable  = new Table();
>     Table secondTable = new Table();
>     Table thirdTable  = new Table();
>        .
>        .
>        .
>      Other Objects.....
> 
>       ....add all objects together
>     returnString += firstTable.toString();
>     returnString += secondTable.toString();
>     returnString += thirdTable.toString();
>     returnString += otherObjects.toString();
>      return (returnString);
> }
> 
> > -----Original Message-----
> > From: snagy@mail.catalystsolutions.net
> > [mailto:snagy@mail.catalystsolutions.net]On Behalf Of Stephan Nagy
> > Sent: Tuesday, March 20, 2001 6:14 PM
> > To: ecs-user@jakarta.apache.org
> > Subject: Re: Returning an object containing various HTML objects
> >
> >
> > "RESTREPO, ALEXANDER G [Non-Pharmacia/1000]" wrote:
> >
> > > Hello:
> > >
> > > I am creating a method which needs to return an
> > > object which contains 3 HTML tables and a few other
> > > HTML objects.  I want to basically return an object
> > > which contains all these elements.
> > >
> > > How can I do this? What class type would this method
> > > have to return.? How can I "concatenate" all the HTML
> > > objects I need to use without using the body tag?
> > >
> > > For example:
> > >
> > > public ???  create questionPanel()
> > > {
> > >     Table firstTable  = new Table();
> > >     Table secondTable = new Table();
> > >     Table thirdTable  = new Table();
> > >        .
> > >        .
> > >        .
> > >      Other Objects.....
> > >
> > >       ....add all objects together
> > >
> > >      return ????;
> > > }
> > >
> > > Any help would greatly be appreciated.
> >
> > Here is one way to do it, there are a couple others as well.
> >
> > StringElement se = new
> > StringElement().addElement(firstTable).addElement(secondTable).add
> > Element(thirdTable);
> >
> > or alternativly just write the tables directly to the output stream
> > like:
> >
> > public void createQuestionPanel(PrintWriter out)
> > {
> >     Table firstTable  = new Table();
> >     Table secondTable = new Table();
> >     Table thirdTable  = new Table();
> >        .
> >        .
> >        .
> >      Other Objects.....
> >
> >       ....add all objects together
> >
> >      firstTable.output(out);
> >      secondTable.output(out);
> >      thirdTable.output(out);
> > }
> >
> > -stephan
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: ecs-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: ecs-user-help@jakarta.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ecs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: ecs-user-help@jakarta.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ecs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: ecs-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: ecs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: ecs-user-help@jakarta.apache.org