Trying again...

As posted here:
http://stackoverflow.com/questions/606145/jibx-how-to-output-the-fields-from-a-particular-class-into-different-parts-of-th




I've managed to get what I want when mapping with inheritance like this:

ThisClassShouldntExist

  - freeFlowMsg
  - errorMsg

BaseForm **extends** ThisClassShouldntExist

  - function
  - subFunction

SpecificForm **extends** BaseForm

  - address



**My binding.xml:**
<binding>
      <mapping class="com.struts.form.ThisClassShouldntExist"
abstract="true">
            <value name="free-flow-message" field="freeFlowMessage" />
            <value name="error-msg" field="errorMessage" />
      </mapping>

      <mapping class="com.struts.form.BaseForm" abstract="true">
            <value name="prog-name" field="function" />
            <value name="sub-prog-name" field="subFunction" />
      </mapping>

      <mapping name="cngaddress"
class="com.struts.form.AddressDisplayForm">
            <structure name="header">
                  <structure map-as="com.struts.form.BaseForm"
usage="optional" />
            </structure>

            <value name="address" field="addressline1" usage="optional"/>

            <structure name="FOOTER">
                  <structure
map-as="com.struts.form.ThisClassShouldntExist" usage="optional" />
            </structure>
      </mapping>
</binding>



**A sample data:**

    <?xml version="1.0" encoding="UTF-8"?>
    <cngaddress>
      <header>
        <prog-name>prog-name</prog-name>
        <sub-prog-name>sub-prog-name</sub-prog-name>
      </header>
      <address>address</address>
      <FOOTER>
        <free-flow-message>free-flow-message</free-flow-message>
        <error-msg>error-msg</error-msg>
      </FOOTER>
    </cngaddress>

--------
**So, the bottom line is that I need to "split" the output of the class
BaseForm into 2 different part of the XML output. First part goes into
`<header>`, second into `<footer>`, but also I want to avoid the
inheritance just to comply with JibX.**

I tried doing something like this but didn't work:

    <structure name="FOOTER">
    <structure field="aFieldFromSuperClassBaseForm"
map-as="com.struts.form.ThisClassShouldntExist" usage="optional" />
    </structure>

Also tried to define 2 `<mapping>` in the same binding for the same class,
but of course it wouldn't work.

=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain 
confidential or privileged information. If you are 
not the intended recipient, any dissemination, use, 
review, distribution, printing or copying of the 
information contained in this e-mail message 
and/or attachments to it are strictly prohibited. If 
you have received this communication in error, 
please notify us by reply e-mail or telephone and 
immediately and permanently delete the message 
and any attachments. Thank you




------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to