Re: Digester and inheritance

2002-03-04 Thread Stacy Weng

the beaninfo is all in the parent class - Component...

--Stacy
  - Original Message - 
  From: dIon Gillard 
  To: Struts Users Mailing List 
  Sent: Saturday, March 02, 2002 8:06 PM
  Subject: Re: Digester and inheritance


  Stacy Weng wrote:

  >I have a parent class called Component, and several child classes extending from 
it.   All the common get/set methods are defined in Component.  So, after each child 
is getting created from addObjectCreate() method, I call addSetProperties() method to 
initialize their values (values are from the xml file), however, digester can't find 
the set methods from the child class, cause they're defined in the parent class 
(Component).  The temporary solution I had was defining those set methods in the child 
classes, and have them call the super methods.  But that seems to defeat the whole 
purpose of inheritance.  Here's an example with the problem:
  >
  >public class Component {
  >public String name = null;
  >public void setName(String name) {
  >this.name=name;
  >}
  >public void getname() {
  >return this.name;
  >}
  >}
  >
  >public class ChildClass extend Component {
  >//Other methods that differ from parent class
  >}
  >
  Do you have any beaninfo classes coded/generated for ChildClass?

  >
  >for the digester rules:
  >
  >digester.addObjectCreate("ChildClassPattern", "some.package.ChildClass");
  >digester.addSetProperties("ChildClassPattern");
  >
  >so, as it gets to addSetProperties(), it doesn't see any of the get/set methods in 
ChildClass, and yet, it doesn't know to look its parent class, Component.
  >
  >I hope I'm able to get my problem across.  Thanks again for taking the time to 
respond.
  >
  >--Stacy
  >
  -- 
  dIon Gillard, Multitask Consulting
  http://adslgateway.multitask.com.au/developers




  --
  To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
  For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>



Re: Digester and inheritance

2002-03-02 Thread dIon Gillard

Stacy Weng wrote:

>I have a parent class called Component, and several child classes extending from it.  
> All the common get/set methods are defined in Component.  So, after each child is 
>getting created from addObjectCreate() method, I call addSetProperties() method to 
>initialize their values (values are from the xml file), however, digester can't find 
>the set methods from the child class, cause they're defined in the parent class 
>(Component).  The temporary solution I had was defining those set methods in the 
>child classes, and have them call the super methods.  But that seems to defeat the 
>whole purpose of inheritance.  Here's an example with the problem:
>
>public class Component {
>public String name = null;
>public void setName(String name) {
>this.name=name;
>}
>public void getname() {
>return this.name;
>}
>}
>
>public class ChildClass extend Component {
>//Other methods that differ from parent class
>}
>
Do you have any beaninfo classes coded/generated for ChildClass?

>
>for the digester rules:
>
>digester.addObjectCreate("ChildClassPattern", "some.package.ChildClass");
>digester.addSetProperties("ChildClassPattern");
>
>so, as it gets to addSetProperties(), it doesn't see any of the get/set methods in 
>ChildClass, and yet, it doesn't know to look its parent class, Component.
>
>I hope I'm able to get my problem across.  Thanks again for taking the time to 
>respond.
>
>--Stacy
>
-- 
dIon Gillard, Multitask Consulting
http://adslgateway.multitask.com.au/developers




--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: Digester and inheritance

2002-03-01 Thread Stacy Weng

But these helper classes all have the same methods and attributes, I would have to 
define all the methods in all the helper classes like the example code from the 
previous email.  And you are suggesting I do that?

--Stacy
  - Original Message - 
  From: Galbreath, Mark 
  To: 'Struts Users Mailing List' 
  Sent: Friday, March 01, 2002 12:45 PM
  Subject: RE: Digester and inheritance


  It appears from your listings and descriptions that Component is basically a
  JavaBean and your helper classes should have "has a" relationships with it,
  not "is a."  Essentially, what I am suggestion is that you wrap Component in
  the helper classes.  Wrappers are far more functional than subclasses (also
  known as the "decorator" pattern) and ensure that adding methods to
  Component will never affect the helpers (loose coupling), making ongoing
  maintenance easier.

  IMHO, implementation (class) inheritance is way overused in Java (even
  within the Java API).

  As for Digester, it is indifferent to the relationships between your
  classes; I am merely suggesting a refactoring of your code.

  Mark

  -Original Message-
  From: Stacy Weng [mailto:[EMAIL PROTECTED]]
  Sent: Friday, March 01, 2002 3:13 PM
  To: Struts Users Mailing List
  Subject: Re: Digester and inheritance


  Wouldn't that be a "has-a" relationship?  If I do that, than I would end up
  with this (since originally I have many child classes extending from
  Component):

  public class Component {
  public String name = null;
  public String getName() {
  return this.name;
  }
  public void setName(String name) {
  this.name=name;
  }
  }

  public class HelperClass1 {
  private final Component c;
  public String getName() {
  return c.getName;
  }
  public void setName(String name) {
  c.setName(name);
  }
  }

  public class HelperClass2 {
  private final Component c;
  public String getName() {
  return c.getName;
  }
  public void setName(String name) {
  c.setName(name);
  }
  }

  public class HelperClass3 {
  private final Component c;
  public String getName() {
  return c.getName;
  }
  public void setName(String name) {
  c.setName(name);
  }
  }

  The reason I'm extending from Component is because these helper classes "is
  - a" Component.  They only have slight variations.  Does digester not handle
  "is-a" relationships?

  --Stacy
  ps - Thanks again for taking the time to respond.  I can't stress how much I
  appreciate it.

