(Bhi, robert
(BThanks for you help very much!
(B
(BBut still I can not use it well. I tried a custom ObjectStringConverter and
(Bdid not get the output I wished.
(BMy problem is: how to eliminate some object in the output? (Since I do want
(Bto show other null object in the
(Boutput XML, I can not use "setWriteEmptyElements" to do that.)
(BCould you show me some good samples of that?
(B
(B
(B// ====================================
(B// Here is the converter I used
(B// ====================================
(Bpublic class MyConverter extends ConvertUtilsObjectStringConverter {
(B public String objectToString(Object object, Class type, String
(Bflavour, Context context) {
(B if ( object == null ) {
(B return "";
(B }
(B
(B if ( Calendar.class.equals(context.getBean().getClass())
(B ||
(BGregorianCalendar.class.equals(context.getBean().getClass()) ) {
(B if (Date.class.equals(type)) {
(B
(B DateFormat dateFormat = new
(BSimpleDateFormat("''yyyy-MM-dd HH:mm:ss.SSS z''");
(B
(BdateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
(B
(B String myTime = dateFormat.format((Date)
(B((GregorianCalendar) context.getBean()).getTime());
(B return myTime;
(B }
(B return "";
(B }
(B
(B if ( ZoneInfo.class.equals(context.getBean().getClass()) ) {
(B context.setBean(null);
(B return "";
(B }
(B
(B return ConvertUtils.convert( object );
(B }
(B
(B public Object stringToObject(String value, Class type, String
(Bflavour, Context context) {
(B ......
(B }
(B}
(B
(B// ====================================
(B// Here is the output I got
(B// ====================================
(B <MyBean>
(B ......
(B ......
(B ......
(B <myCal>
(B <firstDayOfWeek/>
(B <gregorianChange>'2004-09-21 13:11:04.234 UTC'</gregorianChange>
(B <lenient/>
(B <minimalDaysInFirstWeek/>
(B <time>'2004-09-21 13:11:04.234 UTC'</time>
(B <timeInMillis/>
(B <timeZone>
(B <DSTSavings/>
(B <ID/>
(B <displayName/>
(B <rawOffset/>
(B </timeZone>
(B </myCal>
(B ......
(B ......
(B ......
(B </MyBean>
(B
(B// ====================================
(B// and Here is the output I wished
(B// ====================================
(B <MyBean>
(B ......
(B ......
(B ......
(B <myCal>'2004-09-21 13:11:04.234 UTC'</myCal>
(B ......
(B ......
(B ......
(B </MyBean>
(B
(B
(B
(B
(B|---------+-------------------------------------->
(B| | robert burrell donkin |
(B| | <[EMAIL PROTECTED]|
(B| | nder.co.uk> |
(B| | |
(B| | 2004/09/17 06:46 |
(B| | "Jakarta Commons Users |
(B| | List" $B$XJV?.$7$F$/[EMAIL PROTECTED](B |
(B| | |
(B|---------+-------------------------------------->
(B
(B>------------------------------------------------------------------------------------------------------------------------------|
(B |
(B |
(B | [EMAIL PROTECTED](B: "Jakarta Commons Users List" <[EMAIL PROTECTED]>
(B |
(B | cc: (bcc: Ikuki Toh/O/RICOH)
(B |
(B | $B7oL>(B: Re: Betwixt - How to control the output in BeanToXml
(B |
(B
(B>------------------------------------------------------------------------------------------------------------------------------|
(B
(B
(B
(B
(B(hopefully better late than never)
(B
(Byes: use a custom object <-> string converter. see
(Bhttp://jakarta.apache.org/commons/betwixt/guide/binding.html for more
(Bdetails.
(B
(B- robert
(B
(BOn 8 Sep 2004, at 04:07, [EMAIL PROTECTED] wrote:
(B
(B> hi, I am a beginner of commons.betwixt.
(B> I just wondering if Betwixt can do this and how : when convert a Bean
(B> To
(B> Xml,
(B> Could betwixt recognize an object in the bean I input, and then change
(B> the
(B> output
(B> of it to another object(exp : Date) in the XML?
(B>
(B>
(B> FOR EXAMPLE : >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
(B> If there is a Calendar in myBean, could Betwixt just write it as a
(B> Date in
(B> the output XML?
(B> // ====================================
(B> // If the Bean for convert is =>
(B> // ====================================
(B> public class MyBean {
(B>
(B> private String id;
(B> private String name;
(B> private String[] emails;
(B> ..........
(B> private Calendar myCal;
(B>
(B> ..........
(B>
(B> }
(B>
(B> // ====================================
(B> // The output XML I hoped is =>
(B> // ====================================
(B> <?xml version='1.0' encoding='UTF-8'?>
(B> <mybean>
(B> <String>id value</String>
(B> <String>name value</String>
(B> <String>email value</String>
(B> ..........
(B> <Date>Date value</Date>
(B> ..........
(B> </mybean>
(B>
(B> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
(B>
(B> appreciate for any re, thanks!
(B>
(B> Dong
(B>
(B>
(B>
(B> ---------------------------------------------------------------------
(B> To unsubscribe, e-mail: [EMAIL PROTECTED]
(B> For additional commands, e-mail: [EMAIL PROTECTED]
(B>
(B>
(B
(B
(B---------------------------------------------------------------------
(BTo unsubscribe, e-mail: [EMAIL PROTECTED]
(BFor additional commands, e-mail: [EMAIL PROTECTED]
(B
(B
(B
(B
(B
(B
(B---------------------------------------------------------------------
(BTo unsubscribe, e-mail: [EMAIL PROTECTED]
(BFor additional commands, e-mail: [EMAIL PROTECTED]