You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by robert burrell donkin <ro...@blueyonder.co.uk> on 2005/04/27 00:02:19 UTC
Re: BeWixt's bug where it cannot generate XML if the root class
only contain a class parameter?
sorry it's taken a while: my filters missed the misspelled prefix.
yes, this is a bug (in the ignore empty element code). i've just
committed. if you roll from HEAD or wait till the next nightly, i hope
this your problem will be fixed.
- robert
On Fri, 2005-04-22 at 22:21 -0700, Edmond Wong wrote:
> Hi,
>
> I am using the nightly build of the bewixt library, and got the follow
> problem on the output where the xml document is not generated. The
> problem happen when I have a root class PersonBean where it only
> contains a Book class for its parameter:
>
> import java.io.StringWriter;
> import org.apache.commons.betwixt.io.BeanWriter;
>
> Public class WriteExampleApp {
> public static void main(String[] args) throws Exception {
>
> PersonBean pb = new PersonBean();
> pb.setBook(new Book("Edmond Book", "Edmond"));
> System.out.println(pb);
> StringWriter outputWriter = new StringWriter();
> outputWriter.write("<?xml version='1.0' ?>\n");
> BeanWriter beanWriter = new BeanWriter(outputWriter);
> beanWriter.enablePrettyPrint();
> beanWriter.getBindingConfiguration().setMapIDs(true);
>
> beanWriter.getXMLIntrospector().getConfiguration().setWrapCollectionsInElement(true);
> beanWriter.setWriteEmptyElements(false);
> beanWriter.write(pb);
> System.out.println(outputWriter.toString());
> }
> }
>
> The output:
> PersonBean@f6a746[book=Book@13e8d89[name_of_book=Edmond Book,author=Edmond]]
> <?xml version='1.0' ?>
>
> PersonBean.class:
>
> import org.apache.commons.lang.builder.ToStringBuilder;
>
> public class PersonBean implements java.io.Serializable {
> private Book book = new Book();
> public PersonBean() {
> }
> public PersonBean(Book book) {
> super();
> this.book = book;
> }
> public Book getBook() {
> return this.book;
> }
> public void setBook(Book book) {
> this.book = book;
> }
> public String toString() {
> return ToStringBuilder.reflectionToString(this);
> }
> }
>
> Book.class:
>
> import org.apache.commons.lang.builder.ToStringBuilder;
>
> public class Book implements java.io.Serializable {
> String name_of_book;
> String author;
> public Book() {
> }
> public Book(String name_of_book, String author) {
> super();
> this.name_of_book = name_of_book;
> this.author = author;
> }
> public String getAuthor() {
> return author;
> }
> public void setAuthor(String author) {
> this.author = author;
> }
> public String getName_of_book() {
> return name_of_book;
> }
> public void setName_of_book(String name_of_book) {
> this.name_of_book = name_of_book;
> }
> public String toString() {
> return ToStringBuilder.reflectionToString(this);
> }
> }
>
> Thanks,
>
> Edmond
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: BetWixt's bug where it cannot generate XML if the root class
only contain a class parameter?
Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
On Tue, 2005-04-26 at 18:51 -0700, Edmond Wong wrote:
> Thanks for the fix and Sorry for the misspelled prefix. Edmond
no need to be sorry, just means you waited a little longer for your fix
than you might have otherwise.
- robert
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: BetWixt's bug where it cannot generate XML if the root class
only contain a class parameter?
Posted by Edmond Wong <wy...@pacbell.net>.
Thanks for the fix and Sorry for the misspelled prefix. Edmond
robert burrell donkin wrote:
>sorry it's taken a while: my filters missed the misspelled prefix.
>
>yes, this is a bug (in the ignore empty element code). i've just
>committed. if you roll from HEAD or wait till the next nightly, i hope
>this your problem will be fixed.
>
>- robert
>
>On Fri, 2005-04-22 at 22:21 -0700, Edmond Wong wrote:
>
>
>>Hi,
>>
>>I am using the nightly build of the bewixt library, and got the follow
>>problem on the output where the xml document is not generated. The
>>problem happen when I have a root class PersonBean where it only
>>contains a Book class for its parameter:
>>
>>import java.io.StringWriter;
>>import org.apache.commons.betwixt.io.BeanWriter;
>>
>>Public class WriteExampleApp {
>> public static void main(String[] args) throws Exception {
>>
>> PersonBean pb = new PersonBean();
>> pb.setBook(new Book("Edmond Book", "Edmond"));
>> System.out.println(pb);
>> StringWriter outputWriter = new StringWriter();
>> outputWriter.write("<?xml version='1.0' ?>\n");
>> BeanWriter beanWriter = new BeanWriter(outputWriter);
>> beanWriter.enablePrettyPrint();
>> beanWriter.getBindingConfiguration().setMapIDs(true);
>>
>>beanWriter.getXMLIntrospector().getConfiguration().setWrapCollectionsInElement(true);
>> beanWriter.setWriteEmptyElements(false);
>> beanWriter.write(pb);
>> System.out.println(outputWriter.toString());
>> }
>>}
>>
>>The output:
>>PersonBean@f6a746[book=Book@13e8d89[name_of_book=Edmond Book,author=Edmond]]
>><?xml version='1.0' ?>
>>
>>PersonBean.class:
>>
>>import org.apache.commons.lang.builder.ToStringBuilder;
>>
>>public class PersonBean implements java.io.Serializable {
>> private Book book = new Book();
>> public PersonBean() {
>> }
>> public PersonBean(Book book) {
>> super();
>> this.book = book;
>> }
>> public Book getBook() {
>> return this.book;
>> }
>> public void setBook(Book book) {
>> this.book = book;
>> }
>> public String toString() {
>> return ToStringBuilder.reflectionToString(this);
>> }
>>}
>>
>>Book.class:
>>
>>import org.apache.commons.lang.builder.ToStringBuilder;
>>
>>public class Book implements java.io.Serializable {
>> String name_of_book;
>> String author;
>> public Book() {
>> }
>> public Book(String name_of_book, String author) {
>> super();
>> this.name_of_book = name_of_book;
>> this.author = author;
>> }
>> public String getAuthor() {
>> return author;
>> }
>> public void setAuthor(String author) {
>> this.author = author;
>> }
>> public String getName_of_book() {
>> return name_of_book;
>> }
>> public void setName_of_book(String name_of_book) {
>> this.name_of_book = name_of_book;
>> }
>> public String toString() {
>> return ToStringBuilder.reflectionToString(this);
>> }
>>}
>>
>>Thanks,
>>
>>Edmond
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>>
>>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org