You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by "Nation, Carey" <Ca...@turner.com> on 2004/09/09 19:07:36 UTC

Property not being set [Digester]

Hi,
I have some xml that uses attributes.  One of the properties that maps to an attribute is stored internally as a class of mine.  The setter
accepts a String and instantiates one of my objects passing the string to the ctor and stores the ref to that object in my bean.  Something like this:

class Foo
{
    public Foo( String s)...
}

class Bean
{
   private Foo f;

   public void setFoo( String s)
   {
      f = new Foo( s);
   }
}

<bean foo="12345" />

When I get the object back, f is null.  Bean is actually nested inside another object, if that matters.

I know that setFoo is being called because I put a trace message in there.  I know further than the "final" object that I'm getting back from digester is not the instance that is calling setFoo, because I printed out the toString with the instance info on there.

There are other fields in Bean that are base Java types (int, String), that are making it to the final instance of the object.

I thought maybe they were calling clone, but it doesn't appear that that is happening.  So what is happening?  What do I have to do to get my fields copied (or whatever magic is happening)?

Thanks,
Carey Nation


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


Re: Property not being set [Digester]

Posted by José Antonio Pérez Testa <ja...@indra.es>.
Could you bring us an idea of the Digester rules that you are using?
Looking at my crystal ball  i can imagine that you are not pushing 
anything in the Digester stack before calling parse().

Nation, Carey wrote:

>Hi,
>I have some xml that uses attributes.  One of the properties that maps to an attribute is stored internally as a class of mine.  The setter
>accepts a String and instantiates one of my objects passing the string to the ctor and stores the ref to that object in my bean.  Something like this:
>
>class Foo
>{
>    public Foo( String s)...
>}
>
>class Bean
>{
>   private Foo f;
>
>   public void setFoo( String s)
>   {
>      f = new Foo( s);
>   }
>}
>
><bean foo="12345" />
>
>When I get the object back, f is null.  Bean is actually nested inside another object, if that matters.
>
>I know that setFoo is being called because I put a trace message in there.  I know further than the "final" object that I'm getting back from digester is not the instance that is calling setFoo, because I printed out the toString with the instance info on there.
>
>There are other fields in Bean that are base Java types (int, String), that are making it to the final instance of the object.
>
>I thought maybe they were calling clone, but it doesn't appear that that is happening.  So what is happening?  What do I have to do to get my fields copied (or whatever magic is happening)?
>
>Thanks,
>Carey Nation
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>  
>
-------------------------------------------------------------------------------------------------------------------
Este correo electrónico y, en su caso, cualquier fichero anexo al mismo, contiene información de carácter confidencial exclusivamente dirigida a su destinatario o destinatarios. Queda prohibida su divulgación, copia o distribución a terceros sin la previa autorización escrita de Indra. En el caso de haber recibido este correo electrónico por error, se ruega notificar inmediatamente esta circunstancia mediante reenvío a la dirección electrónica del remitente.

The information in this e-mail and in any attachments is confidential and solely for the attention and use of the named addressee(s). You are hereby notified that any dissemination, distribution or copy of this communication is prohibited without the prior written consent of Indra. If you have received this communication in error, please, notify the sender by reply e-mail

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