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/23 19:26:07 UTC

ElementContainer isEmpty() method?

Hello Everyone:

Does anybody know of a method or technique
to determine if a ElementContainer or any other
ECS Element is empty, i.e., it contains no Elements?

Many Thanks:

Alex Restrepo

-----Original Message-----
From: Vladimir Grishchenko [mailto:vladg@std.teradyne.com]
Sent: Thursday, March 22, 2001 3:58 PM
To: ecs-user@jakarta.apache.org
Subject: Re: Clearing a TR Element


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

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


Re: ElementContainer isEmpty() method?

Posted by Robert Burrell Donkin <Ro...@appleonline.net>.
Robert Burrell Donkin wrote:

> Stephan Nagy wrote:
>
> > Robert Burrell Donkin wrote:
> >
> > > "RESTREPO, ALEXANDER G [Non-Pharmacia/1000]" wrote:
> > >
> > > > Hello Everyone:
> > > >
> > > > Does anybody know of a method or technique
> > > > to determine if a ElementContainer or any other
> > > > ECS Element is empty, i.e., it contains no Elements?
> > >
> > > this isn't very pretty code but it works for me
> > >
> > > public boolean isEmpty(org.apache.ecs.ConcreteElement element)
> > > {
> > >     return !(element.keys().hasMoreElements();
> > > }
> > >
> > > i believe that it should be possible to add a better isEmpty() method to the
> > > ConcreteElement
> > > and maybe that'd be a bit better.
> > > don't know what other people think.
> > >
> >
> > You could add something like that into the base class or do :
> >
> > if(this.keys() == null) { ... }  // element is empty
> >
> > Pretty sure that will work.
>
> maybe i'll have a look at testing this.
>
> - robert

i've had a look at the ConcreteElement source and i recon that keys() never returns
null.

this new method (in ConcreteElement) works for me

public boolean isEmpty()
{
    return registryList.isEmpty();
}

(i'm fairly confident that isEmpty() is present in the 1.1 vintage vector but maybe
somebody could set me straight if it isn't)


PS appologies for the double post yesterday...

- robert


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


Re: ElementContainer isEmpty() method?

Posted by Robert Burrell Donkin <Ro...@appleonline.net>.
Stephan Nagy wrote:

> Robert Burrell Donkin wrote:
>
> > "RESTREPO, ALEXANDER G [Non-Pharmacia/1000]" wrote:
> >
> > > Hello Everyone:
> > >
> > > Does anybody know of a method or technique
> > > to determine if a ElementContainer or any other
> > > ECS Element is empty, i.e., it contains no Elements?
> >
> > this isn't very pretty code but it works for me
> >
> > public boolean isEmpty(org.apache.ecs.ConcreteElement element)
> > {
> >     return !(element.keys().hasMoreElements();
> > }
> >
> > i believe that it should be possible to add a better isEmpty() method to the
> > ConcreteElement
> > and maybe that'd be a bit better.
> > don't know what other people think.
> >
>
> You could add something like that into the base class or do :
>
> if(this.keys() == null) { ... }  // element is empty
>
> Pretty sure that will work.

maybe i'll have a look at testing this.

- robert


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


Re: [PATCH] Re: ElementContainer isEmpty() method?

Posted by Stephan Nagy <sn...@connectria.com>.
+1

Robert Burrell Donkin wrote:

> i think that ConcreteElement.isEmpty() is a useful method and should be commited.
> thumbs up or thumbs down?
>
> - robert
>
>   ------------------------------------------------------------------------
> Index: src/java/org/apache/ecs/ConcreteElement.java
> ===================================================================
> RCS file: /home/cvs/jakarta-ecs/src/java/org/apache/ecs/ConcreteElement.java,v
> retrieving revision 1.24
> diff -u -r1.24 ConcreteElement.java
> --- src/java/org/apache/ecs/ConcreteElement.java        2001/03/12 18:39:34     1.24
> +++ src/java/org/apache/ecs/ConcreteElement.java        2001/04/04 18:11:36
> @@ -469,4 +469,9 @@
>              throw new InternalError(ioe.toString());
>          }
>      }
> +
> +    public boolean isEmpty()
> +    {
> +        return registryList.isEmpty();
> +    }
>  }
>
>   ------------------------------------------------------------------------
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ecs-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: ecs-dev-help@jakarta.apache.org


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


[PATCH] Re: ElementContainer isEmpty() method?

Posted by Robert Burrell Donkin <Ro...@appleonline.net>.
i think that ConcreteElement.isEmpty() is a useful method and should be commited.
thumbs up or thumbs down?

- robert

Re: ElementContainer isEmpty() method?

Posted by Robert Burrell Donkin <Ro...@appleonline.net>.
Stephan Nagy wrote:

> Robert Burrell Donkin wrote:
>
> > on the other hand, providing getters for only some (and not all) attributes for
> > some classes would be a bit funny - but providing getters for all attributes
> > with setters for all classes doesn't seem worth the candle to me. comments?
> >
>
> Thats one of the requirements in ecs2 (which should support javabeans so you can
> create different widgets inside your ide of choice ).

