[prev in list] [next in list] [prev in thread] [next in thread] 

List:       castor-user
Subject:    Re: [castor-user] Field value as node="text" broken?
From:       "Tim Mulle" <Tim.Mulle () lighthammer ! com>
Date:       2005-03-30 14:26:08
Message-ID: 4B97121B3CC5B441BC460EA364F02AA40107AFE2 () EX-101 ! mail ! navisite ! com
[Download RAW message or body]



This is a multi-part message in MIME format.

--MML_1112192937_27809@3976.exolab.org
Content-class: urn:content-classes:message
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Anyone else seeing this issue? Or is it something I'm doing wacky? 

-----Original Message-----
From: Tim Mulle [mailto:Tim.Mulle@lighthammer.com] 
Sent: Monday, March 28, 2005 9:45 AM
To: castor-user@exolab.org
Subject: [castor-user] Field value as node="text" broken?

Hi,

I've been using the latest 0.9.6-xml.jar and was trying to do a simple
mapping of my class and found strange behaviour. Below are the test
classes, mapping, etc. 

We are trying to map a field called jspPage to an element with attribute
values of the fields width and height in our javabean. We also want the
actual value of the jspPage field to be a text node. For some reason,
when trying to make it a text node, the value of the jspPage field ends
up at the top level node. If I make the value map as an attribute, it
goes into the correct location but as an attribute and not a text node.
If I don't give the jspPage field a location="jspPage", Castor ends up
creating two "jspPage" elements, one with just the text field value, the
other containing the attributes height and width..and of course Castor
complains when trying to unmarshal because of the duplicate "jspPage"
elements.

Is this a bug? Or am I mapping something wrong?

Thanks,
 - Tim



Expected Result:
<config name="My NAME">
    <workerClassName>my.cool.class</workerClassName>
    <jspPage height="300" width="200">something.jsp</jspPage>
    <handler className="some.handler.class"/> </config>

But got this instead.
Unexpected Result: Notice that the jspPage field value "something.jsp"
is not in the correct location.

<?xml version="1.0" encoding="UTF-8"?>
<config name="My NAME">something.jsp
    <workerClassName>my.cool.class</workerClassName>
    <jspPage height="300" width="200"/>
    <handler className="some.handler.class"/> </config>


Mapping file:
<?xml version="1.0"?>
<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Object Mapping DTD Version
1.0//EN"
                         "http://castor.exolab.org/mapping.dtd">
<mapping>
    <description>Test Mapping file</description>

     <class name="ConfigInfo">
        <map-to xml="config"/>

        <field name="name" type="string">
            <bind-xml name="name" node="attribute"/>
        </field>

        <field name="height" type="integer">
            <bind-xml node="attribute" location="jspPage"/>
        </field>

         <field name="width" type="integer">
            <bind-xml node="attribute" location="jspPage"/>
        </field>

         <field name="jspPage" type="string">
            <bind-xml name="value" location="jspPage" node="text"/>
        </field>

        <field name="workerClassName" type="string">
            <bind-xml name="workerClassName" node="element"/>
        </field>

        <field name="handlerClassName" type="string">
            <bind-xml name="className" node="attribute"
location="handler"/>
        </field>
    </class>
</mapping>

ConfigInfo.java

public class ConfigInfo {

    private String name;
    private String workerClassName;
    private String jspPage;
    private String handlerClassName;

    private int height = 600;
    private int width = 440;

    public String getHandlerClassName() {
        return handlerClassName;
    }
    public void setHandlerClassName(String handlerClassName) {
        this.handlerClassName = handlerClassName;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getWorkerClassName() {
        return workerClassName;
    }
    public void setWorkerClassName(String workerClassName) {
        this.workerClassName = workerClassName;
    }
    public String getJspPage() {
        return jspPage;
    }
    public void setJspPage(String jspPage) {
        this.jspPage = jspPage;
    }
    public int getHeight() {
        return height;
    }
    public void setHeight(int height) {
        this.height = height;
    }
    public int getWidth() {
        return width;
    }
    public void setWidth(int width) {
        this.width = width;
    }

    public String toString() {
        final StringBuffer buf = new StringBuffer();
        buf.append("ConfigInfo");
        buf.append("{name=").append(name);
        buf.append(",workerClassName=").append(workerClassName);
        buf.append(",jspPage=").append(jspPage);
        buf.append(",handlerClassName=").append(handlerClassName);
        buf.append(",height=").append(height);
        buf.append(",width=").append(width);
        buf.append('}');
        return buf.toString();
    }
}


--MML_1112192937_27809@3976.exolab.org
Content-Type: text/plain; charset=us-ascii; name="footer"
Content-Transfer-Encoding: 8bit

-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
minimalist@exolab.org with a subject of:
        unsubscribe castor-user

--MML_1112192937_27809@3976.exolab.org--
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic