You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Maarten Bosteels <mb...@gmail.com> on 2008/02/02 15:52:23 UTC

Re: null on attribute setter

I guess you can achieve this with a custom PrePostSet extension ?

Jacob Danner just posted a link to an interesting article:
http://www.ibm.com/developerworks/xml/library/x-xmlbeanse/?S_TACT=105AGX54&S_CMP=B0201&ca=dnw-904

Would it work to restore the oldValue when the newValue is null ?
Or even better: to return false from the postSet method ?

The postSet method returns void according to
http://wiki.apache.org/xmlbeans/PrePostSetFeature
but in the article it returns a boolean ?

Maarten

On Jan 28, 2008 10:28 PM, Radu Preotiuc-Pietro <ra...@bea.com> wrote:

> Right now, the more verbose code that you posted is the only way to get
> what you want.
>
> Radu
>
> On Mon, 2008-01-28 at 21:06 +0100, Veit Guna wrote:
> > Hi all.
> >
> > I'm encountering the same problem explained in here:
> >
> > http://www.mail-archive.com/user@xmlbeans.apache.org/msg00541.html
> >
> > As soon as I call setFoo(null) on Bar the xml output looks like
> >
> > <bar foo=""/>
> >
> > If I leave the set out, it renders like this:
> >
> > <bar/>
> >
> > Since I'm copying several attributes from my domain model from/to the
> > xmlbeans I'm searching for a way to let xmlbeans handle set(null) as
> > unset. I would like to avoid the
> >
> > if {bo.getFoo() != null) {
> >       xb.setFoo(bo.getFoo());
> > }
> >
> > construct for _every_ attribute. Always setting null to "" in xml is a
> > bit noisy for me.
> >
> > Is there any way to achieve this? Perhaps something like XmlOptions or
> > similar?
> >
> > Regards,
> > Veit
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> > For additional commands, e-mail: user-help@xmlbeans.apache.org
> >
>
> Notice:  This email message, together with any attachments, may contain
> information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
> entities,  that may be confidential,  proprietary,  copyrighted  and/or
> legally privileged, and is intended solely for the use of the individual or
> entity named in this message. If you are not the intended recipient, and
> have received this message in error, please immediately return this by email
> and then delete it.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
>
>