cool. mind you i can now see why ecs2 is so much work...

> Feel free togo back in and
> add getters that correspond to the setter methods in the current ecs tree.

i'm quite happy to add a few getters for the common (ie. non-javascript) setters in
org.apache.html.Option into the current tree.

- robert


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


Re: ElementContainer isEmpty() method?

Posted by Stephan Nagy <sn...@connectria.com>.
Robert Burrell Donkin wrote:

> Stephan Nagy wrote:
>
> > On another note I'm all for the idea of adding
> > the concept of attributetemplates into ecs so that people can easily create
> > templating libraries.  Would work something like:
> >
> > AttributeTemplate at = new AttributeTemplate();
> > at.add(new Attribute(name,value));
> >
> > SomeElement se = new SomeElement(at);
> > FooElement fe = new FooElement(at);
> >
> > That way you can reuse an attribute set across many different elements therby
> > skipping the painful setFoo methods on every element you wish to create with
> > identical attributes.  Any comments?
>
> definitely +1
>
> i suppose also
>
>     fe.addAttribute(at);
>
> on the subject of attributes, we had questions on the list a while ago re:getting
> attributes.
> symmetry sort of says that getters for attributes with setters make sense, and at
> least one person needed getters for the common attributes in
> org.apache.ecs.html.Option at least.
> on the other hand, providing getters for only some (and not all) attributes for
> some classes would be a bit funny - but providing getters for all attributes
> with setters for all classes doesn't seem worth the candle to me. comments?
>

Thats one of the requirements in ecs2 (which should support javabeans so you can
create different widgets inside your ide of choice ).  Feel free togo back in and
add getters that correspond to the setter methods in the current ecs tree.

-stephan



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


Re: ElementContainer isEmpty() method?

Posted by Robert Burrell Donkin <Ro...@appleonline.net>.
Stephan Nagy wrote:

> On another note I'm all for the idea of adding
> the concept of attributetemplates into ecs so that people can easily create
> templating libraries.  Would work something like:
>
> AttributeTemplate at = new AttributeTemplate();
> at.add(new Attribute(name,value));
>
> SomeElement se = new SomeElement(at);
> FooElement fe = new FooElement(at);
>
> That way you can reuse an attribute set across many different elements therby
> skipping the painful setFoo methods on every element you wish to create with
> identical attributes.  Any comments?

definitely +1

i suppose also

    fe.addAttribute(at);


on the subject of attributes, we had questions on the list a while ago re:getting
attributes.
symmetry sort of says that getters for attributes with setters make sense, and at
least one person needed getters for the common attributes in
org.apache.ecs.html.Option at least.
on the other hand, providing getters for only some (and not all) attributes for
some classes would be a bit funny - but providing getters for all attributes
with setters for all classes doesn't seem worth the candle to me. comments?

- robert


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


Re: ElementContainer isEmpty() method?

Posted by Stephan Nagy <sn...@connectria.com>.
Robert Burrell Donkin wrote:

> "RESTREPO, ALEXANDER G [Non-Pharmacia/1000]" wrote:
>
> > Hello Everyone:
> >
> > Does anybody know of a method or technique
> > to determine if a ElementContainer or any other
> > ECS Element is empty, i.e., it contains no Elements?
>
> this isn't very pretty code but it works for me
>
> public boolean isEmpty(org.apache.ecs.ConcreteElement element)
> {
>     return !(element.keys().hasMoreElements();
> }
>
> i believe that it should be possible to add a better isEmpty() method to the
> ConcreteElement
> and maybe that'd be a bit better.
> don't know what other people think.
>

You could add something like that into the base class or do :

if(this.keys() == null) { ... }  // element is empty

Pretty sure that will work.   On another note I'm all for the idea of adding
the concept of attributetemplates into ecs so that people can easily create
templating libraries.  Would work something like:

AttributeTemplate at = new AttributeTemplate();
at.add(new Attribute(name,value));

SomeElement se = new SomeElement(at);
FooElement fe = new FooElement(at);

That way you can reuse an attribute set across many different elements therby
skipping the painful setFoo methods on every element you wish to create with
identical attributes.  Any comments?

-stephan


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


Re: ElementContainer isEmpty() method?

Posted by Robert Burrell Donkin <Ro...@appleonline.net>.
"RESTREPO, ALEXANDER G [Non-Pharmacia/1000]" wrote:

> Hello Everyone:
>
> Does anybody know of a method or technique
> to determine if a ElementContainer or any other
> ECS Element is empty, i.e., it contains no Elements?

this isn't very pretty code but it works for me

public boolean isEmpty(org.apache.ecs.ConcreteElement element)
{
    return !(element.keys().hasMoreElements();
}


i believe that it should be possible to add a better isEmpty() method to the
ConcreteElement
and maybe that'd be a bit better.
don't know what other people think.

- robert


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


Re: ElementContainer isEmpty() method?

Posted by Robert Burrell Donkin <Ro...@appleonline.net>.
i've now added a ConcreteElement.isEmpty() method.

- robert


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