I’ have simple question about JAXB. Here is the sample code:
//setter that has input JAXBElement
b.setBIC(JAXBElement<String> value);
How can I initialize the input element, that uses String from other object?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can create an instance of
JAXBElementdirectly or if you generated your Java model from an XML schema use a convience method on the generatedObjectFactoryclass.schema.xsd
The above demo code is based on a Java model generated from the following XML schema. The reason you get a
JAXBElement<String>property in the first place is when you have an element that is bothnillable="true"andminOccurs="0".Root
The following class was generated from
schema.xsdand contains properties like the one in your question.ObjectFactory
Below is the generated
ObjectFactoryclass that contains convenience methods for creating the instances ofJAXBElement.