- Original Message - 
From: Galbreath, Mark 
To: 'Struts Users Mailing List' 
Sent: Friday, March 01, 2002 2:40 PM
Subject: RE: Digester and inheritance


You are misusing inheritance.  Instead of extending Component, give
HelperClass (was ChildClass) a private field that references an instance
  of
Component (a design pattern known as "composition").Each instance method
  in
HelperClass invokes the corresponding method on the contained instance of
Component and returns the results (a design pattern known as
  "forwarding"):

public class HelperClass {
private final Component c;
public void setName( String name) {
c.setName( name);
}
public String getName() {
return c.getName();
}
}

Cheers!
Mark

-Original Message-
From: Stacy Weng [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 01, 2002 2:12 PM

I have a parent class called Component, and several child classes
  extending
from it.   All the common get/set methods are defined in Component.  So,
after each child is getting created from addObjectCreate() method, I call
addSetProperties() method to initialize their values (values are from the
xml file), however, digester can't find the set methods from the child
class, cause they're defined in the parent class (Component).  The
  temporary
solution I had was defining those set methods in the child classes, and
  have
them call the super methods.  But that seems to defeat the whole purpose
  of
inheritance.  Here's an example with the problem:

public class Component {
public String name = null;
public void setName(String name) {
this.name=name;
}
public void getname() {
return this.name;
}
}

public class ChildClass extend Component {
//Other methods that differ from parent class
}

for the digester rules:

digester.addObjectCreate("ChildClassPattern", "some.package.ChildClass");
digester.addSetProperties("ChildClassPattern");

so, as it gets to addSetProperties(), it doesn't see any of the get/set
   

RE: Digester and inheritance

2002-03-01 Thread Galbreath, Mark

It appears from your listings and descriptions that Component is basically a
JavaBean and your helper classes should have "has a" relationships with it,
not "is a."  Essentially, what I am suggestion is that you wrap Component in
the helper classes.  Wrappers are far more functional than subclasses (also
known as the "decorator" pattern) and ensure that adding methods to
Component will never affect the helpers (loose coupling), making ongoing
maintenance easier.

IMHO, implementation (class) inheritance is way overused in Java (even
within the Java API).

As for Digester, it is indifferent to the relationships between your
classes; I am merely suggesting a refactoring of your code.

Mark

-Original Message-
From: Stacy Weng [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 01, 2002 3:13 PM
To: Struts Users Mailing List
Subject: Re: Digester and inheritance


Wouldn't that be a "has-a" relationship?  If I do that, than I would end up
with this (since originally I have many child classes extending from
Component):

public class Component {
public String name = null;
public String getName() {
return this.name;
}
public void setName(String name) {
this.name=name;
}
}

public class HelperClass1 {
private final Component c;
public String getName() {
return c.getName;
}
public void setName(String name) {
c.setName(name);
}
}

public class HelperClass2 {
private final Component c;
public String getName() {
return c.getName;
}
public void setName(String name) {
c.setName(name);
}
}

public class HelperClass3 {
private final Component c;
public String getName() {
return c.getName;
}
public void setName(String name) {
c.setName(name);
}
}

The reason I'm extending from Component is because these helper classes "is
- a" Component.  They only have slight variations.  Does digester not handle
"is-a" relationships?

--Stacy
ps - Thanks again for taking the time to respond.  I can't stress how much I
appreciate it.

  - Original Message - 
  From: Galbreath, Mark 
  To: 'Struts Users Mailing List' 
  Sent: Friday, March 01, 2002 2:40 PM
  Subject: RE: Digester and inheritance


  You are misusing inheritance.  Instead of extending Component, give
  HelperClass (was ChildClass) a private field that references an instance
of
  Component (a design pattern known as "composition").Each instance method
in
  HelperClass invokes the corresponding method on the contained instance of
  Component and returns the results (a design pattern known as
"forwarding"):

  public class HelperClass {
  private final Component c;
  public void setName( String name) {
  c.setName( name);
  }
  public String getName() {
  return c.getName();
  }
  }

  Cheers!
  Mark

  -Original Message-
  From: Stacy Weng [mailto:[EMAIL PROTECTED]]
  Sent: Friday, March 01, 2002 2:12 PM

  I have a parent class called Component, and several child classes
extending
  from it.   All the common get/set methods are defined in Component.  So,
  after each child is getting created from addObjectCreate() method, I call
  addSetProperties() method to initialize their values (values are from the
  xml file), however, digester can't find the set methods from the child
  class, cause they're defined in the parent class (Component).  The
temporary
  solution I had was defining those set methods in the child classes, and
have
  them call the super methods.  But that seems to defeat the whole purpose
of
  inheritance.  Here's an example with the problem:

  public class Component {
  public String name = null;
  public void setName(String name) {
  this.name=name;
  }
  public void getname() {
  return this.name;
  }
  }

  public class ChildClass extend Component {
  //Other methods that differ from parent class
  }

  for the digester rules:

  digester.addObjectCreate("ChildClassPattern", "some.package.ChildClass");
  digester.addSetProperties("ChildClassPattern");

  so, as it gets to addSetProperties(), it doesn't see any of the get/set
  methods in ChildClass, and yet, it doesn't know to look its parent class,
  Component.

  I hope I'm able to get my problem across.  Thanks again for taking the
time
  to respond.

  --Stacy



  - Original Message - 
From: Fernando Esteban Barril Otero 
To: Struts Users Mailing List 
Sent: Friday, March 01, 2002 1:48 PM
Subject: Re: Digester and inheritance


I'm using digester and inheritance without problems. What kind
of exception are you getting?

Fernando

- Original Message -----
From: "Stacy Weng" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List

Re: Digester and inheritance

2002-03-01 Thread Fernando Esteban Barril Otero

Try writting a small class to list the properties
of your classes (using the JavaBeans API - PropertyDescriptor, etc.).
Then, you can figure out what could be wrong.

Digester doesn't has limitations of this kind. I have the same
hierarchy and it works fine.

Fernando

- Original Message -
From: "Stacy Weng" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Friday, March 01, 2002 5:12 PM
Subject: Re: Digester and inheritance


Wouldn't that be a "has-a" relationship?  If I do that, than I would end up
with this (since originally I have many child classes extending from
Component):

public class Component {
public String name = null;
public String getName() {
return this.name;
}
public void setName(String name) {
this.name=name;
}
}

public class HelperClass1 {
private final Component C;
public String getName() {
return c.getName;
}
public void setName(String name) {
c.setName(name);
}
}

public class HelperClass2 {
private final Component C;
public String getName() {
return c.getName;
}
public void setName(String name) {
c.setName(name);
}
}

public class HelperClass2 {
private final Component C;
public String getName() {
return c.getName;
}
public void setName(String name) {
c.setName(name);
}
}

The reason I'm extending from Component is because these helper classes
"is - a" Component.  They only have slight variations.  Does digester not
handle "is-a" relationships?

--Stacy
ps - Thanks again for taking the time to respond.  I can't stress how much I
appreciate it.



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Re: Digester and inheritance

2002-03-01 Thread Stacy Weng

Wouldn't that be a "has-a" relationship?  If I do that, than I would end up with this 
(since originally I have many child classes extending from Component):

public class Component {
public String name = null;
public String getName() {
return this.name;
}
public void setName(String name) {
this.name=name;
}
}

public class HelperClass1 {
private final Component C;
public String getName() {
return c.getName;
}
public void setName(String name) {
c.setName(name);
}
}

public class HelperClass2 {
private final Component C;
public String getName() {
return c.getName;
}
public void setName(String name) {
c.setName(name);
}
}

public class HelperClass2 {
private final Component C;
public String getName() {
return c.getName;
}
public void setName(String name) {
c.setName(name);
}
}

The reason I'm extending from Component is because these helper classes "is - a" 
Component.  They only have slight variations.  Does digester not handle "is-a" 
relationships?

--Stacy
ps - Thanks again for taking the time to respond.  I can't stress how much I 
appreciate it.

  - Original Message - 
  From: Galbreath, Mark 
  To: 'Struts Users Mailing List' 
  Sent: Friday, March 01, 2002 2:40 PM
  Subject: RE: Digester and inheritance


  You are misusing inheritance.  Instead of extending Component, give
  HelperClass (was ChildClass) a private field that references an instance of
  Component (a design pattern known as "composition").Each instance method in
  HelperClass invokes the corresponding method on the contained instance of
  Component and returns the results (a design pattern known as "forwarding"):

  public class HelperClass {
  private final Component c;
  public void setName( String name) {
  c.setName( name);
  }
  public String getName() {
  return c.getName();
  }
  }

  Cheers!
  Mark

  -Original Message-
  From: Stacy Weng [mailto:[EMAIL PROTECTED]]
  Sent: Friday, March 01, 2002 2:12 PM

  I have a parent class called Component, and several child classes extending
  from it.   All the common get/set methods are defined in Component.  So,
  after each child is getting created from addObjectCreate() method, I call
  addSetProperties() method to initialize their values (values are from the
  xml file), however, digester can't find the set methods from the child
  class, cause they're defined in the parent class (Component).  The temporary
  solution I had was defining those set methods in the child classes, and have
  them call the super methods.  But that seems to defeat the whole purpose of
  inheritance.  Here's an example with the problem:

  public class Component {
  public String name = null;
  public void setName(String name) {
  this.name=name;
  }
  public void getname() {
  return this.name;
  }
  }

  public class ChildClass extend Component {
  //Other methods that differ from parent class
  }

  for the digester rules:

  digester.addObjectCreate("ChildClassPattern", "some.package.ChildClass");
  digester.addSetProperties("ChildClassPattern");

  so, as it gets to addSetProperties(), it doesn't see any of the get/set
  methods in ChildClass, and yet, it doesn't know to look its parent class,
  Component.

  I hope I'm able to get my problem across.  Thanks again for taking the time
  to respond.

  --Stacy



  - Original Message - 
From: Fernando Esteban Barril Otero 
To: Struts Users Mailing List 
Sent: Friday, March 01, 2002 1:48 PM
Subject: Re: Digester and inheritance


I'm using digester and inheritance without problems. What kind
of exception are you getting?

Fernando

- Original Message -
From: "Stacy Weng" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Friday, March 01, 2002 1:20 PM
Subject: Digester and inheritance


Has anyone encountered problems with inheritance using Digester?  It seems
to me that the addSetProperties() does not when its object is inherited
  from
a parent class...hence it assumes the get/set methods aren't defined, when
they are actually defined in its parent class.  I've looked into the
  source,
and it seems that the getMethod call that digester uses does not handle
parent methods.  Is there a patch out there for inheritance with digester?

Once again, thanks again in advance for any input.  It is greatly
appreciated.  =)

--Stacy



--
To unsubscribe, e-mail:
  <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
  <mailto:[EMAIL PROTECTED]>


  --
  To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
  For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: Digester and inheritance

2002-03-01 Thread Galbreath, Mark

You are misusing inheritance.  Instead of extending Component, give
HelperClass (was ChildClass) a private field that references an instance of
Component (a design pattern known as "composition").Each instance method in
HelperClass invokes the corresponding method on the contained instance of
Component and returns the results (a design pattern known as "forwarding"):

public class HelperClass {
private final Component c;
public void setName( String name) {
c.setName( name);
}
public String getName() {
return c.getName();
}
}

Cheers!
Mark

-Original Message-
From: Stacy Weng [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 01, 2002 2:12 PM

I have a parent class called Component, and several child classes extending
from it.   All the common get/set methods are defined in Component.  So,
after each child is getting created from addObjectCreate() method, I call
addSetProperties() method to initialize their values (values are from the
xml file), however, digester can't find the set methods from the child
class, cause they're defined in the parent class (Component).  The temporary
solution I had was defining those set methods in the child classes, and have
them call the super methods.  But that seems to defeat the whole purpose of
inheritance.  Here's an example with the problem:

public class Component {
public String name = null;
public void setName(String name) {
this.name=name;
}
public void getname() {
return this.name;
}
}

public class ChildClass extend Component {
//Other methods that differ from parent class
}

for the digester rules:

digester.addObjectCreate("ChildClassPattern", "some.package.ChildClass");
digester.addSetProperties("ChildClassPattern");

so, as it gets to addSetProperties(), it doesn't see any of the get/set
methods in ChildClass, and yet, it doesn't know to look its parent class,
Component.

I hope I'm able to get my problem across.  Thanks again for taking the time
to respond.

--Stacy



- Original Message - 
  From: Fernando Esteban Barril Otero 
  To: Struts Users Mailing List 
  Sent: Friday, March 01, 2002 1:48 PM
  Subject: Re: Digester and inheritance


  I'm using digester and inheritance without problems. What kind
  of exception are you getting?

  Fernando

  - Original Message -
  From: "Stacy Weng" <[EMAIL PROTECTED]>
  To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
  Sent: Friday, March 01, 2002 1:20 PM
  Subject: Digester and inheritance


  Has anyone encountered problems with inheritance using Digester?  It seems
  to me that the addSetProperties() does not when its object is inherited
from
  a parent class...hence it assumes the get/set methods aren't defined, when
  they are actually defined in its parent class.  I've looked into the
source,
  and it seems that the getMethod call that digester uses does not handle
  parent methods.  Is there a patch out there for inheritance with digester?

  Once again, thanks again in advance for any input.  It is greatly
  appreciated.  =)

  --Stacy



  --
  To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
  For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Re: Digester and inheritance

2002-03-01 Thread Stacy Weng

I have a parent class called Component, and several child classes extending from it.   
All the common get/set methods are defined in Component.  So, after each child is 
getting created from addObjectCreate() method, I call addSetProperties() method to 
initialize their values (values are from the xml file), however, digester can't find 
the set methods from the child class, cause they're defined in the parent class 
(Component).  The temporary solution I had was defining those set methods in the child 
classes, and have them call the super methods.  But that seems to defeat the whole 
purpose of inheritance.  Here's an example with the problem:

public class Component {
public String name = null;
public void setName(String name) {
this.name=name;
}
public void getname() {
return this.name;
}
}

public class ChildClass extend Component {
//Other methods that differ from parent class
}

for the digester rules:

digester.addObjectCreate("ChildClassPattern", "some.package.ChildClass");
digester.addSetProperties("ChildClassPattern");

so, as it gets to addSetProperties(), it doesn't see any of the get/set methods in 
ChildClass, and yet, it doesn't know to look its parent class, Component.

I hope I'm able to get my problem across.  Thanks again for taking the time to respond.

--Stacy



- Original Message - 
  From: Fernando Esteban Barril Otero 
  To: Struts Users Mailing List 
  Sent: Friday, March 01, 2002 1:48 PM
  Subject: Re: Digester and inheritance


  I'm using digester and inheritance without problems. What kind
  of exception are you getting?

  Fernando

  - Original Message -
  From: "Stacy Weng" <[EMAIL PROTECTED]>
  To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
  Sent: Friday, March 01, 2002 1:20 PM
  Subject: Digester and inheritance


  Has anyone encountered problems with inheritance using Digester?  It seems
  to me that the addSetProperties() does not when its object is inherited from
  a parent class...hence it assumes the get/set methods aren't defined, when
  they are actually defined in its parent class.  I've looked into the source,
  and it seems that the getMethod call that digester uses does not handle
  parent methods.  Is there a patch out there for inheritance with digester?

  Once again, thanks again in advance for any input.  It is greatly
  appreciated.  =)

  --Stacy



  --
  To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
  For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Re: Digester and inheritance

2002-03-01 Thread Fernando Esteban Barril Otero

I'm using digester and inheritance without problems. What kind
of exception are you getting?

Fernando

- Original Message -
From: "Stacy Weng" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Friday, March 01, 2002 1:20 PM
Subject: Digester and inheritance


Has anyone encountered problems with inheritance using Digester?  It seems
to me that the addSetProperties() does not when its object is inherited from
a parent class...hence it assumes the get/set methods aren't defined, when
they are actually defined in its parent class.  I've looked into the source,
and it seems that the getMethod call that digester uses does not handle
parent methods.  Is there a patch out there for inheritance with digester?

Once again, thanks again in advance for any input.  It is greatly
appreciated.  =)

--Stacy



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Digester and inheritance

2002-03-01 Thread Stacy Weng

Has anyone encountered problems with inheritance using Digester?  It seems to me that 
the addSetProperties() does not when its object is inherited from a parent 
class...hence it assumes the get/set methods aren't defined, when they are actually 
defined in its parent class.  I've looked into the source, and it seems that the 
getMethod call that digester uses does not handle parent methods.  Is there a patch 
out there for inheritance with digester?

Once again, thanks again in advance for any input.  It is greatly appreciated.  =)

--Stacy