commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From __matthewHawthorne <>
Subject Re: BasicDynaBean and overriding the toString()
Date Mon, 01 Dec 2003 19:24:09 GMT
It sounds like you need to define some type of display wrapper.

You could create a static method to do this:

static final String display(BasicDynaBean bean, String prop) {
	return return bean.get(prop);

Or create a hierarchy -- if you're into this sort of thing...

public abstract BasicDynaBeanView
	BasicDynaBeanView(BasicDynaBean bean) {

	abstract String display() {}

So, if I'm understanding you correctly, there are tons of ways to solve 
your problem.  You need to create a layer in between your GUI and the 
DynaBeans which contain the data.

dumdum 420 wrote:
> Hi All,
> I am using the BasicDynaBean for my entire project which seemed to be 
> working fine till I started coding for the frontend which is java swing 
> based.
> Since the BasicDynaBean has not overridden the toString method when I 
> try to display my JTree using these beans all i get is the Objects 
> memory address which I am not really interested.
> Now since I have lot of swing based componenets  which have similar 
> behaviour I am wondering how can I override toString method to get 
> desired results ie may be return a propertyName say for example
> public String toString(){
>     return this.get("person_Name");
> }
> BTW: Remember that the Bean is same across the project and I cannot do 
> this method in the bean since then for say another usecase this property 
> does not even exist.
> If I am not clear please ask me again.
> I am really stuck and really need a solution.
> Thanx in advace.
> dumdum420
> _________________________________________________________________
> online games and music with a high-speed Internet connection!  Prices 
> start at less than $1 a day average. (Prices 
> may vary by service area.)

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

View raw message