Page 1 of 1

How to add ComboBox to Sdt.

PostPosted: Fri Dec 07, 2012 10:53 pm
by pejfel
I tray to use org.docx4j.wml.CTSdtComboBox but I encounter the exception:
[com.sun.istack.internal.SAXException2: unable to marshal type "org.docx4j.wml.CTSdtComboBox" as an element because it is missing an @XmlRootElement annotation]

I know that CTSdtComboBox does not have an @XmlRootElement. Can you tell me how to create ComboBox for docx documents ?

This is my code:

SdtBlock sdt = wmlFactory.createSdtBlock();
org.docx4j.wml.SdtPr sdtPr = wmlFactory.createSdtPr();
org.docx4j.wml.CTSdtComboBox cTSdtComboBox = wmlFactory.createCTSdtComboBox();
CTSdtListItem item = wmlFactory.createCTSdtListItem();
item.setValue("My value");

sdtPr.getRPrOrAliasOrLock().add(cTSdtComboBox); // THIS THROWS com.sun.istack.internal.SAXException2

Re: How to add ComboBox to Sdt.

PostPosted: Mon Dec 10, 2012 7:16 pm
by jason
To create a structure like:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
          <w:listItem w:value="Choose an item."/>
          <w:listItem w:displayText="n1" w:value="v1"/>
          <w:listItem w:displayText="n2" w:value="v2"/>
Parsed in 0.001 seconds, using GeSHi

please use ObjectFactory's:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
     * Create an instance of {@link JAXBElement }{@code <}{@link CTSdtComboBox }{@code >}}

    @XmlElementDecl(namespace = "", name = "comboBox", scope = SdtPr.class)
    public JAXBElement<CTSdtComboBox> createSdtPrComboBox(CTSdtComboBox value) {
        return new JAXBElement<CTSdtComboBox>(_SdtPrComboBox_QNAME, CTSdtComboBox.class, SdtPr.class, value);
Parsed in 0.015 seconds, using GeSHi

and add JAXBElement<CTSdtComboBox> to the sdtPr object.

In a day or so I'll move this topic to forum data-binding-java-f16/