0

I would like to create an empty tag for one of my attribute when its value is null in JIBX. Can some one please help me out? Lets say i have an attribute called

private String webId

For the above attribute , there is no value coming from DB, so its always null but , its a mandatory tag to be displayed as part of my response , so i want to show an empty tag for this attribute as <webId/>. My mapping in binding file is

 <value name="webId" field="webId" />

Please note: i don't want to manually set its value as empty string if its value is null ,like

if(webId==null){
   productDetails.setWebId("");
}
bdoughan
  • 147,609
  • 23
  • 300
  • 400
user2334926
  • 321
  • 2
  • 7
  • 16

1 Answers1

0

You can initialize the value in your class to an empty string like :

private String webId =  new String();

So when JiBX does marshal, the XML will have an empty tag for it.

I tested this and it works for me.

Abubakkar
  • 15,488
  • 8
  • 55
  • 83